Hello Skimask,
The confusing part is it compiled without listing any errors! it is just one of those things sent to try us I guess.....
Anyway, I have learned some more and that is what it is all about. Thanks again for your input.
Andy
Hello Skimask,
The confusing part is it compiled without listing any errors! it is just one of those things sent to try us I guess.....
Anyway, I have learned some more and that is what it is all about. Thanks again for your input.
Andy
I just looked at the pbppic18.lib file in the PBP directory and found this:
;************************************************* ***************
;* Default Hpwm values *
;************************************************* ***************
ifndef CCP1_REG ; CCP1 pin port
CCP1_REG EQU PORTC
endif
ifndef CCP1_BIT ; CCP1 pin bit
CCP1_BIT EQU 2
endif
ifdef CCP2CON
ifndef CCP2_REG ; CCP2 pin port
CCP2_REG EQU PORTC
endif
ifndef CCP2_BIT ; CCP2 pin bit
CCP2_BIT EQU 1
endif
endif
I don't know if the compiler will accept it, but I'm wondering if adding:
ifndef CCP3_REG ; CCP3 pin port
CCP3_REG EQU PORTG
endif
ifndef CCP1_BIT ; CCP3 pin bit
CCP3_BIT EQU 0
endif.......................................
and so on for channel 4 and 5 to that file...would enable the PWM modules for those channels.
This is above me without a usable 6520 (or anything else in that family) to play with at the moment.
DT, Mr_E? Any thoughts?
Also, you might want to check the chip's revision. The early 6520/6620/6720/8520/8620/8720 chips didn't like to run above 4mhz under certain conditions relating to code (I had a few of those, run all day at 4mhz, didn't like to run at 6mhz). Might want to check the errata sheets and see if you've got one. Of course, if you've bought it recently, or the date code is less than a year or two old, I wouldn't worry about it.
You would also need to change the HPWM routine itself (also in the PBPPIC18.LIB file).
Just took a quick look, doesn't look like it would be too hard.
<br>
DT
Sure does look easy enough. Only 9 lines of assembler and add a few more assembler directives to enable the other 3 channels on those PICs.
And again, if I had a spare 65/66/67/85/86/87..20 laying around, I'd be all over that.
Another mod to send into MeLabs for the next update.
(Are the guys at MeLabs listening in on these last couple of great mods that DT/Mr_E have come up with in the last few weeks or so?)
And if using Charles' method.
Be sure to download mister_e's PicMultiCalc.
http://www.mister-e.org/pages/utilitiespag.html
<br>
DT
I have found that the HPWM function in PBP is fairly limiting - 32.767Khz is the maximum frequency.
It is quite easy to set up the PWM registers directly. I use the following.
With a 40Mhz oscillator. This gives 158Khz PWM frequency with 8 bits of
resolution. You can get up to 10 bits of resolution at lower PWM frequencies.
Although this is for channel 1, I have set up the other channels similarly.
CCPR1L = %00010000
CCPR1H = %00000000 ' Initialize to 0, PWM register
T2CON = %00000100 ' Timer 2, Prescale 1
CCP1CON= %00001100 ' Set up for PWM
PR2 = $3F ' 8 bits of resolution at 158Khz
CCPR1L = PWMVal >> 2 'Upper 6 bits (of the 8) go here
CCP1CON.5=PWMVal.1 'Lower 2 here
CCP1CON.4=PWMVal.0
Charles Linquist
Bookmarks