Skip to content
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

Timer setup #100

Open
tpcorrea opened this issue May 12, 2022 · 3 comments
Open

Timer setup #100

tpcorrea opened this issue May 12, 2022 · 3 comments
Labels
wait for feedback Feedback is needed

Comments

@tpcorrea
Copy link

tpcorrea commented May 12, 2022

Hello, everyone! I am a bit confused with the two timer modes that can be used. In the cyclic mode, I must set a timer to generate periodic interrupts at a given period (say 1ms) and call the COTmrService() inside the interrupt service routine, correct? In this case, the timer driver employed must be the co_timer_swcycle.c and the reload parameter of the DrvTimerReload() is the number of ticks to the next event.

In the delta mode, do I need to call COTmrService() inside the ISR? What is the meaning of the reload parameter in this case?

Thank you very much in advance.

@michael-hillmann
Copy link
Contributor

michael-hillmann commented May 13, 2022

Yes, you are right. In delta mode, you need to call COTmrService() in ISR, too.
The difference to the cyclic mode is, that your timer driver must reprogram the timer on every event to the exact time intervall for the upcoming needed timer event. In other words, we will get interrupts at every event time and no interrupts in between.

Maybe this description explains the reload parameter: Timer Driver / Timer Reload

@tpcorrea
Copy link
Author

Michael,

what would be the unit of the reload parameter in delta mode? Seconds or it assumes a certain clock frequency for the timer and the reload is in ticks as well?

KR,
Tomás

@michael-hillmann
Copy link
Contributor

michael-hillmann commented May 20, 2022

The unit of the reload parameter depends on your driver. I typically configure the timer with a frequency of 1MHz. Then you get an accuracy of 1tick = 1us. The reload parameter is in ticks which is equal to 1us - very comfortable. Just keep an eye on your timer overflow:
with a 32bit timer, you will get 4294s = ~1h - for my projects ok
with a 16bit timer, this is reduced to 65ms - this is not ok and will generate trouble!

@michael-hillmann michael-hillmann added the wait for feedback Feedback is needed label Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wait for feedback Feedback is needed
Projects
None yet
Development

No branches or pull requests

2 participants