8051 microcontrollers an applications based introduction

Page 163

154 The XA 16-bit microcontroller Program $INCLUDE(REGXAG49.INC) ORG 0 DW 8F00H,START ORG 120H START: MOV.B WDCON,#0 MOV.B WFEED1,#0A5H MOV.B WFEED2,#5AH MOV.B S0CON,#42H MOV.B TMOD,#20H MOV.B RTL1,#238 MOV.B TL1,#238 SETB TR1 FIRST: MOV.B R4L,#1 TEXT1: MOV.W R6,#MSG1 JMP NEXTCH TEXT2: MOV.W R6,#MSG2 NEXTCH: MOVC.B R3L,[R6+]

NEXT: SEND:

MSG1: MSG2:

; list of sfr addresses ; reset address ; define PSW ; program start address ; watchdog control off ; watchdog feed1 ; watchdog feed2 ; serial mode 1, TI set ; timer 1 mode 2 ; timer 1 reload TL1 ; TL1 also initially set ; turn timer 1 on ; message marker ; message1 address into R6 ; jump over message2 ; message2 address into R6 ; contents of R6 into R3L, ; increment R6 CJNE R3L,#7EH,NEXT ; checkforendofmessage,~ ¼ 7EH MOV.B R3L,#0DH ; carriage return into R3L CALL SEND ; send carriage return MOV.B R3L,#0AH ; line feed into R3L CALL SEND ; send line feed DJNZ R4L,FIRST ; decrement R4L, if not zero ; message1 JMP TEXT2 ; if R4L zero message2 CALL SEND ; send current character JMP NEXTCH ; get next character JNB TI,SEND ; check SBUF clear to send CLR TI ; clear TI MOV.B S0BUF,R3L ; send current character RET ; return from subroutine DB ‘Roses are red~’ ; message1 DB ‘Violets are blue~’ ; message2 END ; end of assembly language

Simulation The simulation can be run with the animation button set. The animation button is shown in Figure 6.8.

Figure 6.8 Animation button

In the simulation the blue horizontal cursor moves through the program and the message text prints out on the UART Buffer window as shown in Figure 6.9.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.