Picomite Phase Correct PWM


Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2542
Posted: 12:29pm 25 Aug 2022      

hi Volhout,
   that is a really neat hack, opening up a set of new and interesting applications for mmbasic  

it also demonstrates nicely the usefulness of being able to directly 'tinker under the hood', experimenting with new ways to use the hardware and perhaps even suggest a path for future tweaks to mmbasic that can then expose the functionality directly via existing basic commands.

Peter, Geoff: is this mode ("Phase Correct Mode") of operating the PWM something that could perhaps be added as an extension to the existing PWM command in mmbasic for the pico, and possibly also the MX170? for instance, using a negative frequency to specify the alternate mode?


  Solar Mike said  What pwm duty cycle resolution do you have at 200Khz under basic


Geoff did build a 'tweaked' version of mmbasic for the MX170 that exposed direct access to setting the PWM count value here:
http://www.thebackshed.com/forum/ViewTopic.php?TID=14558&P=2#182207
in that example a negative duty cycle parameter indicated a count value was being supplied rather than a duty cycle. later in the above linked thread the formula for the maximum (negative) value is given. in the case of the pico there would be a similar relatively simple formula for the number of 'ticks' within each cycle - in my case i just used trial-and-error to find the approximate limit, then worked backwards from there  


cheers,
rob   :-)