Hmmm, If the FTM timer is ticking at 4 MHz, then to generate a data pulse will require a tick to generate a HIGH bit and then a tick for a LOW bit, so the data rate for galvanometer data will be 2 Mhz. Or 10 us for...
Re: a better fix?
A better solution is to remove the if(txPing & 2) logic from the isr in the library, so the dma.sourceBuffer() is executed on every DMA ISR.
// if(txPing & 2) {
// txPing &= ~2;
if(txPing...
here is sketch that demonstrates using TPM2/DMA to set the lower 8 PORTD bits on Teensy LC (tested with scope on PORTD pins)
// PORTD pins 2 14 7 8 6 20 21 5 TPM2
#include <DMAChannel.h>
#define PRREG(x)...
for what it's worth, here is small T3.2 comparator sketch. I used a scope on pin 22 and pin 10 to measure latency
// comparator latency test COMP1 T3.2
// test with 1khz PWM from pin 22
// pin 23 comparator input...
The GPT timers can have an external clock source. In the Teensy 4 ref manual search for "GPT1_CLK" to see which pins are used for each GPTx timer. Also see GPT2 external clock example at...
this DHT lib https://www.arduino.cc/reference/en/libraries/dhtlib/ says it is designed for AVR processors -- Teensy 3.2 is ARM not AVR. lib is using AVR registers for IO
// replace digitalRead() with Direct Port...
if you "got it working using just SPI", did you find the performance lacking? When I do a 1024-byte SPI.transfer() with SPI clock at 40MHz, I measure a data rate at 37.4 megabits/sec. I believe the Teensy4 SPI...
How about trying
analogWriteFrequency(16, 8000000); // 16 and 17 max 8mhz uses TPM T3.6 only
analogWrite(16, 128);
after starting the analogWrite() you could print out the various TPM1 registers to see how...
Works for me too.
Here is complete example using FreqCount to measure frequency on pin 14. (For Teensy 4, gateinterval is in microseconds ! Who knew. web page documentation needs updating.) Jumper pin 9 to pin...
see discussion on "slow PWM" for Teensy 4 using XBAR
https://forum.pjrc.com/threads/25164-2Hz-analogWriteFrequency-on-Teensy-3-1?p=247337&viewfull=1#post247337