serial communications interface module slide #1 of 19 mc68hc908gp20 training purpose -to explain how...

22
Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE - To explain how to configure and use the Serial Communications Interface (SCI) Module in common applications OBJECTIVES: - Describe the uses and features of the Serial Communications Interface Module. - Identify the steps to configure the SCI transmitter. - Identify the steps to configure the SCI receiver. - Identify the steps to set up serial communications from the MC68HC08 to the host PC. CONTENTS: - 22 pages - 2 questions LEARNING TIME: - 40 minutes PREREQUESITE: - 68HC08 CPU training module Tutorial Introduction

Upload: christian-booth

Post on 18-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #1 of 19

MC68HC908GP20 Training

PURPOSE- To explain how to configure and use the Serial Communications Interface

(SCI) Module in common applications OBJECTIVES:

- Describe the uses and features of the Serial Communications Interface Module.

- Identify the steps to configure the SCI transmitter.- Identify the steps to configure the SCI receiver.- Identify the steps to set up serial communications from the MC68HC08 to

the host PC.CONTENTS:

- 22 pages- 2 questions

LEARNING TIME:- 40 minutes

PREREQUESITE:- 68HC08 CPU training module

Tutorial Introduction

Page 2: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #2 of 19

MC68HC908GP20 Training

• Full-duplex high speed asynchronous operation

• Standard mark/space NRZ format

• 32 programmable baud rates

• Programmable 8-bit or 9-bit character length

• Two receiver wakeup methods:

– Address mark wakeup

– Idle line wakeup

• Separately enabled, double-buffered transmitter and receiver

• Advanced data sampling and re-synchronization logic

• Programmable transmitter output polarity

• Eight interrupt sources

SCI Module Features

Page 3: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #3 of 19

MC68HC908GP20 TrainingSCI Module Pins

MC68HC908GP32SCI output pins RxD and TxD

Page 4: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #4 of 19

MC68HC908GP20 Training

• SCI data register (SCDR)• SCI baud rate register (SCBR) • SCI control register 1 (SCC1)• SCI control register 2 (SCC2)• SCI control register 3 (SCC3)• SCI status register 1 (SCS1)• SCI status register 2 (SCS2)

SCI Register Summary

Page 5: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #5 of 19

MC68HC908GP20 Training

Reading SCDR accesses R7:R0.

Writing SCDR accesses T7:T0.

SCI Data Register (SCDR)

Page 6: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #6 of 19

MC68HC908GP20 Training

Double Buffering

PTE0/TxD

SCI Data Register

H 8 7 6 5 4 3 2 1 0 L

ST

OP

ST

AR

T

11-BITTRANSMIT

SHIFT REGISTER

MSB

INTERNAL DATA BUS

CLK From Baud Rate Generator

SCI Transmitter

SCI Data Register

7 6 5 4 3 2 1 0

Transmitter Empty Event (Flag or IRQ

Request)

Transmition Complete

Event (Flag or IRQ Request)

Data from CPU

Page 7: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #7 of 19

MC68HC908GP20 Training

D0 D1 D2 D3 D4 D4 D6 D7 A PStart Stop

optional

SCI internal sampling burst

Incoming data on RxD pin

time

161 2

4

6 R8 R9 R10

start and bit validation

Data Receiver Recovery

R3 R5 R7

Page 8: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #8 of 19

MC68HC908GP20 Training

baud rate to

shift register

clock Source ÷ 4 PRESCALERBAUD RATE

DIVISOR

SCP1

SCP0

SCR0

SCR1

SCR2

÷ 16

DATA RECOVERYPTE1/RxD

SCI baud rate register (SCBR)

Baud Rate Generator

164 divisor prescaler

source clock rate baud

Page 9: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #9 of 19

MC68HC908GP20 TrainingSCI Baud Rate Register (SCBR)

SCR2 - SCR0000001

baud rate divisor12

010 4011 8100 16101 32110 64111 128

SCP1 - SCP00001

prescaler13

10 411 13

Page 10: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #10 of 19

MC68HC908GP20 TrainingSelecting the Baud Rate

baud 1920025641

MHz 9152.4

164divisor prescaler

SourceClock rate baud

SCR2 - SCR0000001

baud rate divisor12

010 4011 8100 16101 32110 64111 128

SCP1 - SCP00001

prescaler13

10 411 13

Generate a baud rate of 19200 baud:

Page 11: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #11 of 19

MC68HC908GP20 TrainingSCI Control Registers Overview

SCC1

SCC2

SCC3

Page 12: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #12 of 19

MC68HC908GP20 Training

LOOPS — Loop Mode Select Bit

1 = Loop mode enabled

0 = Normal operation enabled

Configuring SCI Operations - SCC1

Page 13: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #13 of 19

