Hi All
I was following a tutorial online regarding RS-232 communication using the MAX232 chip. (Tutorial is called "PIC16F628 alive" - see http://www.oz1bxm.dk/PIC/628uart.htm) Everything is working and I understand most of the code that was used in the tutorial. So when I throw power onto the board, I get a message saying "16F628 alive", and when I type characters, they echo back to the PC. Everything is good.
Now I want to build logic based on different signals received from the connection. For example, if I send character "A" through COM, I want the LED connected to PORTA.0 to light up. If I send character "B", LED on PORTA.1 should light up.
I understand how to build the circuit, yet I have absolutely no clue how to determine which character is sent to the PIC. From the URL above, I know I have to replace the "send" call in the main loop with my own routine. What I have tried so far:
As the process "method" will only fire when receive actually gets something, the LED's should be lit until the next character is received.
For some reason, none of the above works though. I can't get either one of the LED's to light up no matter what I do. Now, my understanding of my code is this:
Subract 65 from the W register (65 = A ascii value)
If bit 0 of the W register is set, light the RED led
If bit 0 of the W register is not set, light the GREEN led
Is my understanding correct? Is there something wrong in the code? I doubt that either of the chips are damaged (when I program the sample code back I get the result as in the tutorial) so I assume it must be my code that's "dodgy"...
I was following a tutorial online regarding RS-232 communication using the MAX232 chip. (Tutorial is called "PIC16F628 alive" - see http://www.oz1bxm.dk/PIC/628uart.htm) Everything is working and I understand most of the code that was used in the tutorial. So when I throw power onto the board, I get a message saying "16F628 alive", and when I type characters, they echo back to the PC. Everything is good.
Now I want to build logic based on different signals received from the connection. For example, if I send character "A" through COM, I want the LED connected to PORTA.0 to light up. If I send character "B", LED on PORTA.1 should light up.
I understand how to build the circuit, yet I have absolutely no clue how to determine which character is sent to the PIC. From the URL above, I know I have to replace the "send" call in the main loop with my own routine. What I have tried so far:
Rich (BB code):
; MAIN LOOP
call message
loop
call receive
call process
goto loop
process
subwf 65,W
btfsc W,0
call LightRed
btfss W,0
call LightGreen
return
LightRed
bsf PORTA,0
bcf PORTA,1
return;
LightGreen
bsf PORTA,1
bcf PORTA,0
return;
For some reason, none of the above works though. I can't get either one of the LED's to light up no matter what I do. Now, my understanding of my code is this:
Subract 65 from the W register (65 = A ascii value)
If bit 0 of the W register is set, light the RED led
If bit 0 of the W register is not set, light the GREEN led
Is my understanding correct? Is there something wrong in the code? I doubt that either of the chips are damaged (when I program the sample code back I get the result as in the tutorial) so I assume it must be my code that's "dodgy"...