Pulse output on Teensy 3.6

Status
Not open for further replies.
I need to generate a continous digital output of 25.0 MHz, dutycycle 50 %, on a pin on the Teensy 3.6 kit. I have been through all the libraries, but none seem to hold the answer. Is it possible to do this? Can anybody offer a bit of help? Thanks for any input!
 
No, not 25 MHz.

You can get integer division of F_BUS, which defaults to 60 MHz but can be 48 MHz or other lower frequencies (listed in kinetis.h).

So you could get 30 or 24 or 20 MHz, but not 25 MHz.
 
A big note: I did this on Teensy 3.5 set with the CPU speed at 144 MHz overclock.
Well at least you can try 24 MHz quickly.
Code:
// TEENSY 3.5  CPU @ 144MHz

void setup() {
  pinMode(5, OUTPUT); // pin 5
  analogWriteResolution(2);  // Resolution (# of bits 2) analogWrite PWM Value 0 to 3
  analogWriteFrequency(5, 24000000); // Teensy changes to 24000000 kHz
  analogWrite(5, 2); // PWM Value 2 = 50% duty cycle
}

void loop() {
}
 
Thanks Chris!
Funny thing is that your code gives me an output of 20 MHz. If I change the frequency parameter to 25 M, the output changes to 30 MHz. Problem: I am using two SPI channels running independently in parallel at SCK = 20 MHz. These are corrupted by the clock. It seems as if the clock is generated by code, not by a free running timer.

The big problem with Teensy is the level of documentation. The commands you are using are described in a mix of Arduino and Teensy. Confusing, to say the least.

Thanks for help so far!
 
Problem: I am using two SPI channels running independently in parallel at SCK = 20 MHz. These are corrupted by the clock.
Try using PWM pin 3 or 4.
(Timer FTM1 PWM PINS 3, 4)
(Timer FTM0 PWM PINS 5, 6, 9, 10, 20, 21, 22, 23)
 
Problem: I am using two SPI channels running independently in parallel at SCK = 20 MHz. These are corrupted by the clock. It seems as if the clock is generated by code, not by a free running timer.

We could try to help you with this specific problem, if you can elaborate and maybe post a sample program which demonstrates the problem.

But perhaps this is merely a misunderstanding about how SPI works? The SCK clock signal is not continuous. You only get short bursts of clock pulses during data transfers. That's how SPI works on virtually all microcontrollers.
 
Status
Not open for further replies.
Back
Top