PDA

View Full Version : problem with variable on PIC10f202



Samoele
- 26th October 2009, 17:12
Hi,

I have a simple program and make me problem. After receiving data blinking LED only one cycle and after this cycle LED is off
I would that LED is after receiving data blinking constant. Why is not stored number in variable and loop the program?

tnx

here is my program:


@ device pic10F202,wdt_off,mclr_off,protect_off
define osc 4
INCLUDE "modedefs.bas"



led var GPIO.0
out var gpio.1
serial var gpio.3
ena var gpio.2
b0 var byte
b1 var byte

main:
serin serial,T2400,[1],b0

for b1=0 to b0
high led
pause 200
low led
pause 200
next b1
pause 2000
goto main


end

flipper_md
- 26th October 2009, 17:29
Your code will go back to Main after first blink, and then wait again for a command as it see Serin, which wait forever until you send him data.

look into adding a background timer if you want the led to blink, or use a timeout so the Serin will end if no new char is received.

also, some indent in code help to see more clearly :)


main:
serin serial,T2400,[1],b0

for b1=0 to b0
high led
pause 200
low led
pause 200
next b1

pause 2000
goto main