Using the Hardware Timers - Teensy 4.0

Status
Not open for further replies.

Kuba0040

Well-known member
Hello,
I am working on a project that requires some precise timing. Not only repeated interrupts on equal intervals but also precise time delays. So I want to use the 32 bit hardware timers of the Teensy 4.0. I am aware of the IntervalTimer object. But that isn't enough. So here is my question: (More like questions) How do I setup and use the timers directly, like you would modify the registers on AVR (or via a library that allows you to set the same things). How do I set the priority for the timer interrupts to better manage my CPU time? What priority and what timer does the Audio library use?
Thanks for the help :)
 
If you want to go low-level, you can check the manual here: https://www.pjrc.com/teensy/IMXRT1060RM_rev2.pdf

Also study the existing libraries and the core source code: https://github.com/PaulStoffregen/cores/tree/master/teensy4

The core files define a lot of constants and helper functions for working with the processor. So if the manual tells you to manipulate a particular register, a search for the register's name in the GitHub repo may be enlightening.

Note that if you're interested in a topic that's part of the generic ARM instruction set rather than the particular chip, this won't be covered in the IMXRT manual, but rather in ARM's online docs for the ARMv7 architecture.
 
I am working on a project that requires some precise timing. Not only repeated interrupts on equal intervals but also precise time delays.

It sounds like you want a combination of input capture and output compare, and possibly to link those together. I searched for those topics in the forum, and I found this nice post by Paul that may answer your question. Regarding the input side, in addition to TimerTool, you could also look at library FreqMeasureMulti. This library configures measures the precise period of input signals and generates interrupts on each period. By default, the ISR simply writes the measured period values to a queue that you can then read at task level, but you could write your own ISRs to do what Paul is suggesting here.

https://forum.pjrc.com/threads/6664...y-Timer-advice?p=274069&viewfull=1#post274069

If you get it to work, it would be a great thing to share with the community.
 
Status
Not open for further replies.
Back
Top