Freescale Semiconductor QE128 Quick Reference User Manual

Devices supported: mcf51qe128 mc9s08qe128
Table of Contents

Advertisement

Quick Links

QE128 Quick Reference User Guide
Devices Supported:
MCF51QE128
MC9S08QE128
Document Number: QE128QRUG
Rev. 1.0
10/2007

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the QE128 and is the answer not in the manual?

Questions and answers

Summary of Contents for Freescale Semiconductor QE128

  • Page 1 QE128 Quick Reference User Guide Devices Supported: MCF51QE128 MC9S08QE128 Document Number: QE128QRUG Rev. 1.0 10/2007...
  • Page 2 Freescale Semiconductor product could Asia/Pacific: create a situation where personal injury or death may occur. Should Buyer Freescale Semiconductor Hong Kong Ltd.
  • Page 3: Table Of Contents

    5.3 Hardware Implementation ..........1-4 QE128 Quick Reference User Guide, Rev. 1.0...
  • Page 4 10.2 SCI project for EVB ........... . 1-1 QE128 Quick Reference User Guide, Rev. 1.0...
  • Page 5 14.1 Overview............. 1-1 QE128 Quick Reference User Guide, Rev. 1.0...
  • Page 6 14.4 Hardware Implementation ..........1-7 QE128 Quick Reference User Guide, Rev. 1.0...
  • Page 7 QE Peripheral Module Quick Reference User Guide A Compilation of Demonstration Firmware for QE Modules This document is a brief description of the QE128 microcontroller unit (MCU) in an 8-bit version and 32-bit version. There is also useful information about core differences.
  • Page 8 QE Peripheral Module Quick Reference User Guide QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 9: Qe Mcus 8-Bit And 32-Bit Comparison

    Supports up to 30 peripheral interrupts and seven software interrupts. • Built upon lowest-cost ColdFire V2 core microarchitecture. • Two independent decoupled 2-stage pipelines. • Debug architecture remapped into S08's single-pin BDM interface. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 10 AGEX Execute BDC/Debug On-Platform Bus Flash Peripheral RGPIO Controller Controller Bridge Controller Off-Platform Off-Platform Peripheral Bus RGPIO Flash Array SRAM Array BKGD Pins Figure 2-1. ColdFire V1 Core Platform Block Diagram QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 11 Program counter (PC) -- This register contains the address of the currently executing instruction. The PC increments its value or can be loaded with a new one when an instruction is executing or when an exception occurs. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 12 When used in supervisor mode the registers can be accessed. If a supervisor instruction is executed in user mode it generates a privilege violation exception. Figure 2-8 shows the SR behavior in a state machine. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 13 (USP). The hardware implementation of these two registers do not identify one as SSP and the other as USP. Instead, the hardware uses one 32-bit register as the active A7 and the other as, OTHER_A7. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 14 Address Register Indirect with Displacement. op.sz d16(Ay),Rx Address Register Indirect with Scaled Index and Displacement. op.sz d8(Ay,Xi*SF),Rx Program Counter Indirect with Displacement. op.sz d16(PC),Rx Program Counter Indirect with Scaled Index and Displacement. op.sz d8(PC,Xi*SF),Rx) QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 15 I/O interrupt. The ColdFire V1 core uses a reduced version of the interrupt controller from other ColdFire processors. This hardware implementation is available only for a 32-bit MCU. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 16 The ColdFire V1 core architecture only uses a relatively small number of the I/O interrupt vector. Table 2-4 shows the ColdFire V1 core processor with the exception of the vector table. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 17 Level 5 Software Interrupt 0x18C Next Level 4 Software Interrupt 0x190 Next Level 3 Software Interrupt 0x194 Next Level 2 Software Interrupt 0x198 Next Level 1 Software Interrupt 103-255 0x19C-0x3FC Reserved; unused for V1 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 18: Qe S08 Core

    Condition code register (CCR) -- This 8-bit condition code register contains the interrupt mask (I) and five flags that indicate the results of the instruction just executed. Bits 5 and 6 are permanently set to 1. QE128 Quick Reference User Guide, Rev. 1.0 2-10 Freescale Semiconductor...
  • Page 19 -- Any label or expression that refers to an address that is within -128 to +127 locations from the next address after the last byte of object code for the current instruction. A -- Accumulator QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 2-11...
  • Page 20: Coldfire V1 Or 9S08Qe

    These differences are highlighted in the following section. The ColdFire V1 architecture features, staged pipelining allows the core to process multiple instructions at the same time. QE128 Quick Reference User Guide, Rev. 1.0 2-12 Freescale Semiconductor...
  • Page 21 The ColdFire MCU has two programming models with different privileges to control the system. These programming models are similar to the administrator and user in windows. When the MCU is on the QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 22 General-purpose registers (An, Dn) must be saved/restored by the ISR. Interrupt Levels. 1 = f(CCR[I]). 7 = f(SR[I]) with automatic hardware support for nesting. Non-Maskable IRQ Support. Yes with level 7 interrupts. QE128 Quick Reference User Guide, Rev. 1.0 2-14 Freescale Semiconductor...
  • Page 23 0004 a623 0006 c70000 _SOPT1 0009 for(;;) { for (i=0; i<=60000; i++) { 0009 95 000a 6f03 000c 6f02 000e for (k=0; k<=100; k++) { 000e 95 000f 6f01 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 2-15...
  • Page 24 Assembly lines generated for the MCF51QE128 MCU. SOPT1 = 0x23; // Watchdog disable. Stop Mode Enable. Background Pin enable. RESET pin enable for(;;) { 0x00000004 0x7023 moveq #35,d0 0x00000006 0x11C09802 move.b d0,0xffff9802 QE128 Quick Reference User Guide, Rev. 1.0 2-16 Freescale Semiconductor...
  • Page 25 The performance is application dependant. Table 2-8. Comparison of CPU Cycles and Assembly Code Lines MCF51QE128 MC9S08QE128 Assembly lines code CPU Cycles 49,201,507 407,947,991 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 2-17...
  • Page 26: Features Comparison

    SOPT1 register then executing STOP instruction). 2.3.3 Package Comparison Table 2-11. Package Comparison MC9S08QE128 MCF51QE128 Pin-to-pin compatible in 80-LQFP and 64-LQFP packages. Additional 48-QFN, 44-QFP and 32-LQFP packages. No additional packages. QE128 Quick Reference User Guide, Rev. 1.0 2-18 Freescale Semiconductor...
  • Page 27: Clock Comparison

    Hysteresis and configurable pull up device on all input pins, configurable slew rate and drive strength on all output pins. SET/CLR registers on 16 pins (PTC and PTE). Rapid I/O not featured. Selectable Rapid I/O supported on PTC and PTE ports. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 2-19...
  • Page 28: Development Support Comparison

    RTC – (Real time counter) 8-bit modules counter with binary or decimal based prescaler; external clock source for precise time base, time-of-day, calendar or task scheduling functions; Free running on-chip low power oscillator (1 kHz) for periodical wake-up without external components; runs in all MCU modes QE128 Quick Reference User Guide, Rev. 1.0 2-20 Freescale Semiconductor...
  • Page 29: How To Load The Qrug Examples

    Follow these simple steps in order to load the QRUG examples and download it to the device. The explanation works for the EVB and Demo board. 1. Open CodeWarrior 6.0. 2. File -> Open, or click on the Open Icon as shown in Figure 3-1. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 30 3-2. The BDM multilink hardware for programming the MCU is needed when an EVB is used. This device is developed by PEmicro. If a demo board is used do not buy a multilink. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 31 9. Project –> Debug. Click on the debug icon beside the make icon, or just press F5 on the keyboard. Doing this launches the debugger and downloads the program to the MCU flash. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 32 How to Load the QRUG Examples? Make Icon Debug Icon Figure 3-3. Make Icon and Debug Icon 10. After the debug command is executed a window pops up (see Figure 3-4). Click on the Connect option. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 33 13. Click on the run button as shown in Figure 3-5. This figure shows the true-time simulator window or debugger window. This makes the MCU start to execute the project. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 34: Steps To Programming The Mcu Using In-Circuit Bdm

    Follow these simple steps in order to load the QRUG examples and download it to the device. The explanation works for EVB only. 1. Open CodeWarrior 6.0. 2. File -> Open, or click on the Open Icon as shown in Figure 3-6. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 35 5. To open the file, double click on .c extension file (main.c). 6. On the left side of the window is a combo box. Select the SofTec option as shown in Figure 3-7. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 36 10. Project –> Debug. Also click on the debug icon beside the make icon, or just press F5 on the keyboard. Doing this launches the debugger and downloads the program to the MCU flash. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 37 Figure 3-8. Make Icon and Debug Icon 11. After the debug command is executed a window pops up (see Figure 3-9), select the EVBQE128 hardware model and then click on the Connect option. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 38 14. Click on the run button as shown in Figure 3-10. This figure shows the true-time simulator window or debugger window. This makes the MCU start to execute the project. QE128 Quick Reference User Guide, Rev. 1.0 3-10 Freescale Semiconductor...
  • Page 39 How to Load the QRUG Examples? Start/Contin- ue button Figure 3-10. Run/Continue Icon QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 3-11...
  • Page 40 How to Load the QRUG Examples? QE128 Quick Reference User Guide, Rev. 1.0 3-12 Freescale Semiconductor...
  • Page 41: Using The Keyboard Interrupt (Kbi) For The Qe Microcontrollers

    KBEDG[7:0] – determines the polarity edge that is recognized as a trigger event for the corresponding pin. KBI project for EVB 4.2.1 Code example and explanation This example code is available from the Freescale Web site www.freescale.com QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 42 // Put 0's in PTE port This is the initialization code for the keyboard interrupt using the QE128 MCU. For this example, both KBI registers (KBIxSC and KBIxPE) are used to configure the module to detect only falling edges and enable PTD4 to PTD7 as KBI.
  • Page 43: Hardware Implementation

    // Clear the KBI interrupt flag PTED_PTED0 ^= 1; // Toggles PTE0 4.2.2 Hardware Implementation This project is developed using the EVBQE128 STARTER KIT and can be downloaded at www.freescale.com. No extra hardware is needed. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 44 This example is developed using the CodeWarrior IDE version 6.0 for the HCS08 and V1 families. It is expressly made for the MCF51QE128 and MC9S08QE128 (80-pin package). There may be changes needed in the code to initialize another MCU. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 45: Kbi Project For Demo Board

    // Put 0's in PTC0 pin This is the initialization code for the keyboard interrupt using the QE128 MCU. For this example, both KBI registers (KBIxSC and KBIxPE) are used to configure the module to detect only falling edges and enable PTA2 and PTA3 as KBI.
  • Page 46: Hardware Implementation

    KBI1SC_KBACK = 1; // Clear the KBI interrupt flag PTCD_PTCD0 ^= 1; // Toggles PTC0 4.3.2 Hardware Implementation This project was developed using the DEMOQE board. No extra hardware is needed. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 47 4-2, shows the hardware connections used for the KBI project, for detailed information about the MCU supply voltages needed, please refer to the Pins and Connections chapter in the Reference Manual (MC9S08QE128 or MCF51QE128). It can also be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 48 Using the Keyboard Interrupt (KBI) for the QE Microcontrollers QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 49 The project ICS.mcp shows how to configure the ICS module for the QE family MCUs. The main functions are: • main — Endless loop toggling a LED. • MCU_Init – MCU initialization, watchdog disable. • GPIO_Init – Configure PTE0 pin as output. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 50 ICSSC = 0x00; // Initialize ICSSC register from a non volatile memory #endif #ifdef FBI ICSC1 = 0x40; // Internal reference clock is selected ICSC2 = 0x00; // Divides selected clock by 1 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 51 The Bus frequency can be checked in the True-Time Simulator window of CodeWarrior. Once the program is downloaded to the MCU, the simulator window opens, look at the command window and notice the MCU bus frequency change. See Figure 5-1, for detailed information. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 52 TPM1C0V = 500; // PWM duty cycle = 50% Hardware Implementation This project is developed using the EVBQE128 STARTER KIT. No extra hardware is needed. Figure 5-2 shows the hardware configuration. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 53 5-2, shows the hardware connections used for the ICS project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. (MC9S08QE128 or MCF51QE128). It can also be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 54 Using the Internal Clock Source (ICS) for the QE Microcontrollers QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 55: Using The Inter-Integrated Circuit (Iic) For The Qe Microcontrollers

    GCAEN – General Call Address Enable AD[10:8] – Slave Address ADEXT – Address Extension Code Example and Explanation This example codes for the Master and Slave project is available from the Freescale Web site www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 56: Iic Master Project

    IIC baud rate = bus speed (Hz) / (mul * SCL divider) Eqn. 6-1 IIC baud rate = 4000000 / (1 * 32) IIC baud rate = 125000 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 57 = a; // Select number of bytes to transfer num_to_rec = IIC2C1_TX = 1; // Set TX bit for Address cycle IIC2C1_MST = 1; // Set Master Bit to generate a Start QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 58 // Switch to RX mode IIC2D; // Dummy read from Data Register else if (add_cycle !=1) { IIC2D = counter; // Transmit Data count++; if (count == bytes_to_trans) { last_byte = 1; QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 59 The slave address is then sent. void Master_Transmit(uint8 a, uint8 b) { last_byte = 0; QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 60: Iic Slave Project

    // Check for Slave Rec or transmit IIC2C1_TX = 1; // Set Tx bit to begin a Transmit IIC2D = IIC_TX_Data[count]; count++; else { IIC2C1_TX = 0; IIC2D; // Dummy read QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 61: Hardware Implementation

    This project is developed using the EVBQE128 STARTER KIT. No extra hardware is needed. Two resitors are needed for the protocol to work properly. For this example 2 MCUs are connected. Figure 6-1 shows the hardware configuration. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 62 Using the Inter-Integrated Circuit (IIC) for the QE Microcontrollers Figure 6-1. IIC Hardware Implementation QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 63 Figure 6-1, shows the hardware connections used for the IIC project, for detailed information of the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 64 Using the Inter-Integrated Circuit (IIC) for the QE Microcontrollers QE128 Quick Reference User Guide, Rev. 1.0 6-10 Freescale Semiconductor...
  • Page 65: Using The Analog Comparator (Acmp) For The Qe Microcontrollers

    Rising, falling, or any edge may be chosen as the active edge that triggers an input capture. The ACMP2 output can be driven to the TPM2 channel 0 by setting the ACIC2 in the SOPT2. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 66: Acmp Project For Evb

    For more detailed and specific data about internal reference voltage, please see the QE128 DataSheet. It can be found at www.freescale.com. An ACMP+ is fed with a variable voltage of 0 to 3 V. Every time the ACMP+ voltage crosses the ACMP–...
  • Page 67 // Put 0's in PTE port This is the initialization code for the analog comparator used for the QE128 MCU. This application uses the ACMP2 module. The internal bandgap is selected and this voltage is compared with the PTC7 pin voltage.
  • Page 68: Hardware Implementation

    This example is developed using the CodeWarrior IDE version 6.0 for the HCS08 and V1 families. It is expressly made for the MCF51QE128 and MC9S08QE128 (80-pin package). There may be changes needed in the code to initialize another MCU. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 69: Acmp Project For Demo Board

    VectorNumber_Vacmpx ACMP_ISR(void) { // ACMP vector address = 20 (S08) // ACMP vector address = 82 (V1) ACMP2SC_ACF = 1; // Clear ACMP flag */ PTCD_PTCD0 ^= 1; // Toggles PTC0 */ QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 70: Hardware Inplementation

    This example is developed using the CodeWarrior IDE version 6.0 for the HCS08 and V1 families. It is expressly made for the MCF51QE128 and MC9S08QE128 (64-pin package). There may be changes needed in the code to initialize another MCU. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 71 7-3, shows the hardware connections used for the ACMP project, for detailed information about the MCU supply voltages needed, please refer to the Pins and Connections chapter the Reference Manual (MC9S08QE128 or MCF51QE128). It can also be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 72 Using the Analog Comparator (ACMP) for the QE Microcontrollers QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 73: Overview

    ADR7-ADR0 – contains the eight bits of the result of a 12-bit, 10-bit or 8-bit conversion ADCCVH ADCV11 ADCV10 ADCV9 ADCV8 Compare value: ADCV11-ADCV8 – contains the upper four bits of the 12-bit compare value. ADCCVL ADCV7 ADCV6 ADCV5 ADCV4 ADCV3 ADCV2 ADCV1 ADCV0 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 74: Adc Project For Evb

    MCU. For specific information visit www.freescale.com and search for the reference manual MC9S08QE128 or MCF51QE128 MCUs. The QE128 MCUs have a 12-bit analog-to-digital succesive-approximation converter which is the ADC. It can be configured with a 12-bit, 10-bit or 8-bit resolution. These are some options for the user: •...
  • Page 75 // Function that initializes the ADC module EnableInterrupts; // enable interrupts ADCSC1_AIEN = 1; // Enable ADC interrupt APCTL1_ADPC0 = 1; // Select the channel for ADC input for(;;) { // loop forever QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 76: Hardware Implementation

    // ADC vector address = 19 (S08) // ADC vector address = 81 (V1) PTED = ADCRL; // Move the adquired ADC value to PTE port 8.2.2 Hardware Implementation Figure 8-1. ADC Hardware Implementation. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 77: Adc Project For Demo Board

    MCU is S08 or V1. Using these example makes the code fully compatible for either MCU. void interrupt VectorNumber_Vadc ADC_ISR(void) { // ADC vector address = 19 (S08) // ADC vector address = 81 (V1) QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 78: Hardware Implementation

    This example is developed using the CodeWarrior version 6.0 for the HCS08 and V1 families. It is expressly made for the MCF51QE128 and MC9S08QE128 (64-pin package). There may be changes needed in the code to initialize another MCU. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 79 8-2, shows the hardware connections used for the ADC project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 80 Using the Analog to Digital Converter (ADC) for the QE Microcontrollers QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 81: Using The Real Time Counter (Rtc) For The Qe Microcontrollers

    MCU_Init – MCU initialization, watchdog disable and the RTC clock module enabled. • GPIO_Init – Configure PTE port as output. • RTC_Init – RTC module configuration. • RTC_ISR — Toggles PTE port . QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 82 MCU is S08 or V1. Using these example makes the code fully compatible for either MCU. void interrupt VectorNumber_Vrtc RTC_ISR(void) { QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 83: Hardware Implementation

    9-1, shows the hardware connections used for the RTC project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 84: Rtc Project For Demo Board

    // RTC vector address = 24 (S08) // RTC vector address = 86 (V1) RTCSC = RTCSC | 0x80; // Clear the RTC flag PTCD_PTCD0 ^= 1; // Toggles PTC0 pin QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 85: Hardware Implementation

    This example is developed using the CodeWarrior IDE version 6.0 for the HCS08 and V1 families. It is expressly made for the MCF51QE128 and MC9S08QE128 (64-pin package). There may be changes needed in the code to initialize another MCU. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 86 9-2, shows the hardware connections used for the RTC project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 87: Using The Serial Communications Interface (Sci) For The Qe Microcontrollers

    // 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 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 10-1...
  • Page 88 // Display on PTE the received data from SCI while (SCI1S1_TDRE == 0); // Wait for the transmitter to be empty SCI1D = '1'; // Send a character by SCI QE128 Quick Reference User Guide, Rev. 1.0 10-2 Freescale Semiconductor...
  • Page 89 The SCI.mcp project needs to work with the hyperterminal program. The hyperterminal is configured to the following characteristics: • 9600bps baud rate • 8-bit mode • No parity checked • 1 stop bit • No flow control QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 10-3...
  • Page 90: Code Example And Explanation

    PTCD = (UINT8) (temp & 0x3F); // Move the received value to port C while (SCI1S1_TDRE == 0); // Wait for the transmitter to be empty SCI1D = '1'; // Send a character by SCI QE128 Quick Reference User Guide, Rev. 1.0 10-4 Freescale Semiconductor...
  • Page 91: Hardware Implementation

    The SCI.mcp project needs to work with the hyperterminal program. The hyperterminal is configured to the following characteristics: • 9600bps baud rate • 8-bit mode • No parity checked QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 10-5...
  • Page 92 Using the Serial Communications Interface (SCI) for the QE Microcontrollers • 1 stop bit • No flow control Press any key and the character “1” appears. QE128 Quick Reference User Guide, Rev. 1.0 10-6 Freescale Semiconductor...
  • Page 93: Using The Serial Peripheral Interface (Spi) For The Qe Microcontrollers

    Bit 0 Data buffer 11.2 SPI project for EVB 11.2.1 Code Example and Explanation This example code for Master and Slave project is available from the Freescale Web site www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 11-1...
  • Page 94 To obtain a 15.625KHz bit rate it is necessary to do the following calculations: kHz = escaler Divider 256 = (Prescaler Divisor) x (Clock Rate Divider) 256 = 8*32 QE128 Quick Reference User Guide, Rev. 1.0 11-2 Freescale Semiconductor...
  • Page 95 The firmware for this project is similar to the SPI_master project. The differences are, the device is configured as slave and only Receives a byte and displays it on the PTE port. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor...
  • Page 96 // Clear register flag buffer = SPI2D;// Read data register to clear receive flag PTED = buffer; For detailed information about the code, refer to the SPI_Slave project from the QRUG examples. QE128 Quick Reference User Guide, Rev. 1.0 11-4 Freescale Semiconductor...
  • Page 97: Hardware Implementation

    Using the Serial Peripheral Interface (SPI) for the QE Microcontrollers 11.2.2 Hardware Implementation Figure 11-1. SPI Hardware Implementation. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 11-5...
  • Page 98: Spi Project For Demo Board

    Within the enless loop a byte is sent by SPI and the next byte is sent after a delay. For detailed information about SPI module, refer to the QE MCU reference manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 11-6...
  • Page 99 PTED = (UINT8) (temp & 0xC0); // Move the adquired ADC value to port E PTCD = (UINT8) (temp & 0x3F); // Move the adquired ADC value to port C QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 11-7...
  • Page 100 Using the Serial Peripheral Interface (SPI) for the QE Microcontrollers For detailed information about the code, refer to the SPI_Slave project from the QRUG examples. QE128 Quick Reference User Guide, Rev. 1.0 11-8 Freescale Semiconductor...
  • Page 101: Hardware Implementation

    Using the Serial Peripheral Interface (SPI) for the QE Microcontrollers 11.3.2 Hardware Implementation Figure 11-2. SPI Hardware Implementation. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 11-9...
  • Page 102 11-2, shows the hardware connections used for the SPI project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 11-10 Freescale Semiconductor...
  • Page 103: Overview

    MSnB – Mode Select B for TPM Channel n TPMxCnVH Bit 15 Bit 8 TPMxCnVL Bit 7 Bit 0 Captured TPM counter of input capture function OR output copare value for output compare of PWM function QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 12-1...
  • Page 104: Pwm Project For Evb

    // in this register at the beggining because the next value // will be increased by 1 in the ISR TPM1SC = 0x0F; // TPM Clock Source is the bus rate clock. This bus is // divided by 128 QE128 Quick Reference User Guide, Rev. 1.0 12-2 Freescale Semiconductor...
  • Page 105 PTED_PTED0 = PTBD_PTBD5; // PTB5 is the PWM output, so this output is display in the LED1 else { TPM1C1V = 0x0001; // Reset the value of duty cycle to 1 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 12-3...
  • Page 106: Hardware Implementation

    This example is developed using the CodeWarrior IDE version 6.0 for the HCS08 and V1 families. It is expressly made for the MCF51QE128 and MC9S08QE128 (80-pin package). There may be changes needed in the code to initialize another MCU. QE128 Quick Reference User Guide, Rev. 1.0 12-4 Freescale Semiconductor...
  • Page 107: Pwm Project For Demo Board

    PTCD_PTCD0 = PTBD_PTBD5; // PTB5 is the PWM output, so this output is display in the LED1 else { TPM1C1V = 0x0001; // Reset the value of duty cycle to 1 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 12-5...
  • Page 108: Hardware Implementation

    12-2, shows the hardware connections used for the PWM project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 12-6 Freescale Semiconductor...
  • Page 109: Overview

    MSnB – Mode Select B for TPM Channel n TPMxCnVH Bit 15 Bit 8 TPMxCnVL Bit 7 Bit 0 Captured TPM counter of input capture function OR output copare value for output compare of PWM function QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 13-1...
  • Page 110: Tpm Project For Evb

    // The channel interrupt will happen when counter matches TPM3C3SC = 0x54; // Channel interrupt enabled and configured as toggle output on compare TPM3SC = 0x0F; // TPM clock source is: Bus rate clock divided by 128 QE128 Quick Reference User Guide, Rev. 1.0 13-2 Freescale Semiconductor...
  • Page 111 // TPM interrupt vector number = 28 (S08) // TPM interrupt vector number = 90 (V1) TPM3C3SC_CH3F; // Clears timer flag TPM3C3SC_CH3F = 0; PTED_PTED0 = ~PTED_PTED0; // Toggle PTE0 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 13-3...
  • Page 112: Hardware Implementation

    Figure 13-1, shows the hardware connections used for the TPM project, for detailed information about the MCU needed hardware please refer to Pins and Connections chapter on your Reference Manual. QE128 Quick Reference User Guide, Rev. 1.0 13-4 Freescale Semiconductor...
  • Page 113: Tpm Project For Demo Board

    // TPM interrupt vector number = 28 (S08) // TPM interrupt vector number = 90 (V1) TPM3C3SC_CH3F; // Clears timer flag TPM3C3SC_CH3F = 0; PTED_PTED0 = ~PTED_PTED0; // Toggle PTE0 QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 13-5...
  • Page 114 Figure 13-2, shows the hardware connections used for the TPM project, for detailed information about the MCU needed hardware please refer to Pins and Connections chapter on your Reference Manual. QE128 Quick Reference User Guide, Rev. 1.0 13-6 Freescale Semiconductor...
  • Page 115 // Put 0's in PTE port This is the initialization code for RGPIO module used for the MCF51QE128 MCU. These code lines configure the PTE7 to work as a RGPIO output. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 14-1...
  • Page 116 This section describes the necessary steps to observe the differences of using a normal GPIO and RGPIO module in a V1 microcontroller. 1. Once the firmware is downloaded to the MCU, a simulation window is opened like the figure shown below. QE128 Quick Reference User Guide, Rev. 1.0 14-2 Freescale Semiconductor...
  • Page 117 Using the Rapid General Purpose I/O (RGPIO) for the MCF51QE128 Microcontrollers Figure 14-1. Step 1 2. Go to code line PTED_PTED3 ^= 1. Right click and select Set Breakpoint option. See next figure. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 14-3...
  • Page 118 3. Go to code line PTED ^= 0x01. Right click and select Set Breakpoint option. 4. Put a break point in code line RGPIO_TOG = 0x0080. The break points should be as the figure shows it. QE128 Quick Reference User Guide, Rev. 1.0 14-4 Freescale Semiconductor...
  • Page 119 6. In the the assembly window the blue squeare shows the instruction that has been executed. The first red arrow is a breakpoint from the Source window and corresponds to the first red arrow from the Assembly window. See next figure. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 14-5...
  • Page 120 Using the Rapid General Purpose I/O (RGPIO) for the MCF51QE128 Microcontrollers Figure 14-4. Step 6 7. Press Ctrl+F11 on the keyboard or click on assembly step button, and observe the executed assembly instruction from each C command line. QE128 Quick Reference User Guide, Rev. 1.0 14-6 Freescale Semiconductor...
  • Page 121 14-5, shows the hardware connections used for the RGPIO project, for detailed information about the MCU hardware needed, please refer to the Pins and Connections chapter in the Reference Manual. It can be found at www.freescale.com. QE128 Quick Reference User Guide, Rev. 1.0 Freescale Semiconductor 14-7...

Table of Contents