Try something like this.
Code:
DEFINE OSC 4
' Timing as described in NexaProtocol.txt
T CON 350 ' T = 350uS
T3 CON 1050 ' 3T
T32 CON 11200 ' 32T (Stop/Synch)
' Note we're using 1 VS X as shown in text
A1_ON CON %101100000000 ' 12-bit code for House/Unit A1 ON
A1_OFF CON %001100000000 ' 12-bit code for House/Unit A1 OFF
' ||||||||||||____ 4-bit House code
' ||||||||________ 4-bit Unit code
' ||||____________ 3-bit Unknown code
' |_______________ 1-bit Activation code 1=ON 0=OFF
D_PACKET VAR WORD ' Holds 12-bit data packet to send
INDEX VAR BYTE ' Data packet bit index pointer
LOOPS VAR BYTE ' Loop counter
TX VAR PORTB.0 ' Connects to RF transmitter data in
LOW TX ' TX output idles low for RF carrier OFF
Main:
D_PACKET = A1_ON
GOSUB Send
PAUSE 5000
D_PACKET = A1_OFF
GOSUB Send
PAUSE 5000
GOTO Main
Send:
FOR LOOPS = 1 TO 4 ' send each packet 4 times
FOR INDEX = 0 TO 11 ' sends 12 bits per pass LSB 1st
HIGH TX ' The 1st half of a 0 or X bit period is the
PAUSEUS T ' same so no need to repeat this sequence inside
LOW TX ' the IF block
PAUSEUS T3
IF D_PACKET.0[INDEX]=1 THEN
HIGH TX ' send a 1 bit (1=X here)
PAUSEUS T3
LOW TX
PAUSEUS T
ELSE
HIGH TX ' send a 0 bit
PAUSEUS T
LOW TX
PAUSEUS T3
ENDIF
NEXT INDEX ' loop until all 12-bits sent
' Start of Stop/Synch period after each 12-bit packet
HIGH TX
PAUSEUS T
LOW TX
PAUSEUS T32
' End of Stop/Synch period
NEXT LOOPS ' send 4 packets per pass
RETURN
END
Can't say if this works or not since I don't have the receiver to play with, but it looks close
to what's shown in the NexaProtocol.txt timing diagram.
Bookmarks