Hi,
This question is about pin assignment and pwm output.
In pwm.c, in analogWrite(), we have the following at line 266
The mux value is stored in pwm_pin_info[] at the top of the file, with the structure for the array elements declared at line 6, and the array populated at line 19, with pin number as index into the array.
So in other words, there seems to be a hard coded relationship between pin number and pwm output.
Now the questions:
1) Is this association between a given pin and a given pwm output, fixed in hardware? How? Or, can the mux value be assigned to a different pin mux to re-route the pwm output?
2) Can the PWM be used without assinging the mux to a pin? An example use case would be to only use the interrupt but not the pin.
3) After starting the pwm for a pin, does calling pinMode() for that pin (digital.c, line 133), leave the pwm running?
Thank you
P/S It occured to me that I should be more specific about what I am trying to do.
What I am looking for is access to all four submodules of any flexPWM for a Teensy 4.0.
At the moment, the board uses pins 4 or 5, 6, 7, and 9 or 10. Being able to mux onto those pins would be fantastic. Otherwise, I will just have to spin the board again.
To that, so far, I was able to program what I need using pins 4,5 and 6 for flexpwm2 submodules 0,1 and 2, and assert the 4th pin as needed from an ISR. I would very much prefer to be able to get to submodule 3 (on one of the pins, not a solder pad on the bottom).
I am still interested in the above question though.
This question is about pin assignment and pwm output.
In pwm.c, in analogWrite(), we have the following at line 266
Code:
*(portConfigRegister(pin)) = info->muxval;
The mux value is stored in pwm_pin_info[] at the top of the file, with the structure for the array elements declared at line 6, and the array populated at line 19, with pin number as index into the array.
Code:
struct pwm_pin_info_struct {
uint8_t type; // 0=no pwm, 1=flexpwm, 2=quad
uint8_t module; // 0-3, 0-3
uint8_t channel; // 0=X, 1=A, 2=B
uint8_t muxval; //
};
So in other words, there seems to be a hard coded relationship between pin number and pwm output.
Now the questions:
1) Is this association between a given pin and a given pwm output, fixed in hardware? How? Or, can the mux value be assigned to a different pin mux to re-route the pwm output?
2) Can the PWM be used without assinging the mux to a pin? An example use case would be to only use the interrupt but not the pin.
3) After starting the pwm for a pin, does calling pinMode() for that pin (digital.c, line 133), leave the pwm running?
Thank you
P/S It occured to me that I should be more specific about what I am trying to do.
What I am looking for is access to all four submodules of any flexPWM for a Teensy 4.0.
At the moment, the board uses pins 4 or 5, 6, 7, and 9 or 10. Being able to mux onto those pins would be fantastic. Otherwise, I will just have to spin the board again.
To that, so far, I was able to program what I need using pins 4,5 and 6 for flexpwm2 submodules 0,1 and 2, and assert the 4th pin as needed from an ISR. I would very much prefer to be able to get to submodule 3 (on one of the pins, not a solder pad on the bottom).
I am still interested in the above question though.
Last edited: