OliviliK / ESP32_timer_u32

14 stars 0 forks source link

Usage with ESP32-S3 #2

Open electricityforprogress opened 10 months ago

electricityforprogress commented 10 months ago

I was trying to get this working with the ESP32-S3, and while it compiles, I was not able to return a value from the systimer using timer_u32. I suppose the registers might be different from the S2 to the S3. Do you have any advice on how I can read the SYSTIMER (s) on an S3? I see there are two counters (UNIT1/UNIT0) and three comparators in the S3.

I am looking at the tech reference and I see that register bit needs to be loaded, waited, and then read just as your algorithm. But I am not quite savvy enough to translate the hex values to update the REG_WRITE, _GET, and _READ

I am using this high speed timer to measure pulses coming from a 555 timer set as astable which is measuring changing conductivity in an organic system. I use a 7.4pf timing capacitor so the pulses are quite fast and I am looking to detect small variations in pulse width from the 555 using the SYSTIMER

thanks for the advice - Sam

electricityforprogress commented 10 months ago

I did locate a solution for accessing the high speed timer in the S3 (sometimes just asking a question helps to find solutions). This provides a 64 bit number, so I think i will try to take the low 32bits and use that as the value for measuring short incoming pulses.

include "hal/cpu_hal.h"

cpu_hal_get_cycle_count()

OliviliK commented 10 months ago

I had not tested the timer capabilities in S3. I am pleased to notice your discovery of the HAL get cycle count function. At the moment I am waiting for the ESP32-P4 as an alternative for Teensy and Raspberry PI. I hope that it will not introduce an additional high speed counter.

electricityforprogress commented 9 months ago

Oh yeah, aren't we all waiting for the P4!? big thanks for your open source contributions which have helped me over many years.