The transmitter works like a charm, made with a 18F452 GLCD and swordfish offcourse!
It has a TX RF module attached to Usart.
My problem is getting the reciever to work properly.
I use a PIC16F628A to recieve the usart data send with the 18F.
It works just fine when i use 1 output but when i add a output it does not work very well.
This happens: When i send the command to activate LED1, LED1 is ON nice .
Ok so now LED1 is on, when i send the command to activate LED2, LED1 goes OFF :S.... Not so nice .
And LED2 goes ON.
I dont understand why so i hope someone can help me with this.
My code
Code: Select all
start
clrf aanuit
bcf RCSTA,CRen
bsf rcsta,cren
Call ontvangen
xorlw 0x9A ; Is the data for me?
btfss status,z
goto start
call ontvangen
xorlw 0x9A ; is it really for me?
btfss status,z
goto start
call ontvangen
movwf aanuit ; What to do?
call ontvangen
xorlw 0x9A ; Was it really for me? If not
btfsc status,z ; Return to start.
goto welke_lamp ; If yes goto (welke Lamp)
goto start ;And see what needs to be done.
;*************************************************************************
;Which lamp?
;On or Off?
;*************************************************************************
welke_lamp
movfw aanuit
xorlw 0xCE ; Did i recieve $CE?
btfss status,z
goto lamp1_uit ;No: goto Lamp1_uit (uit means OFF)
bsf porta,2 ;Yes: Lamp 1 ON
Call wait25ms
goto start
;Is het voor HL1?
Lamp1_uit
movfw aanuit
xorlw 0XEC ; Did i recieve $EC?
btfss status,z
goto Lamp_hl2 ;No: goto Lamp1_hl2
bcf porta,2 ;YES: Lamp 1 OFF
Call wait25ms
goto start
;Is het voor HL2
Lamp_HL2
movfw aanuit
xorlw 0xAE ; Did i recieve $AE?
btfss status,z
goto lamp2_uit ;No: goto Lamp2_uit
bsf porta,1 ;YES: Lamp 2 ON
Call wait25ms
goto start
;Is het voor HL1?
lamp2_uit
movfw aanuit
xorlw 0XEA ; Did i recieve $EA?
btfss status,z
goto start ;No: goto start
bcf porta,1 ;YES: Lamp 2 OFF
Call wait25ms
goto start
ontvangen BTFSS PIR1,RCIF ;check for received data
GOTO ontvangen
MOVF RCREG,w
RETURN
$9A
$9A
$CE
$9A
Greets,
Gert.
*EDIT*
The problem was RMW!!!