Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Serial Communication Interface (SCI) MC9S12-C32

Similar presentations


Presentation on theme: "The Serial Communication Interface (SCI) MC9S12-C32"— Presentation transcript:

1 The Serial Communication Interface (SCI) MC9S12-C32
Lecture L4.9

2 HCS12 Serial Communications Interface
Reference HCS12 Serial Communications Interface (SCI) Block Guide V02.08 S12SCIV2.pdf

3 PIM_9C32 Block Diagram SCI module

4 SCI Asynchronous Serial I/O The 68HCS12 SCI Interface
Programming the SCI SCI Interface Using Interrupts

5

6 SCI Asynchronous Serial I/O The 68HCS12 SCI Interface
Programming the SCI SCI Interface Using Interrupts

7

8

9

10

11

12

13

14

15 SCI Asynchronous Serial I/O The 68HCS12 SCI Interface
Programming the SCI SCI Interface Using Interrupts

16 sci.asm ; SCI0 SC0BDH EQU $C8 ;baud rate control
SC0CR1 EQU $CA ;SCI control reg 1 SC0CR2 EQU $CB ;SCI control reg 2 SC0SR1 EQU $CC ;SCI status reg SC0DRL EQU $CF ;SCI data reg RDRF EQU $ ;SCSR mask ; INITIALIZE SCI sci0_init CLR SC0CR ;8 bit LDD #52 STD SC0BDH ;9600 baud LDAA #$0C STAA SC0CR ;enable tx & rx RTS

17 ; INPUT BYTE FROM SERIAL PORT INTO A
INCHAR LDAA SC0SR ;check status ANDA #RDRF ;check rdrf BEQ INCHAR ;wait for char LDAA SC0DRL ;get char in A RTS ; OUTPUT BYTE IN A TO SERIAL PORT OUTPUT TST SC0SR1 BPL OUTPUT ;loop until tdre STAA SC0DRL ;send A

18 Communicating with a PC

19 sciecho.asm ; echo char to PC org $4000 sci_echo bsr sci0_init
se1 bsr inchar bsr output bra se1 #include sci.asm

20 SCI Asynchronous Serial I/O The 68HCS12 SCI Interface
Programming the SCI SCI Interface Using Interrupts

21 ; SCI Interface using interrupts File: SCIINT.WHP
; display characters from PC keyboard on LCD display SC0BDH EQU $C8 ;baud rate control SC0CR1 EQU $CA ;SCI control reg 1 SC0CR2 EQU $CB ;SCI control reg 2 SC0SR1 EQU $CC ;SCI status reg SC0DRL EQU $CF ;SCI data reg RDRF EQU $ ;SCSR mask SCI0.IVEC EQU $0FD8 ;SCI0 user vector address + 2 ORG $4000 main jsr spi_init ;initialize spi jsr lcd_init ;initialize lcd jsr initq ;initialize queue jsr sci0_init ;initialize sci mn1 jsr checkq ;if queue is empty bcs mn1 ; wait jsr data8 ;store char on LCD ldy #3 jsr ms_delay ;delay ~10 ms bra mn1

22 ; INITIALIZE SCI sci0_init SEI ;disable interrupts CLR SC0CR ;8 bit LDD #52 STD SC0BDH ;9600 baud LDAA #$2C STAA SC0CR ;enable tx & rx, RX INT LDD #SCI_INTSER STD SCI0.IVEC ;set sci int vector CLI ;enable interrupts RTS

23 ; Interrupt service routine: get char and store in queue 
SCI_INTSER LDAA SC0SR1 ANDA #RDRF BEQ SI1 ;if RDRF set LDAA SC0DRL ;read data (clears RDRF flag) JSR QSTORE ;and store it in queue SI1 RTI #INCLUDE QUEUE.ASM #INCLUDE LCD.ASM


Download ppt "The Serial Communication Interface (SCI) MC9S12-C32"

Similar presentations


Ads by Google