Replies: 2 comments
|
The 50 ns offset is consistent with the documented peripheral behavior at 20 MHz; Two details matter here:
So the scope trace does not show TCB counting one tick early. It shows both counters synchronized, followed by different specified output latency. Changing period, slew, or inversion would not remove that fixed one-clock relationship, which matches your tests. There is also a separate startup trap in the final line of the sketch. The ATtiny3224/3226/3227 silicon errata says that, with TCB in TCA0.SINGLE.CTRLESET = TCA_SINGLE_CMD_RESTART_gc | 0x02;References:
Practical consequences:
Thus I would classify this as a documented one-clock output-path latency plus a relevant silicon erratum, not a megaTinyCore synchronization bug. |
|
Thank you kindly for your thorough response! I didn't think it was megaTinyCore, but I was really hoping I'd found a silicon bug in the wild. That would have been pretty neat. I do agree that this is a documented one-clock output-path latency and that you are correct. In regards to the erratum, I saw that but it doesn't seem to be affecting this chip and doesn't apply to it according to 322X errata. Microchip didn't update their online documents, I guess. If I understand this correctly, output from pymcuprog with -v info, relevant porttion:
So I think that means this is a REV A ATtiny 3224. The pdf of Silicon Errata and Data Sheet Clarifications ATtiny3224/3226/3227 Rev C 3-2026 doesn't mention that bug. Per your link to Series 2 errata, at the bottom of the page, "The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page." It only shows a 16bit register problem on TCB. So, I think the pdf errata for the 322X parts takes precedence over the 2 series errata Microchip gives online.
If I understand this correctly, testing also bears out that the bug isn't present in these chips. I modified the code from my initial post: changed the periods around a little, added enable/disable of TCB, delays, TCA reset, and nops into main. It's ugly but I can capture the reset's effect on TCB. Wide view of the above code, TCB starts up within the low of TCA. 30 or so NOPS/Cycles later, TCA is reset. TCB synchronizes with a visible discontinuity. When TCA overflows towards the right edge of the screen, you can see TCB sync again with a discontinuity: Closer view of the TCA reset and TCB sync. At least I think this is what is going on. I'm not in any way an expert and am happy to be corrected. Ultimately, I can work around the cycle of latency in TCA. I just thought it was interesting. Thank you again for taking the time to look at this and respond. It is appreciated. |








The 50 ns offset is consistent with the documented peripheral behavior at 20 MHz;
SYNCUPDsynchronizes the counter restart, not the two waveform-output datapaths.Two details matter here:
CNTreaching BOTTOM, TOP, orCMPnoccurs on the nextCLK_TCAcycle. WithDIV1at 20 MHz, that is exactly 50 ns.CCMPH. Its output path is therefore one TCA clock ahead of the delayed TCA WO update even though both counters reach BOTTOM together.So the scope trace does not show TCB counting one tick early. It shows both counter…