The 18F2X/4X/5XK42 devices have four 10-bit hardware PWMs. They are PWM5, PWM6, PWM7, and PWM8. GCB only supports PWM1-7. Would it be much work to add PWM8? I'm working on a project where it would be useful.
-Jim
~ sent from my pedal-powered computer (pedalpc.com) ~
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have updated the Help to cover PMW8, we do not need a demo as this is the same as the other PWM channels.
Some example code using PMW8 on PPS/RA0. Use PPS to change the output port. Works as expected on the scope.
'Chip Settings #chip 18F25K42, 64'Generated by PIC PPS Tool for Great Cow Basic'PPS Tool version: 0.0.5.24'PinManager data: v1.75'Generated for 18f25k42''Template comment at the start of the config file' #startup InitPPS, 85 #define PPSToolPart 18f25k42 Sub InitPPS'Module: PWM8RA0PPS=0x0010'PWM8 > RA0 End Sub'Template comment at the end of the config file DIR porta Out HPWM 8, 50, dutyvalue, 2 wait 10 ms do'use for-loop to show the duty changing a 10bit value dim dutyvalue as word for dutyvalue = 0 to 1023 HPWMUpdate 8, dutyvalue wait 10 ms next loop
Last edit: Anobium 2018-11-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The 18F2X/4X/5XK42 devices have four 10-bit hardware PWMs. They are PWM5, PWM6, PWM7, and PWM8. GCB only supports PWM1-7. Would it be much work to add PWM8? I'm working on a project where it would be useful.
-Jim
~ sent from my pedal-powered computer (pedalpc.com) ~
A day or two. I had not spotten that those devices had PWM8.
Check back on Monday.
No hurry. Thanks!
I just found a few moments to load and test. All ok.
Download from here. https://sourceforge.net/p/gcbasic/code/HEAD/tree/GCBASIC/trunk/include/lowlevel/pwm.h?format=raw
I have updated the Help to cover PMW8, we do not need a demo as this is the same as the other PWM channels.
Some example code using PMW8 on PPS/RA0. Use PPS to change the output port. Works as expected on the scope.
Last edit: Anobium 2018-11-24
Wow, you're incredibly fast! I was just going to write back and say it wasn't necessary--I figured out how to implement it using the CCP PWMs :-/