2021-01-15 12:44 AM
#include "mbed.h"
#include "FastPWM.h"
FastPWM fastpwm(PA_8,1);
int main() {
fastpwm.period(5.25e-8 );
fastpwm.write(0.5);
}
This is my simple code to generate PWM in MHZ using FastPWM. When i check on CRO its showing frequency about 16 to 19 MHZ but not abel to see square waves. what am i missing here? Can someone please help?
2021-01-15 01:59 AM
I don't think you will find much help for mbed here. Try dedicated mbed support (forum, if such exists).
For precisely timed PWM, use hardware timers.
If the GPIO output is not fast enough, try different setting for the given pin in GPIO_OSPEEDR. I don't know how is this set in mbed.
JW
2021-01-15 02:44 AM
PA8 is also MCO1. Check if you can use that way. Check also, that alternat functions are set the right way.
2021-01-17 09:20 PM
Thank you for reply @Community member and @Uwe Bonnes , Yes @Community member you are right, i have posted same question on same day on mbed forum also and no one replied to it. Anyway let me go with your suggestions. Will revert back with the output. Thank you.
2021-01-19 04:22 AM
Just for Information. I am able to get proper 16 MHZ output on PWM pins like D6,D9,D10,PA8 etc... with the same code posted in question. It was probe issue and input impedance issue. I have set input impedance to 1 Mega-ohm. Thank you.