That's a start, but as you correctly say PBP will only look at the Lower 8-bits... so your example will lose the upper two, which are far more important.
First, let's grab the UPPER eight bits (variable TempA is a BYTE)...
TempA=Y >> 2
Now let's set the 8-bit PWM with the eight most significant bits...
HPWM 1,Temp,1000
For the two least significant bits, if you looked in the 'Capture/Compare/PWM' section of your PIC's Datasheet you would have found that bits 5 and 4 of the CCP1CON Register handle those... so, simply just load them...
CCP1CON.5=Y.1
CCP1CON.4=Y.0
That's all there is to it... simple? Sure it is... like I keep telling everyone - Read the Datasheet. Actually, it's so simple to fire up the PWM module, you can dispense with PBP's HPWM and manipulate the registers yourself (detailed instructions in Datasheet)... ends up using heaps less program code.
Lastly, don't forget to set TRIS appropriately for output on the HPWM channel you are using. For a 16F628 this will be TRISB.3=0, For a 16F877 this would be TRISC.2=0.
Melanie
Bookmarks