QE128 Quick Reference User Guide, Rev. 1.0
Freescale Semiconductor
10-1
Chapter 10
Using the Serial Communications Interface (SCI) for the QE
Microcontrollers
10.1
Overview
This is a quick reference for using the serial communication interface (SCI) module for the QE family
microcontrollers (MCUs). Basic information about the functional description and configuration options
are provided. The following example may be modified to suit an application. The SCI project is made for
the MC9S08QE128 and MCF51QE128 MCUs.
10.2
SCI project for EVB
10.2.1
Code Example and Explanation
This example code is available from the Freescale Web site www.freescale.com.
The zip file contains the following functions:
•
main — Endless loop waiting for the SCI interrupt to occur.
•
MCU_Init – MCU initialization, watchdog disable and the SCI clock module enabled.
•
GPIO_Init – Configure PTE port as output.
•
SCI_Init – SCI module configuration.
•
SCI_RX_ISR — The data obtained by SCI module is displayed on the PTE port and the character
“1” is sent by SCI.
The following example describes the initialization code for the SCI module. This example configures the
serial communications interface at 9600bps, in an 8-bit mode. The MCU waits for an interrupt, once an
interrupt is detected the received data is displayed on the PTE port and then the character “1” is sent by
SCI. The SCI module uses interrupts to handle transmition, reception and errors events, for this example
reception interrupt is used.
The code below executes the instructions to disable the watchdog, enable the Reset option and backgroud
pin. The System Option Register 1 (SOPT1) is used to configure the MCU. The SCGC1 and SCGC2 are
registers used for saving power consumption, here the bus clock to peripherals can be enabled or disabled.
In this example only the bus clock to the SCI module is active. The clocks to the other peripherals are
disabled.
void MCU_Init(void) {
SOPT1 = 0x23; // Watchdog disabled. Stop Mode Enabled. Background Pin
// enable. RESET pin enable
SCGC1 = 0x01; // Bus Clock to the SCI1 module is enabled
SCGC2 = 0x00; // Disable Bus clock to unused peripherals