-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Seeking clarification on pulse_cnt capabilities. #11633
-
I am seeking to upgrade an old project from pcnt to pulse_cnt. I am not a professional developer (hence my existence in the Arduino universe). I have read the Expressif write-ups, and a lot else besides; I am particularly trying to get my head around counter overflow. This term only gets mentioned in the section "Compensate Overflow Loss", and all it says is:
1.Enable [pcnt_unit_config_t::accum_count] when installing the PCNT unit.
2.Add the high/low limit as the [Watch Points].
3.Now, the returned count value from the [pcnt_unit_get_count()]function not only reflects the hardware's count value, but also accumulates the high/low overflow loss to it.
So would one normally set the High/Low limits at INT16_MAX and INT16_MIN? Some examples I have seen appear to set these limits at, (one example) +/-32760.
And what does "accumulates the high/low overflow" mean? My reading of esp-idf/issues/10167 (again, noting I am not a professional developer, so much of that is over my head) suggests that, by simply enabling accum_count when installing gives me a complete 32 bit counter with interrupt overhead (in the absence of other watchpoints) only at High/Low limit events, and regardless of what these limits are, I will still have a complete 32 bit counter (well 64000 times the count limits, I guess). My reading also suggests that all the associated get_count calls, and indeed all the now "hidden" interrupts and other magic are sufficiently atomic to the extent that 4 counters can all be independently flying along under FreeRTOS without any application-level ISRs, etc.
If my reading is correct, that is pure magic.
But is my understanding correct? I suspect not, because there is so little that I can find on Google about this.
But if I am correct, has that magic (noting issue 10167) been rolled yet into the current Arduino release?
Beta Was this translation helpful? Give feedback.