gti_uk
- 31st May 2009, 00:16
Hello,
Ive got a really simple problem but i cannot see why i can not sort it.
Im using a K8048 board with the standard 18pin 16F627A pic. Ive managed to hook it up and ive compiled the blink app in mplab and put it on the pic fine.
The problem is ive tried to drop a if statement in as i thought it was a simple enough thing to do next. Only problem is it does not work :confused:
This is the code ive done
OPTION_REG = %11010111 'Set PIC options (See datasheet).
TRISA = %11111111 'all RA ports are inputs
TRISB = %11000000 'RB7 & RB6 are inputs.RB5...RB0 are outputs.
led1 var portB.0
led2 var portB.1
sw1 var portA.0
loop:
if sw1 = 1 then Goto loop
high led1 ' Turn on LED connected to PORTB.0
low led2
Pause 500 ' Delay for .5 seconds
low led1 ' Turn off LED connected to PORTB.0
high led2
Pause 500 ' Delay for .5 seconds
Goto loop ' Go back to loop and blink LED forever
End
This is part of the schematic for the k8084
http://i120.photobucket.com/albums/o170/gti_uk/schem1.jpg
Ive looked at the code and ive got the A bank set as an input, and the push button goes to RA0.
Any ideas where ive gone wrong, and sorry for such a dumb problem
Ive got a really simple problem but i cannot see why i can not sort it.
Im using a K8048 board with the standard 18pin 16F627A pic. Ive managed to hook it up and ive compiled the blink app in mplab and put it on the pic fine.
The problem is ive tried to drop a if statement in as i thought it was a simple enough thing to do next. Only problem is it does not work :confused:
This is the code ive done
OPTION_REG = %11010111 'Set PIC options (See datasheet).
TRISA = %11111111 'all RA ports are inputs
TRISB = %11000000 'RB7 & RB6 are inputs.RB5...RB0 are outputs.
led1 var portB.0
led2 var portB.1
sw1 var portA.0
loop:
if sw1 = 1 then Goto loop
high led1 ' Turn on LED connected to PORTB.0
low led2
Pause 500 ' Delay for .5 seconds
low led1 ' Turn off LED connected to PORTB.0
high led2
Pause 500 ' Delay for .5 seconds
Goto loop ' Go back to loop and blink LED forever
End
This is part of the schematic for the k8084
http://i120.photobucket.com/albums/o170/gti_uk/schem1.jpg
Ive looked at the code and ive got the A bank set as an input, and the push button goes to RA0.
Any ideas where ive gone wrong, and sorry for such a dumb problem