I'm working with a KE06Z and have a need to trigger a function every 2 seconds. After looking at the various timer modules on the KE06 mcus I started thinking about the purpose for all the the different types and what situation you would prefer to use one type over another.
Here is a list of the timers that are listed in the reference guide:
Flex Timer
Periodic Interrupt Timer
Real Time Counter
Pulse Width Timer
Pulse width seems the most obvious but comparing the other 3 seems more difficult being that it seems like you can use any of the first 3 in similar situations.
Hopefully someone can fill me in.
Thank you.
Steven
- SYSTICK is also available for a periodic interrupt (without HW interaction)
- PITs allow periodic interrupts with high resolution (core frequency) and long periods (32 bit timers) but have no HW interaction
- RTC is useful for long period counting/calendar but it has low resolution (eg. 1s or 32kHz)
- FlexTimers allow periodic interrupts but not long periods since they are 16 bit timers. They are attached to HW (can use external clocks or generate output signals that can change at the same time as the timer interrupts fire). They are very useful for generating multiple interrupts which are synchronised to points in the timer cycle (eg. you can have multiple period interrupts, each with a different phase. See chapter 3 of http://www.utasker.com/docs/uTasker/uTasker_DMX.pdf for an example of generating interrupts at different points in a frame cycle.
In Kinetis devices with DMA support (KE parts don't support DMA) most of these interrupts can also be used to generate DMA triggers.
In some instances any one of the timers can be used to do the same job so if one needs lot of such timers some can be done with PITs and some with FlexTimers.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KE:
- http://www.utasker.com/kinetis/FRDM-KE02Z.html
- http://www.utasker.com/kinetis/FRDM-KE02Z40M.html
- http://www.utasker.com/kinetis/FRDM-KE04Z.html
- http://www.utasker.com/kinetis/FRDM-KE06Z.html
- http://www.utasker.com/kinetis/FRDM-KE15Z.html
RTC and time keeping: http://www.utasker.com/docs/uTasker/uTasker_Time.pdf
HW Timers: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF