Mitsubishi Motors DS5000TK User Manual

Page 123

Advertising
background image

USER’S GUIDE

050396 122/173

123

;This code example shows how to initialize the serial port and transmit /

; receive code as described above.

TA

Equ

0C7h

MCON

Equ

0C6h

Org

00h

Reset :

SJMP

Start

Org

23h

Serial_ISR :

CLR

RI

;Clear receive flag

CLR

TI

;Clear transmit flag

RETI

;No special processing, return to application

Org

30h

Start :

MOV

TA, #0AAh

;Start Timed Access

MOV

TA, #55h

; finish Timed Access

MOV

MCON, #88h

;Select Partition at 4000h (DS5000)

CLR

RI

;Initialize receive flag

CLR

TI

:Initialize transmit flag

MOV

SCON, #50h

;Configure Serial Port for Mode 1 and enable receiver

MOV

TMOD, #20h

;Configure the Timer 1 for 8–bit auto–reload

MOV

TCON, #40h

;Enable the Timer 1

MOV

TH1, #0FDh

;Set Baud Rate

ANL

PCON, #7Fh

;Set SMOD=0

MOV

IP, #10h

;Set Serial Interrupt to high priority

MOV

IE, #90h

;Globally enable interrupts and Serial Interrupt

Send :

MOV

R0, #0FFh

;Set loop counter to 255

MOV

DPTR, #4000h

;Put the data pointer at the beginning of data memory

Send_Loop :

MOVX

A, @DPTR

;Get data byte

MOV

SBUF, A

;Transmit data byte

JNB

TI, $

;Wait for serial word to be sent (interrupt)

INC

DPTR

;Next byte to be sent

DJNZ

R0, Send_Loop

;Decrement loop counter

Receive :

JNB

RI, $

;Wait for incoming word (interrupt)

MOV

R1, SBUF

;Get received byte

CJNE

R1, #0A5h, Send ;Check for confirmation code

; and resend all data if wrong

End

Advertising
This manual is related to the following products: