PA3040
Advanced Member level 3
- Joined
- Aug 1, 2011
- Messages
- 883
- Helped
- 43
- Reputation
- 88
- Reaction score
- 43
- Trophy points
- 1,308
- Activity points
- 6,936
Dear All,
Today experiment with UART + MCU 16f877a
1. I wrote a program and compiled successfully
2. Simulated in Proteus with virtual terminal
3. displayed unexpected character
Please find the attachment for picturs
Advice is needed
Thanks in advance
Today experiment with UART + MCU 16f877a
1. I wrote a program and compiled successfully
2. Simulated in Proteus with virtual terminal
3. displayed unexpected character
Please find the attachment for picturs
Advice is needed
Thanks in advance
Code:
char_loader equ 0x20 ;bank 0
LIST P=P16F877
#include <p16f877a.inc>
__config 3f39
org 0x000
start goto main
main call sys_init
loop call load_char
goto loop
load_char movlw 'T'
movwf char_loader
call send_char
movlw 'E'
movwf char_loader
call send_char
movlw 'S'
movwf char_loader
call send_char
movlw 'T'
movwf char_loader
call send_char
movlw '1'
movwf char_loader
call send_char
movlw '2'
movwf char_loader
call send_char
movlw '3'
movwf char_loader
call send_char
return
send_char btfss PIR1,TXIF ;Check the USART transmit buffer is empty
goto $-1
movf char_loader,w
movwf TXREG
return
sys_init bsf STATUS,5
movlw b'00000000'
movwf TRISC
movlw 0x11
movwf SPBRG ; Set Baud rate 9600bps
movlw b'10100000' ; 8-bit transmit, transmitter enabled,
movwf TXSTA ; asynchronous mode, low speed mode
bcf STATUS,5
bsf RCSTA,SPEN ;Serial port enabled
;(configures RC7/RX/DT and
;RC6/TX/CK pins as serial port pins)
return
end