PDA

View Full Version : Newbee Hardware PWM clarification needed



emmett brown
- 8th July 2006, 22:15
I found this code in the forums . And will be a good beginning for my project. What do I need to be able to compile it in PICBASIC without so many errors? A 16f877 at 4 Mhz

Begin:

PVAL = 1000 ' Start with 1kHz
For Duty = 64 to 250
HPWM 1,Duty,PVAL
PAUSE 100
NEXT Duty

Duty = 127 ' 50% Duty-cycle
For PVAL = 1000 to 10000 step 100 ' Increments of 100. Change as needed
HPWM 1,Duty,PVAL
PAUSE 100
Next PVAL

GOTO Begin

END

mister_e
- 8th July 2006, 22:55
regular PBC or PBP (pro)?

If you didn't define the variables or you're using PBC, i don't see the error source

PBC don't have the HPWM statement, you'll need to POKE the PIC registers as per the PIC datasheet.

emmett brown
- 9th July 2006, 01:47
So it would work with PBP? I have the demo and it comes up with a bunch of syntax and bad expression errors Thanks Emmett

mister_e
- 9th July 2006, 09:18
Ok i try again..

If you didn't define the variables ... i don't see the error source

X Var BYte
tada var word

etc
etc