Just a quick question here. Any one been dealing with the built in PWM modules in PICBasic?
I am trying to do a 3 channel dimmer that uses the 14 bit PWM.
The rundown of what I have so far is:
PWMCON0 = 0101(takes care of the odd pins for output) bits 3-0 I’m not sure on how to set. I am assuming that I want independent mode for just having a simple dimmer setup. That would be 01011111.
Next would be to setup “freerunning mode” – PTCON0 = 0000 (1:1 Postscale) 00 (1:1 Prescale) 00 (Free Running Mode) - all zeros.
Next is the PWMCON1 = 00000000. This register deals with interrupts and special events. Neither are needed.
I am not sure on the PWM Period stuff. Do I need to set PTPER? This I don’t really get. From what I can tell if I do need to set it, it would be PTPER = 0FFFH like in the datasheet.
After that it’s all down to the Duty Cycle – PDCx (L & H)
I won’t be using the dead time, override or fault registers. At least I don’t think so.
I am new to the whole onboard PWM stuff so any help is greatly appreciated.
Ian
Bookmarks