HPWM/HPWM2/HPWM3 hardware PWM modules

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

Post by Jerry Messina » Fri Nov 17, 2023 12:37 pm

I just thought i would report it in case anyone else has this problem.
And thanks for that! I hadn't noticed the two register writes so I've modified the files to account for it.

The registers are double-buffered, but I think one of the issues is that it can take several cycles to perform the duty cycle programming,
and if you get a timer rollover (TMRIF) during that you could end up with partial data. This is alluded to in the "Setup for PWM Operation" section of the CCP...
In order to send a complete duty cycle and period on the first PWM
output, the above steps must be included in the setup sequence. If it is not critical to
start with a complete PWM signal on the first output, then step 6 may be ignored.
Step 6 shows syncing the update to right after a TMRIF occurs. In any case, you now have an #option to select whether you want that to occur or not.
New files will be included in the next update (due Real Soon Now).

Right now I'm working on a similar version for devices with the 16-bit PWM module. They have their own dedicated timers (and a lot more features). Each module has two outputs so you can end up with 4-8 PWM outputs and still have all the timers and CCP modules available too.

richardb
Posts: 310
Joined: Tue Oct 03, 2006 8:54 pm

Re: HPWM/HPWM2/HPWM3 hardware PWM modules

Post by richardb » Fri Nov 17, 2023 12:57 pm

Nice, Thanks Again Jerry.
Hmmm..

Post Reply