This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can't simulate the Serial Port??

Dear ALL,
I have tried to program the serial port and simulated the serial port under the Keil.
But it seems could work.
All the related registers I have checked.
The program just won't get into the uart_sub and loop in the main_loop.


;;Test Program
;;UART always send 0x41h out

org 0000h
ljmp start

org 0023h ;serial communication int
ljmp uart_sub

org 0030h

start:

mov sp,#060h

;------UART Setting Start---------------------------------------------
mov tmod,#00100000b ;Timer0 Mode1,Timer1 Mode2
mov th1,#0fdh
setb tr1

mov scon,#01010000b ;enable Receive
mov ie,#10010000b ;enable UART Interrupt
;------UART Setting End-----------------------------------------------


main_loop:

;;UART test start

mov a,#041h
mov sbuf,a

jmp main_loop
;;UART test end







;;------------------------------------------
;;
;; UART Subroutine Start
;;
;;------------------------------------------

uart_sub:
push psw
push acc
jbc ri,rcv_data
clr ti
jmp uart_done

rcv_data: COM port got data
mov a,sbuf
mov uart_buffer,a

uart_done:
pop acc
pop psw

reti


;;---------------------------------------------------------------------------------
;;
;; UART Subroutine End
;;
;;---------------------------------------------------------------------------------

end

0