My goal is to capture the times between input pulses using DMA. I got this working on Teensy 3.6, based on input_capture_dma.ino. But moving to Teensy 4.1, I can't get capture to work.
I'm using pin 6 (FLEXPWM2_PWMA02) so I reimplementing everything with FlexPWM, but DMA capture didn't work at all. Working backward, I looked at the capture register directly, then edge counting, then just the PWM_A input directly, but none of those worked at all. I verified that the counter register is counting, though.
I've boiled it down to this code. Expected behavior: pin 6 will go to the PWM_A input and should show up in the value I'm printing. Observed behavior: continually prints 0. (Pin 6 is getting pulses externally, verified both by an oscilloscope and by digitalReadFast(6).)
I suspect I'm messing up the pin mux or misconfiguring FlexPWM. I've studied the FlexPWM chapter in the manual but I get nothing from the input even after trying a bunch of plausible settings.
I'm using pin 6 (FLEXPWM2_PWMA02) so I reimplementing everything with FlexPWM, but DMA capture didn't work at all. Working backward, I looked at the capture register directly, then edge counting, then just the PWM_A input directly, but none of those worked at all. I verified that the counter register is counting, though.
I've boiled it down to this code. Expected behavior: pin 6 will go to the PWM_A input and should show up in the value I'm printing. Observed behavior: continually prints 0. (Pin 6 is getting pulses externally, verified both by an oscilloscope and by digitalReadFast(6).)
Code:
void setup() {
pinMode(6, INPUT); // Initialize the direction
*(portConfigRegister(6)) = 2; // Mux 2 = FLEXPWM2_PWMA02, for IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_10
FLEXPWM2_OUTEN = 0; // No outputs
while (1) {
Serial.println(FLEXPWM2_SM2OCTRL, HEX); // top bit should be PWM_A Input
}
}
void loop() {
}