LIST p=16F84 ;tell assembler what chip we are using
include "P16F84.inc" ;include the defaults for the chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC ;sets the configuration settings (oscillator type etc.) or RC_OSC if thats what your using
Rcv_Byte equ 0x0C
Bit_cntr equ 0x1C
Delay_Count equ 0x0D
STATUS equ 0x03
PORTA equ 0x05
PORTB equ 0x06
TRISA equ 0x85
TRISB equ 0x86
org 0x000
Initialise CLRF PORTA
CLRF PORTB
BSF STATUS,5
MOVLW b'00000000'
MOVWF PORTB
BCF STATUS,5
CALL SER_INIT
Loop CALL Rcv_RS232
MOVWF PORTB
goto Loop
SER_INIT
BSF STATUS,5
MOVLW b'00000001'
MOVWF PORTA
BCF STATUS,5
RETURN
Rcv_RS232 BTFSC PORTA, 0x00
GOTO Rcv_RS232
CALL Start_Delay
BTFSC PORTA,0x00
GOTO Rcv_RS232
MOVLW 0x08
MOVWF Bit_cntr
CLRF Rcv_Byte
Next_RcvBit CALL Bit_Delay
BTFSS PORTA,0x00
BCF STATUS,C
BTFSC PORTA,0x00
BSF STATUS,C
RRF Rcv_Byte,f
DECFSZ Bit_cntr,f
GOTO Next_RcvBit
CALL Bit_Delay
MOVF Rcv_Byte,W
RETURN
Start_Delay MOVLW 0x0C
MOVWF Delay_Count
Start_Wait NOP
DECFSZ Delay_Count,f
GOTO Start_Wait
RETURN
Bit_Delay MOVLW 0x18
MOVWF Delay_Count
Bit_Wait NOP
DECFSZ Delay_Count,f
GOTO Bit_Wait
RETURN
end