fbus pic
Thanks for the reply.
I wrote a small section of code for initialising FBUS and for sending the 'GET SOFTWARE'
command.This is the first time I am using the UART module.So plz point out if
there are any mistakes in the following code section.
:_____________________________________________________________________________________
banksel TXSTA
bcf TXSTA,TX9; 8 bit transmit
bcf TXSTA,SYNC; asynchronous
bsf TXSTA,BRGH; high speed
banksel RCSTA
bsf RCSTA,SPEN; enable serial port
bcf RCSTA,RX9; 8 bit
bcf RCSTA,ADDEN;disable address detection
banksel SPBRG
movlw 0x0A
movwf SPBRG; move 10(dec)for 115200 baud
banksel TRISC
bsf TRISC,7
bsf TRISC,6; RC7&RC6 as 1 for UART
banksel PORTC
call fbus_initialize
;###########################################
; send 1E,00,0C,D1,00,07,00,01,00,03,00,01,60,00,72,D5 to
; phone(as given in embedtronics) to get software version
;#############################################
banksel TXSTA
bsf TXSTA,TXEN; enable transmission
banksel TXREG
send_command_phone_version
movlw 0x1E ;
movwf TXREG ; data immediately transferred
check_TXREG ; to TSR.
btfss PIR1,TXIF; wait for transmission to complete
goto check_TXREG; and TXREG to become empty
movlw 0x00
movwf TXREG
check_TXREG1
btfss PIR1,TXIF
goto check_TXREG1;;;;
movlw 0x0C
movwf TXREG
check_TXREG2
btfss PIR1,TXIF
goto check_TXREG2;;;;
movlw 0xD1
movwf TXREG
check_TXREG3
btfss PIR1,TXIF
goto check_TXREG3;;;;
:
:
:similarly
:
:
:
movlw 0x72
movwf TXREG
check_TXREG14
btfss PIR1,TXIF
goto check_TXREG14;;;;
movlw 0xD5
movwf TXREG
check_TXREG15
btfss PIR1,TXIF
goto check_TXREG15;;
;---------------------------------------------
fbus_initialize
movlw 0x80 ; 128(dec)
movwf count1 ; count1 equ 0x20
fbus_initialize_loop1
call send_U_asynchronous
decfsz count1,1; loop 128 times
goto fbus_initialize_loop1
return
;----------------------------------------------
send_U_asynchronous
banksel TXSTA
bsf TXSTA,TXEN ; enable transmit
movlw 0x55
movwf TXREG ; move 'u' to TXREG
return
;-----------------------------------------------