gidp
Newbie level 5
usart pic
Hello,
I need help in operating the USART, in SYNC mode when PIC 16F870 is used as MASTER and transmit data, to PIC 16F877A that set as SLAVE and received the data. I have set the baud rate to 62.5Mb/s.
When the master send the data via the TXREG, and I’m using delay of 200ms and then sends the next data it works (the slave gets the proper data):
MOVLW ADDRESS ; send the address as LOW byte TX
MOVWF TXREG ;
CALL DELAY_200MS ; call delay 200msec routine
But when I use the status register to test if the TX is completed its not working:
MOVLW ADDRESS ; send the address as LOW byte TX
MOVWF TXREG ;
BTFSS TXSTA,TRMT ; check if tx shift reg is empty
GOTO $-1 ; if not empty continue to check
GOTO NEXTB ; if empty go to send the next byte
My question is why the checking of the status register is not working?
and how can I sync between the master and slave so each time the master sends a byte the slave will received it properly?
Thanks in advanced.
Gideon.
The Master program starts as:
ORG 00H
NOP
GOTO MAIN
ORG 04H ; interrupt entrance address
RETFIE
MAIN
CLRF PORTC
BSF STATUS,RP0 ; select bank1 ;
CLRF TRISC ; set all PORTC as OUTPUT
MOVLW 0x27 ; for 10MHz XTAL set the Baud Rate to 62.5kb/s
MOVWF SPBRG
MOVLW 0xB0 ; Set USRAT TX Status Reg', CSRC bit7=1, TXEN bit5=1, SYNC bit4=1
MOVWF TXSTA ; bit1 TRMT (tx status) 1=empry
BCF STATUS,RP0 ; select bank0
MOVLW 0x80
MOVWF RCSTA ; Set USART RX Status Reg', Serial Port Enable SPEN bit7=1
BSF INTCON,GIE ; enable general interrupt
BSF INTCON,PEIE ; enable outside interrupt
Hello,
I need help in operating the USART, in SYNC mode when PIC 16F870 is used as MASTER and transmit data, to PIC 16F877A that set as SLAVE and received the data. I have set the baud rate to 62.5Mb/s.
When the master send the data via the TXREG, and I’m using delay of 200ms and then sends the next data it works (the slave gets the proper data):
MOVLW ADDRESS ; send the address as LOW byte TX
MOVWF TXREG ;
CALL DELAY_200MS ; call delay 200msec routine
But when I use the status register to test if the TX is completed its not working:
MOVLW ADDRESS ; send the address as LOW byte TX
MOVWF TXREG ;
BTFSS TXSTA,TRMT ; check if tx shift reg is empty
GOTO $-1 ; if not empty continue to check
GOTO NEXTB ; if empty go to send the next byte
My question is why the checking of the status register is not working?
and how can I sync between the master and slave so each time the master sends a byte the slave will received it properly?
Thanks in advanced.
Gideon.
The Master program starts as:
ORG 00H
NOP
GOTO MAIN
ORG 04H ; interrupt entrance address
RETFIE
MAIN
CLRF PORTC
BSF STATUS,RP0 ; select bank1 ;
CLRF TRISC ; set all PORTC as OUTPUT
MOVLW 0x27 ; for 10MHz XTAL set the Baud Rate to 62.5kb/s
MOVWF SPBRG
MOVLW 0xB0 ; Set USRAT TX Status Reg', CSRC bit7=1, TXEN bit5=1, SYNC bit4=1
MOVWF TXSTA ; bit1 TRMT (tx status) 1=empry
BCF STATUS,RP0 ; select bank0
MOVLW 0x80
MOVWF RCSTA ; Set USART RX Status Reg', Serial Port Enable SPEN bit7=1
BSF INTCON,GIE ; enable general interrupt
BSF INTCON,PEIE ; enable outside interrupt