I guess I'm trying to figure out, if I know the frequency I want to pulse, and the duty cycle, what do I need to call in order to make that happen using analogWrite()? I want to use PWM to pulse a Stepper Motor driver.
where the maximum frequency is 150 MHz (as listed for IPG_CLK_ROOT in the docs [Table 13-5])
@PaulStoffregen, is there any reason that the formula for div_ipg in clockspeed.c doesn't try to maximize F_BUS_ACTUAL? For instance, for the following frequencies of F_CPU_ACTUAL you get these values for F_BUS_ACTUAL:
But if div_ipg were set to 2 and 1 when CPU is 300 and 100 MHz respectively, then BUS would be 150 and 100 MHz instead. Is there a reason not to do this?
Also, since the BUS (IPG) clock is derived from the CPU (AHB) clock, and the clockspeed is dynamic, how do you ensure that you get a stable PWM frequency? I probably misunderstood something here!
To add to this discussion. Is the bit resolution 16 bit for all frequencies on the Teensy 4? I have looked through the chip specs and cannot tell definitively, but it looks like it always has 16 bit counter.