I have the need to pulsate an LED rather than just turn it on or off. I've modified the code I used for my model train detection project that used a 16F628A and have a working example on my bread board. Although its not rocket science I used the PWM command and a for next loop to increase the on time of the LED and thus its brighness. However given that this is just my second project with PBP I'm well chuffed that it worked with very few attempts.
However, I really want to use a 12F675 so I copied and pasted the code, substituting PORTB.4 for GPIO.0 and compiled the code once the chip was selected in Microcode IDE. However it fails to work with the 12F675. Ive included the setting to make ports digital (I think) but it still fails, and I would really like some guidance here.
This is the code for the 12F675
Code:
GPIO.0 = 0
CMCON = 7 ' PortA Digital inputs
VRCON = 0 ' Voltage reference disabled
OPTION_REG.7 = 0
@RC_OSC_NOCLKOUT
@WDT_ON
@PWRT_ON
@MCLR_OFF
@BOD_ON
@LVP_OFF
@CPD_OFF
@PROTECT_OFF
led var GPIO.0
i var byte
Main:
For i = 0 to 255
Pwm GPIO.0,i,1
next i
if i = 255 then goto down
down:
for i = 255 to 1 step -1
pwm GPIO.0,i,1
next i
If i = 0 then goto main
Is the software command PWM supported on all chips ? I thought it simply pulses the pin for a duration and cycle.
Hope to hear from you guys soon
Cheers
Malcolm
Bookmarks