using timers for signal generation?

albireo13

Member
I am looking for a tutorial for using the timers in Teensy. I currently have a teensy 2.0 but, will likely buy a 4.0 soon.

I want to use the Teensy to generate various clock signals, for testing some pcbs. Rather than buy a dedicated signal generator, I should be able to do this.
Nothing too crazy ... logic level signals, 50kHz to 5MHz in range. Programmable duty cycle.
A 4.0 will likely be better due to higher native clock speed.
Rather than use software timing, I figure using dedicated timers would be better. This is my first exposure to using the embedded timers.

I am a beginner user and looking for some good reading/tips on this.
Thx.
 
You might look at @luni library:

For most of these things, I end up looking at the Reference Manual for the processor. There are links to this on the product pages.

Potentially PWM might for your needs. where you can set the frequency using analogWriteFrequency... And set the duty using analogWrite.
Different pins can have different frequency, although some pins are linked to the same timer, so all of those will have same frequency.
 
I want to use the Teensy to generate various clock signals, for testing some pcbs. Rather than buy a dedicated signal generator, I should be able to do this. Nothing too crazy ... logic level signals, 50kHz to 5MHz in range. Programmable duty cycle. Rather than use software timing, I figure using dedicated timers would be better. This is my first exposure to using the embedded timers. I am a beginner user and looking for some good reading/tips on this..
As KurtE said, it sounds like all you need are the high-level PWM function calls, which you can read about on the pjrc tutorial pages (https://www.pjrc.com/teensy/td_pulse.html). It's definitely better to generate the PWM entirely in hardware rather than software (timer interrupts and digital outputs).
 
Back
Top