Async slower than Sync? TCB Single Shot on 2 Series #735
-
I'm using EXTCLK, events, RTC, TCBs and CCL on ATtiny3227. The 10 MHz EXTCLK is feeding RTC
I am generating a waveform output representing the RTC divided by 256 using events (clocked by the RTC clock - EXTCLK)
Then I'm feeding the
The strange thing is the response of the TCB0 single shot event pulse, with respect to the I understand that the single shot mode can take two clock cycles to commence timing (note that my Please shout if you can see where this or any other signal propagation delays may be coming from. If anyone would like to test this, please say and I will provide a minimal example. EDIT I have re-read the TCB section on single-shot mode. I think it might explain the observed behaviour after all. Although it appears when the signal of interest to be counted is (or synchronous with) the peripheral clock the
So, my EDIT 2022-12-02 I have amended code throughout this discussion that I have posted to use the more correct |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 11 replies
-
I would try retesting with a very simple case: Pick a pin. Set it output Wait for a few seconds, then use a single clock method to drive the pin high, eg digitalWriteFast(PIN_PA4,HIGH); Either way it is rendered as sbi VPORTA 1<<4 (don't generalize this to other registrers. On any register outside the I/O space the compiler would instead generate lds (3 clocks 2 words) ori (1 word 1 clock) sts (2 word 2 clock for 7clocks and 3 words instead of 1 of each, since cbi nd sbi only work on the first 32 registers, and are the only ones that are atomic. When that pin is your generator, it''s rising will trigger the scope, and you'' then see the beginning and end of the pulse (and if you've got mo0re than 2 channels you can watch the system clock too to make it more clear. Those two beginning to end traces should make whatever is going on a lot more clear, whilst removing all the confounding variables of a wacky source of events and configurable logic - because I agree that the problem is single shot mode specifically. If that still reproduces the problem complain to microchip, because that would imply you found movel silicon errata. |
Beta Was this translation helpful? Give feedback.
-
Well guess what I'm adding to my Tindie store? A freshly assembled batch of
Rev. D ATtiny3227 PCBs ;-) no need to dead bug anything.
Signals do take a finite length of time to pass through stages of the event
system and the CCLs.
You can demonstrate it by comparing a LUT with a truth table of 0b00000001,
input 0 set to feedback and enable pin input.
Or set the LUT - or the output pin - as a generator channel, set the CCLs
eventA user to and use that as input 0. You;l see different speeds in both
cases.
But That's not, I don't think, exactly what's happening here.
I'd first perform due dilligence by putting a _NOP(); or between those two
toggle instructions. mostly as a sanity check
I would also try instead of the port registers, doing it the fast way, with
the VPORTs. and seeing how that changed behavior
```
digitalWriteFast(PIN_PA4,HIGH);
digitalWriteFast(PIN_PA4,LOW)';
```
or the equivalent but less readable
```
VPORTA.OUT |= 1<<4;
VPORTA.OUT &= ~(1<<4);
```
Single bit set or clear in a register in the low I/O space (like the
VPORTS) can be done in a single clock cycle. So I'd expect your code to do
a 2 clock pulse, and my suggestion to do a 1 clock pulse (and in all cases,
the clock pulses could be elongated wiith nops. You can use multiple in a
row, or 2 clocks in 1 word with _NOPNOP (I think, if not you'll be able to
next version.)
You're either geting a 2 clock sync delay from the wrong edge, or a 4 clock sync delay and neitehr of those really make sense.
I really think this is a Microchip support question, unrelated to anything the core has control over. Is this supposed to a syncronization delay of 2 clocks like I'd expect or is it four?" If they say that 4 system clocks is expected I'd love to see their explanation of where that is described in the datasheet, because I don't think it is. I've read that datasheet very carefully...
|
Beta Was this translation helpful? Give feedback.
-
I opened a ticket with Microchip support a few days ago and they have just assigned someone who said
So that's positive. I linked to this discussion in the ticket, to save repeating everything above. So maybe you can let them know any further thoughts if you post here in the near term. |
Beta Was this translation helpful? Give feedback.
-
I'm guessing another entry on the errata list that doesn't get fixed |
Beta Was this translation helpful? Give feedback.
-
I have an update from Microchip support on the TCB event user behaviour:
And a little while later, they came back with:
So, we have been seeing async running slower than expected. I've asked if this will end up in errata but maybe @SpenceKonde wants to add it to his own list in this repo. |
Beta Was this translation helpful? Give feedback.
-
If yo describe it and let me know what parts it happens on I'd be happy tp put it onto the errata lists. Async events on otherwise sync devicves is something thy seem to strugle with (like not surprising, it sounsds hard. Apparently the second about pin interrupts having a 3 clock retrigger delay on partially async but not fullty async pins is also backwards. Of course, it is, because the async event source needs to get synchronized to the system clock! |
Beta Was this translation helpful? Give feedback.
-
I have a final answer from Microchip:
So this affects lots of parts. Hope it isn't a problem for anyone else. |
Beta Was this translation helpful? Give feedback.
-
Thanks for update. I dobt suppose theycmenrioned if it was silicon errata
(it not working but some day we hope to fix it maybe, or a datasheet
clarifucation type issue so i know what to say in the errata summary?or a a
datasheet clarification? " oh, did we say it would do something else ? Let
me see that datasheet, u can clear that right up" * holding a marker*
…____________
Spence Konde
Azzy’S Electronics
New products! Check them out at tindie.com/stores/DrAzzy
GitHub: github.com/SpenceKonde
ATTinyCore: Arduino support for almost every ATTiny microcontroller
Contact: ***@***.***
On Thu, Dec 1, 2022, 20:40 SimonMerrett ***@***.***> wrote:
I have a final answer from Microchip:
Below provided is the feedback from the internal team.
“Since the event is async, the TCB will start counting 2-3 cycles after
the async event is received, but since the PWM is set/cleared one clock
cycle delayed compared to the counter value the PWM output ends up, in this
mode, being 3-4 clock cycles longer than defined by the CMP setting.
It is the same for all: tiny0/1/2, mega0, AVR DA/DB/DD”
With this confirmation, the behavior affects all tiny 0/1/2, mega0, AVR Dx
families (sharing the same TCB macro).
So this affects lots of parts. Hope it isn't a problem for anyone else.
—
Reply to this email directly, view it on GitHub
<#735 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTXEW6YJZELO22QVWZXGNDWLFHQRANCNFSM53A33LAQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
I have a final answer from Microchip:
So this affects lots of parts. Hope it isn't a problem for anyone else.