The PWM frequency is 62.5kHz and duty cycle should be 50%. I am using the following code, but cannot get the starting at 300us pin high followed by 3 pulses at 62.5kHz followed by the pin being high forever.
Currently, I get 3 pulses at 62.5kHz at the beginning (rather than a 300us or in the case I have implemented in code, a 100ms high output followed by the pulse) and after delay the pulse continues forever
What comes out of that code?
Not being 200% expert this sounds strange. From what is that 300 uS counted? Why involve PWM? It makes no sense just sending a few pulses.
Please give us the big picture showing why this? No helper like spending time finding a solution to Your question just to hear the next day: "It doesn't work".
You're not really trying to generate a pwm signal so much as you are trying to generate 3 pulses. A pwm signal is continuous. It doesn't stop after only 3 pules. Why not simply do this:
I'm not a big fan of blocking code either, since it usually causes problems with most systems, especially anything with wifi. But 300us is so fast, that blocking isn't blocking for long.
so no dc bias for 300us and and infinite sequence of 62.5khz pulse after 3 pulses. The 3 pulse is an example, I will need a maximum pulse count of 40 pulses for my application used to adjust voltage on a inverting boost.
If you are trying to generate a set of 3 pulses at different times, it would be easier to put that into it's own function and call it from whereever you are triggering it from.