;***************************************************************; ;***************************************************************; ;** Monitor Main File for the 8051 **; ;** 8051 built-in version **; ;** UW ECE 453 Computer Labs **; ;** (c) 1997 University of Wisconsin **; ;** **; ;***************************************************************; ;***************************************************************; ; Compile using the Cross-32 Meta-Assembler ;***************************************************************; ;** Hardware definitions **; ;***************************************************************; ; Processor family and hex file format cpu "C:\Lab_Sw\Cross-32\8051.tbl" ; Intel 8051 family microcontroller hof "INT8" ; Intel 8-bit hex output format incl "lib51.asm" ; Library Functions for the 8051 ; Part addresses ROM: equ 0x0000 ; Base address of EPROM ROMEND: equ 0x2000 ; Location after end of EPROM STANDALONE: equ 0 ; Standalone boot address, zero if monitor RAM: equ 0x2000 ; Base address of RAM RAMEND: equ 0x4000 ; Location after end of RAM STACK: equ 0x2f ; Initial stack pointer ; Crystal and baud rates CRYSTAL: equ 11059200 ; Crystal rate in Hertz BAUD: equ 57600 ; Baud rate in Hertz ; User-defined procedures USREI0: equ 0x2010 ; External interrupt 0 vector USRTF0: equ 0x2020 ; Timer 0 overflow vector USREI1: equ 0x2030 ; External interrupt 1 vector ;***************************************************************; ;** Include the Monitor Code **; ;***************************************************************; incl "mon51.asm" ; Monitor for the 8051 Microcontroller Family ;***************************************************************; ;** UART-specific routines **; ;***************************************************************; ; uartinit ; Initialize the built-in UART. ; Inputs: ; None. ; Outputs: ; None. ; Error handling: ; None. ; Side-effects: ; Nothing destroyed. uartinit: mov PCON, #10000000b; 1xxxxxxx = Double baud rate ; xxxx00xx = General purpose bits ; xxxxxx00 = Normal power mov IE, #00000000b ; 0xxxxxxx = Disable all interrupts mov IP, #00000000b ; 00000000 = Low priority interrupts mov TCON, #00000000b; x0xxxxxx = Timer 1 off ; xxx0xxxx = Timer 0 off ; 0x0x0000 = Cleared timers mov TMOD, #00100010b; 0xxxxxxx = Timer 1 started by TR1 ; x0xxxxxx = Timer 1 as timer ; xx10xxxx = Timer 1 8-bit auto load ; xxxx0xxx = Timer 0 started by TR0 ; xxxxx0xx = Timer 0 as timer ; xxxxxx10 = Timer 0 8-bit auto load mov TH1, #{{-2*CRYSTAL}/{BAUD*384}} ; Set baud rate mov SCON, #01010010b; 01xxxxxx = 8-bits, variable clock ; xx0xxxxx = Single-processor ; xxx1xxxx = Enable reception ; xxxx00xx = Cleared flags ; xxxxxx1x = Ready to send ; xxxxxxx0 = Receiver cleared setb TR1 ; Start timer 1 ret ; Done! ; uartintr ; UART interrupt service routine. ; Inputs: ; None. ; Outputs: ; Carry = 1 if break character received; 0 otherwise. ; Error handling: ; Side-effects: ; Flags destroyed. uartintr: clr CY ret ; Done! ; inchar ; Input a character from the built-in serial port. ; Inputs: ; None. ; Outputs: ; A = character read. ; Error handling: ; None. ; Side-effects: ; Nothing destroyed. ; Blocks until character is read. _inchar: jnb RI, _inchar ; Is received character ready? clr RI ; If so, mov A, SBUF ; Put it in accumulator ret ; Done! ; outchar ; Output a character to the built-in serial port. ; Inputs: ; A = character to output. ; Outputs: ; None. ; Error handling: ; None. ; Side-effects: ; Nothing destroyed. ; Blocks until character is output. _outchar: jnb TI, _outchar ; Is transmitter ready? clr TI ; If so, mov SBUF, A ; Output accumulator ret ; Done! ;***************************************************************; ;** End-of-file **; ;***************************************************************; end ; End of the source file