lecture11 - 0306-250 Assembly Language Programming Lecture...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-250 Assembly Language Programming Lecture Eleven: SCI Polled Receive •Polled Receive Algorithm •GetChar Subroutine • • • • SCI Registers Baud rate control registers (SCIBDH, SCIBDL) Control registers (SCICR1 , SCICR2) Status registers (SCISR1 , SCISR2 Data registers (SCIDRH, SCIDRL) – Read: Receive data register – Write: Transmit data register Serial Communications Interface (S12SCIV2) Block Description, p. 4. Two separate registers, which map to the same address 2 SCI0 Initialization • Set SCI0 baud rate SCI0BDH, SCI0BDL • Set SCI0 operation/format SCI0CR1 • Set SCI0 operation/enable SCI0CR2 Required once in program before any SCI operation 3 Program SCI Initialization (only once per program) • EQUates constants—at beginning of program SCI_9600H: SCI_9600L: SCI_8N: EQU EQU EQU $00 $0D %00000000 • Set SCI baud rate movb movb #SCI_9600H,SCI0BDH #SCI_9600L,SCI0BDL • Set SCI character format for serial bit stream movb #SER_8N,SCI0CR1 • Enable SCI transmitter and receiver movb #(mSCI0CR2_RE|mSCI0CR2_TE),SCI0CR2 4 Polled Receive What does it mean? • Poll – Question or canvas – Test • Receive – Acquire – Get HCS12-SCI application • Poll RDRF bit of SCI’s status register until SCI has received data RDRF = 1 • Read data received, from RDR www.m-w.com 5 Include File EQUates for SCI SR1 INCLUDE 'mc9s12dt256b.inc‘ ;*** SCI0SR1 - SCI 0 Status Register 1; 0x000000CC *** SCI0SR1: equ $000000CC ; bit numbers SCI0SR1_PF: SCI0SR1_FE: SCI0SR1_NF: SCI0SR1_OR: SCI0SR1_IDLE: SCI0SR1_RDRF: SCI0SR1_TC: SCI0SR1_TDRE: equ equ equ equ equ equ equ equ ; bit position masks mSCI0SR1_PF: equ mSCI0SR1_FE: equ mSCI0SR1_NF: equ mSCI0SR1_OR: equ mSCI0SR1_IDLE: equ mSCI0SR1_RDRF: equ mSCI0SR1_TC: equ mSCI0SR1_TDRE: equ 0 1 2 3 4 5 6 7 ; ; ; ; ; ; ; ; Parity Error Flag Framing Error Flag Noise Flag Overrun Flag Idle Line Flag Receive Data Register Full Flag Transmit Complete Flag Transmit Data Register Empty Flag %00000001 %00000010 %00000100 %00001000 %00010000 %00100000 %01000000 %10000000 6 ACIA Polled Receive Algorithm • Algorithm repeat { check RDRF bit of SCI SR } until (RDRF = 1) get character received, from SCI RDR • Note: to clear RDRF condition 1.Read SCI SR containing RDRF 2.Read from SCI RDR (must occur in this order) 7 Polled Receive Code • Algorithm repeat { check RDRF bit of SCI SR } until (RDRF = 1) get character received, from SCI RDR • Instructions—core of GetChar subroutine ; Poll RDRF until ready PollRx: ldaa SCI0SR1 anda #mSCI0SR1_RDRF beq PollRx ; Get character ldab SCI0DRL 8 ...
View Full Document

Ask a homework question - tutors are online