I think that I’ve read everything about 8051′s UART but I can’t understand what goes wrong even in this simpliest example. According to literature in mode 0 MCU transmits byte only when we write it into SBUF, and only there 8 clock impulses occur in TXD line; MCU reads byte when TXD voltage changes.
In this example (only indicator is connected to P1) I write nothing to SBUF, but pediodically TI, then RI interrpupt occur, TXD voltage constantly changes and I constantly recieve 0.
Clock frequency is 12 MHz. What can be a reason?
Thank everyone for any effort!
;====================================================================
; MCU: 80C51
; Compiler: ASEM-51 (Proteus)
;====================================================================
$NOMOD51
$INCLUDE (8051.MCU)
;====================================================================
; RESET AND INTERRUPT VECTORS
;====================================================================
; Reset vector
org 0000h
jmp Init
; Serial port interrupt vector
org 0023h
call SERIAL_PORT_HANDLER
reti
;====================================================================
; MAIN CODE BLOCK
;====================================================================
org 0150h
Init:
setb ES
setb EA
mov SCON, #00010000b ; UART Mode 0,
; accept messages with any 9th bit,
; enable recieving,
; don't recieve 9th bit,
; clear interrupt flags
Loop:
jmp Loop
;====================================================================
; SERIAL PORT INTERRUPT HANDLER
;====================================================================
SERIAL_PORT_HANDLER:
jb TI, _SENT
_RECEIVED:
mov P1, SBUF ; Move to indicator
clr RI
jmp _AFTER_SERIAL_PORT_HANDLING
_SENT:
clr TI
_AFTER_SERIAL_PORT_HANDLING:
ret
;====================================================================
END