MC68HC908GP20 Training

TE - Transmitter Enable Bit

1 = Transmitter enabled

0 = Transmitter disabled

Configuring SCI Operations - SCC2

Page 14: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #14 of 19

MC68HC908GP20 Training

R8 — Received Bit 8

When receiving 9-bit characters, R8 is the ninth bit (bit 8) of the character.

When receiving 8-bit characters, R8 is a copy of the eighth bit (bit 7) of the character.

Configuring SCI Operations - SCC3

Page 15: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #15 of 19

MC68HC908GP20 Training

SCC2

SCC3

Configuring SCI Interrupts

Page 16: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #16 of 19

MC68HC908GP20 Training

SCTE — SCI Transmitter Empty Bit

1 = SCDR data transferred to transmit shift register

0 = SCDR data not transferred to transmit shift register

SCI Status Register 1 (SCS1)

Page 17: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #17 of 19

MC68HC908GP20 Training

BKF — Break Flag Bit

1 = Break character detected0 = No break character detected

SCI Status Register 2 (SCS2)

Page 18: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #18 of 19

MC68HC908GP20 Training

Transmit “Hello World” at 9600,n,8,1 to a terminal:

$include 'iogp20.inc'

ORG $FFFEFDB Application ;Reset Vector

ORG $B000Application:

MOV #$0B,CONFIG1;No COP, 5V Operation, No Low voltage detectionMOV #$02,CONFIG2 ;Use Internal data bus clock as clock source for SCI

MOV #%00000011,SCBR ;Select 9600 Baud rate over a clock = 4.9152 MHzMOV #%01000000,SCC1 ;Enable SCIMOV #%00001000,SCC2 ;Transmit enable, Disable receiverLDA SCS1 ;Condition to clear SCT Tx empty bit

Main:MOV #'H',SCDR ;Send “H”BRCLR 7,SCS1,* ;Wait for TXMOV #'e',SCDR ;Send “e”BRCLR 7,SCS1,* ;Wait for TXMOV #'l',SCDR ;Send “l”BRCLR 7,SCS1,* ;Wait for TXMOV #'l',SCDR ;Send “l”BRCLR 7,SCS1,* ;Wait for TXMOV #'o',SCDR ;Send “o”BRCLR 7,SCS1,* ;Wait for TXMOV #$0013,SCDR ;Send <CR>BRCLR 7,SCS1,* ;Wait for TXJMP MAIN

Example: Transmission Program

Page 19: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #19 of 19

MC68HC908GP20 Training

$include 'iogp20.inc'

ORG $FFFEFDB Application ;Reset Vector

ORG EPROMApplication:

MOV #$0B,CONFIG1 ;No COP, 5V Operation, No Low voltage detectionMOV #$02,CONFIG2 ;Use Internal data bus clock as clock source for SCI

MOV #%00000011,SCBR ;Select 9600 Baud rate over a clock = 4.9152 MHzMOV #%01000000,SCC1 ;Enable SCIMOV #%00100100,SCC2 ;Receiver enable, Disable transmitterLDA SCS1 ;Condition to clear SCT Tx empty bit

CLR PORTC ;Set PORTC = 0x00BSET 4,DDRC ;Set PORTC Bit 4 as Output.CLI

Main: JMP MAIN ;Application Loop

RxEvent:LDA SCS1 ;Clear Rx flagLDA SCDR ;Read incoming charCMP #'4' ;IF Acc = ASCII(4) Then Complement PORTC output contentsBNE EndIRQ ;ELSE Exit IRQCOM PORTC ;Complement PORTC output contents

EndIRQ RTI ;End this IRQ

ORG $FFE4 ;Set SCI Receiver full Event (a New character has arrive)DW RxEvent ;Define Interrupt Service Routine in IRQ Vector Table

Receive a “4” to turn off/on a LED:

Example: Reception Program

Page 20: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #20 of 19

MC68HC908GP20 Training

Question

What is the SCI baud rate when the clock frequency is 4.9152 MHz, the prescaler select bits are set to 01, and the baud rate select bits are set to 001? Click on your choice.

a) 3200 baud

b) 12,800 baud

c) 19,200 baud

d) 25,600 baud

Page 21: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #21 of 19

MC68HC908GP20 Training

Question

Which of the following instructions configures the SCI to generate both a noise error interrupt and a parity error interrupt? Click on your choice.

a) MOV #%01010000, SCC3

b) MOV #%00000101, SCS1

c) MOV #%10000001, SCC2

d) MOV #%00000101, SCC3

Page 22: Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface

Serial Communications Interface ModuleSlide #22 of 19

MC68HC908GP20 Training

Tutorial Completion

- SCI Uses and Features - SCI Configuration- SCI Transmission- SCI Reception