Menu

change pwm frequency in gcbasic

Help
2009-01-28
2013-05-30
  • Nobody/Anonymous

    if i increase the chip mhz the pwm freq goes up right?, can i edit the pwm file in gcbasic to speed it up also? and if so what line would I do that on?

     
    • kent_twt4

      kent_twt4 - 2009-01-28

      The higher the internal or external osc that is applied, the faster the soft pwmout routine will run.  Its is well explained by Hugh here in help http://gcbasic.sourceforge.net/help/

      If you wanted to mess with the software pwmout, then reduce the 8bit resolution in the subroutine to whatever resolution you want.  For instance, if 6 bit resolution was acceptable (64 steps) then just reduce the internal loop count from 1 to 64 instead of 1 to 255.  That would increase your speed substantially (almost 4 times).

      Hard to keep track of the train of thought here.  Is this a continuation of 12f683 software pwmout questions?  If so then consider using the hardware Pwm module, and use the GCBasic HPWM command.  This will run the PWM in the background, offer faster frequencies, all while you do other stuff in your code.

       
    • Nobody/Anonymous

      is the internal loop count in the pwmout.h ?

       
    • kent_twt4

      kent_twt4 - 2009-01-29

      No, that is the HPWM library.  For the softpwm library look in stdbasic.h file.  The line to change is:

      For DOPWM = 1 to 255
      ...
      ...
      Next

      Good luck.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.