-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Timer based on ESP-IDF API #5931
Conversation
Noticed that the RepeatTimer example (main branch) doesn’t work on ESP32-S2 (works OK on ESP-WROOM-32). Before I open a new issue…looks like it might be related & addressed by this PR? If so, will just keep an eye on the status here. Thx. |
Answering my own question (and for author’s and maintainers’ edification): can confirm this fixes the RepeatTimer example, correctly runs on both WROOM and S2 after this. Looks like it gets Adafruit_Protomatter working again as well. Thx! |
Tagging @ladyada on this to follow along on current status. |
Timer1 and Timer2 can't be used at the same time since 2.0.2. I believe this is because... // Works for all chips right ? |
Hi @AkiHigashi, All timers work at the same time. Tested on 2.0.3 :)
This is just definition of timer groups / numbers for ESP-IDF API. |
In the function timer_dev[] is used as So I think in the cases num=1 and num=2 result in the same [hw_timer_t * timer]. How? |
The 1st number is GROUP, 2nd number is TIMER NUMBER.
Read the comment on that line, it will get the combination of group/number from the num passed to the begin function. Then it will configure the timers by group/num.
If you call timerBegin() with 0 / 1 / 2 or 3 you will always get different group/timer_num :) You can check arduino-esp32 timer doc and ESP-IDF timer docs if needed. |
Last comment. timerBegin(0, uint16_t divider, bool countUp) timerBegin(1, uint16_t divider, bool countUp) timerBegin(2, uint16_t divider, bool countUp) timerBegin(3, uint16_t divider, bool countUp) static hw_timer_t timer_dev[4] = { should be static hw_timer_t timer_dev[4] = { In esp32-hal-timer.c (2.0.1) typedef struct hw_timer_s { static hw_timer_t hw_timer[4] = { bye |
Yep you are right, sorry i was blind. That is a mistake in the definition. Should be like you posted. Thanks for finding that. I will make a PR with a fix :) |
Tnx! |
@P-R-O-C-H-Y The PR changes the definition of |
@mrengineer7777 |
Summary
This PR is refactoring of TIMER HAL in order to use IDF instead of current Register manipulation approach.
I will do more tests, but everything seems to be working on all chips.
Impact
None.