Texas Instruments MSP50C614 manual Data

Models: MSP50C614

1 414
Download 414 pages 24.44 Kb
Page 361
Image 361

Implementation Details

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

;called from C±±

;void oport(char Port, int Data)

;Writes Data to the I/O port specified by the letter Port.

;Example:

;oport('B', 0xAA); //Write 0xAA to port B. ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± _oport

mov

a0, *r7 ± 4 ; port address

mov

a0~, *r7 ± 2

; data

add

a0, _out_port_access ± 'A' ; find the location in the table

mov

a0, *a0

; get the value of the label in the table

jmp

*a0

; jump to the label from the table

_prta

 

 

out

0x00, a0~

; write to PortA

ret

 

 

_prtb

 

 

out

0x08, a0~;

write to PortB

ret

 

 

_prtc

 

 

out

0x10, a0~

; write to PortC

ret

 

 

_prtd

 

 

out

0x18, a0~

; write to PortD

ret

 

 

_prte

 

 

out

0x20, a0~

; write to PortE

ret

 

 

_out_port_access

; table for table lookup

DATA

_prta

 

DATA

_prtb

 

DATA

_prtc

 

DATA

_prtd

 

DATA

_prte

 

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

;called from C±±

;int iport(char Port)

;Reads data from the I/O port specified by the letter Port.

;Example:

;int data = iport('F'); //Read port F. ;±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± _iport

mov

a0, *r7 ± 2 ; port address

add

a0, _in_port_access ± 'A' ; find the location in the table

mov

a0, *a0

; get the value of the label in the table

jmp

*a0

; jump to the label from the table

_iprta

 

 

in

a0, 0x00

; read from PortA

ret

 

 

_iprtb

 

 

in

a0, 0x08

; read from PortB

ret

 

 

Code Development Tools

5-61

Page 361
Image 361
Texas Instruments MSP50C614 manual Data