Page 1 of 1

high-frequency PWM

Posted: Sat Jan 30, 2021 11:21 pm
by rgcoldeman
There seems to be a minor bug in ports/rp2/machine_pwm.c which gets the frequency wrong. The offending line is "uint32_t div16_top = 16 * source_hz / freq;", where a "-1" should be added.
It does not matter much at low frequencies, where the value of 'TOP' is high so 1 more or less doesn't matter much. But in the MHz range the value of TOP is small and 1 more or less changes everything. To get 62.5 MHz, I need to ask for 125MHz. To get 41.67MHz, ask for 62.5MHz, to get 31.25MHz, ask for 41.67MHz, to get 25MHz, ask for 31.25MHz.