MC9S08DN60 MC9S08DN48 MC9S08DN32 MC9S08DN16 Data Sheet HCS08 Microcontrollers MC9S08DN60 Rev 3 6/2008 freescale.
MC9S08DN60 Series Features 8-Bit HCS08 Central Processor Unit (CPU) • 40-MHz HCS08 CPU (20-MHz bus) • HC08 instruction set with added BGND instruction • Support for up to 32 interrupt/reset sources On-Chip Memory • Flash read/program/erase over full operating voltage and temperature — MC9S08DN60 = 60K — MC9S08DN48 = 48K — MC9S08DN32 = 32K — MC9S08DN16 = 16K • Up to 2K EEPROM in-circuit programmable memory; 8-byte single-page or 4-byte dual-page erase sector; Program and Erase while executing Flash; Erase a
MC9S08DN60 Data Sheet Covers MC9S08DN60 MC9S08DN48 MC9S08DN32 MC9S08DN16 MC9S08DN60 Rev 3 6/2008 Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. © Freescale Semiconductor, Inc., 2007-2008. All rights reserved.
Revision History To provide the most up-to-date information, the revision of our documents on the World Wide Web will be the most current. Your printed copy may be an earlier revision. To verify you have the latest information available, refer to: http://freescale.com/ The following revision history table summarizes changes contained in this document. Revision Number Revision Date 1 6/2006 Advance Information version for alpha samples customers 2 9/2007 Product Launch.
List of Chapters Chapter Title Page Chapter 1 Device Overview .............................................................................. 19 Chapter 2 Pins and Connections ..................................................................... 23 Chapter 3 Modes of Operation ......................................................................... 31 Chapter 4 Memory .............................................................................................
Contents Section Number Title Page Chapter 1 Device Overview 1.1 1.2 1.3 Devices in the MC9S08DN60 Series ...............................................................................................19 MCU Block Diagram .......................................................................................................................20 System Clock Distribution ...............................................................................................................
Section Number 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.5.10 4.5.11 Title Page Program and Erase Times .................................................................................................48 Program and Erase Command Execution .........................................................................48 Burst Program Execution ..................................................................................................50 Sector Erase Abort .........................................
Section Number 6.4 6.5 Title Page 6.3.2 Edge and Level Sensitivity ................................................................................................82 6.3.3 Pull-up/Pull-down Resistors .............................................................................................82 6.3.4 Pin Interrupt Initialization .................................................................................................82 Pin Behavior in Stop Modes...................................................
Section Number 8.2 8.3 8.4 8.5 Title Page 8.1.2 Modes of Operation ........................................................................................................133 External Signal Description ...........................................................................................................133 Register Definition .........................................................................................................................134 8.3.1 MCG Control Register 1 (MCGC1) ...........
Section Number Title Page 10.1.7 ADC Module Block Diagram .........................................................................................171 10.2 External Signal Description ...........................................................................................................172 10.2.1 Analog Power (VDDAD) ..................................................................................................173 10.2.2 Analog Ground (VSSAD) .......................................................
Section Number Title Page 11.3 Register Definition .........................................................................................................................196 11.3.1 IIC Address Register (IICA) ...........................................................................................197 11.3.2 IIC Frequency Divider Register (IICF) ...........................................................................197 11.3.3 IIC Control Register (IICC1) ...........................................
Section Number Title Page Chapter 13 Serial Communications Interface (S08SCIV4) 13.1 Introduction ....................................................................................................................................229 13.1.1 Features ...........................................................................................................................231 13.1.2 Modes of Operation ........................................................................................................
Section Number Title Page 15.1.3 Block Diagram ................................................................................................................262 15.2 Signal Description ..........................................................................................................................264 15.2.1 Detailed Signal Descriptions ...........................................................................................264 15.3 Register Definition ........................................
Section Number Title Page Appendix A Electrical Characteristics A.1 A.2 A.3 A.4 A.5 A.6 A.7 A.8 A.9 A.10 A.11 A.12 Introduction ...................................................................................................................................309 Parameter Classification ................................................................................................................309 Absolute Maximum Ratings ...............................................................................
Section Number Title Page B.4.4 PWM End-of-Duty-Cycle Events ...................................................................................344 Appendix C Ordering Information and Mechanical Drawings C.1 Ordering Information ....................................................................................................................345 C.1.1 MC9S08DN60 Series Devices ........................................................................................345 C.2 Mechanical Drawings ...........
Chapter 1 Device Overview Controller Area Network MC9S08DN60 Series devices provide peripheral flexibility and offer a pin and code compatibility with MC9S08DV60 and MC9S08DZ60 Series devices when the CAN module is required. 1.1 Devices in the MC9S08DN60 Series This data sheet covers members of the MC9S08DN60 Series of MCUs: • MC9S08DN60 • MC9S08DN48 • MC9S08DN32 • MC9S08DN16 Table 1-1 summarizes the feature set available in the MC9S08DN60 Series. Table 1-1.
Chapter 1 Device Overview 1.2 MCU Block Diagram PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D Figure 1-1 is the MC9S08DN60 Series system-level block diagram.
Chapter 1 Device Overview Table 1-2 provides the functional version of the on-chip modules. Table 1-2. Module Versions Module Central Processor Unit (CPU) 3 Multi-Purpose Clock Generator (MCG) 1 Analog Comparator (ACMP) 3 Analog-to-Digital Converter (ADC) 1 Inter-Integrated Circuit (IIC) 2 Serial Peripheral Interface (SPI) 3 Serial Communications Interface (SCI) 4 Real-Time Counter (RTC) 1 Timer Pulse Width Modulator (TPM) 31 Debug Module (DBG) 2 1 1.
Chapter 1 Device Overview 1 kHZ LPO RTC COP TPM1CLK TPM2CLK TPM1 TPM2 IIC SCI1 SPI MCGERCLK MCGIRCLK MCG MCGFFCLK ÷2 MCGOUT ÷2 FFCLK* BUSCLK MCGLCLK XOSC CPU EXTAL BDC XTAL * The fixed frequency clock (FFCLK) is internally synchronized to the bus clock and must not exceed one half of the bus clock frequency. ADC ADC has min and max frequency requirements. See the ADC chapter and electricals appendix for details.
Chapter 2 Pins and Connections This section describes signals that connect to package pins. It includes pinout diagrams, recommended system connections, and detailed discussions of signals. 2.
48-Pin LQFP 13 14 15 16 17 18 19 20 21 22 23 24 1 2 3 4 5 6 7 8 9 10 11 12 36 35 34 33 32 31 30 29 28 27 26 25 PTB1/PIB1/ADP9 PTA0/PIA0/ADP0/MCLK PTB0/PIB0/ADP8 BKGD/MS PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 VDD VSS PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTE2/SS PTE3/SPSCK PTE4/SCL/MOSI PTE5/SDA/MISO PTF0 PTF1 PTF2/TPM1CLK/SCL PTF3/TPM2CLK/SDA PTE6 PTE7 PTD0/PID0/TPM2CH0 PTD1/PID1/TPM2CH1 PTB6/PIB6/ADP14 PTA7/PIA7/ADP7/IRQ PTB7/PIB7/ADP15 VDD VSS PTG0/EXTAL PTG1/XTAL RESE
PTA4/PIA4/ADP4 VDDA/VREFH VSSA/VREFL PTA3/ADP3/ACMPO PTA2/ADP2/ACMP- 31 30 29 28 27 26 25 32 PTA7/PIA7/ADP7/IRQ 1 PTA1/ADP1/ACMP+ PTA5/PIA5/ADP5 PTA6/PIA6/ADP6 Chapter 2 Pins and Connections 24 PTB1/PIB1/ADP9 VDD 2 23 PTA0/PIA0/ADP0/MCLK VSS 3 22 PTB0/PIB0/ADP8 PTG0/EXTAL 4 21 BKGD/MS PTG1/XTAL 5 20 PTD5/PID5/TPM1CH3 RESET 6 19 PTD4/PID4/TPM1CH2 PTE0/TxD1 7 18 PTD3/PID3/TPM1CH1 8 10 11 12 13 14 9 PTD0/PID0/TPM2CH0 PTE7 PTE6 PTE5/SDA/MISO PTE4/SCL/MOSI 16 P
Chapter 2 Pins and Connections 2.2 Recommended System Connections Figure 2-4 shows pin connections that are common to MC9S08DN60 Series application systems. VDD + PTA1/PIA1/ADP1/ACMP1+ CBY 0.1 μF CBLK + 10 μF 5V PTA0/PIA0/ADP0/MCLK MC9S08DN60 PTA2/PIA2/ADP2/ACMP1VSS SYSTEM POWER CBY 0.1 μF PORT A VDDA VREFH VREFL VSSA PTA3/PIA3/ADP3/ACMP1O PTA4/PIA4/ADP4 PTA5/PIA5/ADP5 PTA6/PIA6/ADP6 IRQ PTA7/PIA7/ADP7/IRQ PTB0/PIB0/ADP8 PTB1/PIB1/ADP9 BACKGROUND HEADER VDD BKGD/MS VDD PORT B 4.
Chapter 2 Pins and Connections 2.2.1 Power VDD and VSS are the primary power supply pins for the MCU. This voltage source supplies power to all I/O buffer circuitry and to an internal voltage regulator. The internal voltage regulator provides regulated lower-voltage source to the CPU and other internal circuitry of the MCU. Typically, application systems have two separate capacitors across the power pins.
Chapter 2 Pins and Connections Whenever any reset is initiated (whether from an external signal or from an internal system), the RESET pin is driven low for about 34 bus cycles. The reset circuitry decodes the cause of reset and records it by setting a corresponding bit in the system reset status register (SRS). 2.2.4 Background / Mode Select (BKGD/MS) While in reset, the BKGD/MS pin functions as a mode select pin.
Chapter 2 Pins and Connections NOTE To avoid extra current drain from floating input pins, the reset initialization routine in the application program should either enable on-chip pull-up devices or change the direction of unused or non-bonded pins to outputs so they do not float.
Chapter 2 Pins and Connections Table 2-1.
Chapter 3 Modes of Operation 3.1 Introduction The operating modes of the MC9S08DN60 Series are described in this chapter. Entry into each mode, exit from each mode, and functionality while in each of the modes are described. 3.2 • • • 3.
Chapter 3 Modes of Operation Background commands are of two types: • Non-intrusive commands, defined as commands that can be issued while the user program is running. Non-intrusive commands can be issued through the BKGD/MS pin while the MCU is in run mode; non-intrusive commands can also be executed when the MCU is in the active background mode.
Chapter 3 Modes of Operation 3.6 Stop Modes One of two stop modes is entered upon execution of a STOP instruction when the STOPE bit in SOPT1 register is set. In both stop modes, all internal clocks are halted. The MCG module can be configured to leave the reference clocks running. See Chapter 8, “Multi-Purpose Clock Generator (S08MCGV1),” for more information. Table 3-1 shows all of the control bits that affect stop mode selection and the mode selected under various conditions.
Chapter 3 Modes of Operation 3.6.1.2 Active BDM Enabled in Stop3 Mode Entry into the active background mode from run mode is enabled if ENBDM in BDCSCR is set. This register is described in Chapter 16, “Development Support.” If ENBDM is set when the CPU executes a STOP instruction, the system clocks to the background debug logic remain active when the MCU enters stop mode. Because of this, background debug communication remains possible.
Chapter 3 Modes of Operation To maintain I/O states for pins that were configured as general-purpose I/O before entering stop2, the user must restore the contents of the I/O port registers, which have been saved in RAM, to the port registers before writing to the PPDACK bit. If the port registers are not restored from RAM before writing to PPDACK, then the pins will switch to their reset states when PPDACK is written.
Chapter 3 Modes of Operation 5 ERCLKEN and EREFSTEN set in MCGC2 for, else in standby. For high frequency range (RANGE in MCGC2 set) requires the LVD to also be enabled in stop3. 6 If ENBDM is set when entering stop2, the MCU will actually enter stop3. 7 If LVDSE is set when entering stop2, the MCU will actually enter stop3.
Chapter 4 Memory 4.1 MC9S08DN60 Series Memory Map On-chip memory in the MC9S08DN60 Series consists of RAM, EEPROM, and Flash program memory for nonvolatile data storage, and I/O and control/status registers.
Chapter 4 Memory 0x0000 DIRECT PAGE REGISTERS 128 BYTES 0x007F 0x0080 RAM 2048 BYTES 0x0000 DIRECT PAGE REGISTERS 128 BYTES 0x007F 0x0080 RAM 2048 BYTES 0x0000 DIRECT PAGE REGISTERS 128 BYTES 0x007F 0x0080 RAM 1536 BYTES 0x087F 0x0880 0x087F 0x0880 0x067F 0x0680 0x13FF 0x1400 UNIMPLEMENTED 3968 BYTES UNIMPLEMENTED 3200 BYTES FLASH 2944 BYTES 0x14FF 0x1500 EEPROM 2 x 1024 BYTES 0x17FF 0x1800 HIGH PAGE REGISTERS 256 BYTES 0x18FF 0x1900 0x15FF 0x1600 EEPROM 2 x 768 BYTES 0x17FF 0x1800 HIGH PAGE
Chapter 4 Memory Table 4-1.
Chapter 4 Memory 4.3 Register Addresses and Bit Assignments The registers in the MC9S08DN60 Series are divided into these groups: • Direct-page registers are located in the first 128 locations in the memory map; these are accessible with efficient direct addressing mode instructions. • High-page registers are used much less often, so they are located above 0x1800 in the memory map. This leaves more room in the direct page for more frequently used registers and RAM.
Chapter 4 Memory Table 4-2.
Chapter 4 Memory Table 4-2.
Chapter 4 Memory Table 4-2.
Chapter 4 Memory Table 4-3.
Chapter 4 Memory Table 4-3.
Chapter 4 Memory Table 4-4. Nonvolatile Register Summary Address Register Name Bit 7 6 5 4 3 2 1 Bit 0 0xFFAE Reserved for storage of FTRIM 0 0 0 0 0 0 0 FTRIM 0xFFAF Res.
Chapter 4 Memory 4.4 RAM The MC9S08DN60 Series includes static RAM. The locations in RAM below 0x0100 can be accessed using the more efficient direct addressing mode, and any single bit in this area can be accessed with the bit manipulation instructions (BCLR, BSET, BRCLR, and BRSET). Locating the most frequently accessed program variables in this area of RAM is preferred. The RAM retains data while the MCU is in low-power wait, stop2, or stop3 mode. At power-on the contents of RAM are uninitialized.
Chapter 4 Memory • • 4.5.2 Burst programming capability Sector erase abort Program and Erase Times Before any program or erase command can be accepted, the Flash and EEPROM clock divider register (FCDIV) must be written to set the internal clock for the Flash and EEPROM module to a frequency (fFCLK) between 150 kHz and 200 kHz (see Section 4.5.11.1, “Flash and EEPROM Clock Divider Register (FCDIV)”).
Chapter 4 Memory NOTE Before programming a particular byte in the Flash or EEPROM, the sector in which that particular byte resides must be erased by a mass or sector erase operation. Reprogramming bits in an already programmed byte without first performing an erase operation may disturb data stored in the Flash or EEPROM memory. 2. Write the command code for the desired command to FCMD.
Chapter 4 Memory (1) Required only once WRITE TO FCDIV(1) after reset. PROGRAM AND ERASE FLOW START 0 FACCERR? CLEAR ERROR WRITE TO FLASH OR EEPROM TO BUFFER ADDRESS AND DATA WRITE COMMAND TO FCMD WRITE 1 TO FCBEF TO LAUNCH COMMAND AND CLEAR FCBEF (2) FPVIOL OR FACCERR? (2) Wait at least four bus cycles before checking FCBEF or FCCF. YES ERROR EXIT NO 0 FCCF? 1 DONE Figure 4-2. Program and Erase Flowchart 4.5.
Chapter 4 Memory program time provided that the conditions above are met. If the next sequential address is the beginning of a new row, the program time for that byte will be the standard time instead of the burst time. This is because the high voltage to the array must be disabled and then enabled again. If a new burst command has not been queued before the current command completes, then the charge pump will be disabled and high voltage removed from the array.
Chapter 4 Memory 4.5.5 Sector Erase Abort The sector erase abort operation will terminate the active sector erase operation so that other sectors are available for read and program operations without waiting for the sector erase operation to complete. The sector erase abort command write sequence is as follows: 1. Write to any Flash or EEPROM address to start the command write sequence for the sector erase abort command. The address and data written are ignored. 2.
Chapter 4 Memory NOTE The FCBEF flag will not set after launching the sector erase abort command. If an attempt is made to start a new command write sequence with a sector erase abort operation active, the FACCERR flag in the FSTAT register will be set. A new command write sequence may be started after clearing the ACCERR flag, if set. NOTE The sector erase abort command should be used sparingly since a sector erase operation that is aborted counts as a complete program/erase cycle. 4.5.
Chapter 4 Memory 4.5.7 Block Protection The block protection feature prevents the protected region of Flash or EEPROM from program or erase changes. Block protection is controlled through the Flash and EEPROM protection register (FPROT). The EPS bits determine the protected region of EEPROM and the FPS bits determine the protected region of Flash. See Section 4.5.11.4, “Flash and EEPROM Protection Register (FPROT and NVPROT).
Chapter 4 Memory which can be performed at the same time the Flash memory is programmed. The 1:0 state disengages security; the other three combinations engage security. Notice the erased state (1:1) makes the MCU secure. During development, whenever the Flash is erased, it is good practice to immediately program the SEC0 bit to 0 in NVOPT so SEC = 1:0. This would allow the MCU to remain unsecured after a subsequent reset. The on-chip debug module cannot be enabled while the MCU is secure.
Chapter 4 Memory 4.5.10 EEPROM Mapping Only half of the EEPROM is in the memory map. The EPGSEL bit in FCNFG register selects which half of the array can be accessed in foreground while the other half can not be accessed in background. There are two mapping mode options that can be selected to configure the 8-byte EEPROM sectors: 4-byte mode and 8-byte mode. Each mode is selected by the EPGMOD bit in the FOPT register.
Chapter 4 Memory Table 4-6. FCDIV Register Field Descriptions Field Description 7 DIVLD Divisor Loaded Status Flag — When set, this read-only status flag indicates that the FCDIV register has been written since reset. Reset clears this bit and the first write to this register causes this bit to become set regardless of the data written. 0 FCDIV has not been written since reset; erase and program operations disabled for Flash and EEPROM.
Chapter 4 Memory R 7 6 5 4 3 2 KEYEN FNORED EPGMOD 0 0 0 F F F 0 0 0 1 0 SEC W Reset = Unimplemented or Reserved F F F = loaded from nonvolatile location NVOPT during reset Figure 4-6. Flash and EEPROM Options Register (FOPT) Table 4-8. FOPT Register Field Descriptions Field Description 7 KEYEN Backdoor Key Mechanism Enable — When this bit is 0, the backdoor key mechanism cannot be used to disengage security.
Chapter 4 Memory 4.5.11.3 Flash and EEPROM Configuration Register (FCNFG) 7 R 6 5 4 EPGSEL KEYACC Reserved1 0 0 1 0 3 2 1 0 0 0 0 1 0 0 0 1 W Reset 0 = Unimplemented or Reserved Figure 4-7. Flash Configuration Register (FCNFG) 1 User must write a 1 to this bit. Failing to do so may result in unexpected behavior. Table 4-10. FCNFG Register Field Descriptions Field Description 6 EPGSEL EEPROM Page Select — This bit selects which EEPROM page is accessed in the memory map.
Chapter 4 Memory Table 4-11. FPROT Register Field Descriptions Field Description 7:6 EPS EEPROM Protect Select Bits — This 2-bit field determines the protected EEPROM locations that cannot be erased or programmed. See Table 4-12. 5:0 FPS Flash Protect Select Bits — This 6-bit field determines the protected Flash locations that cannot be erased or programmed. SeeTable 4-13. Table 4-12.
Chapter 4 Memory Table 4-13. Flash Block Protection (continued) FPS Address Area Protected Memory Size Protected (bytes) Number of Sectors Protected 0x1B 0x2800–0xFFFF 54K 72 0x1A 0x2200–0xFFFF 55.5K 74 0x19 0x1C00–0xFFFF 57K 76 0x18–0x00 0x0000–0xFFFF 64K 86 4.5.11.5 Flash and EEPROM Status Register (FSTAT) 7 6 R 5 4 FPVIOL FACCERR 0 0 FCCF FCBEF 3 2 1 0 0 FBLANK 0 0 0 0 0 0 W Reset 1 1 = Unimplemented or Reserved Figure 4-9.
Chapter 4 Memory Table 4-14. FSTAT Register Field Descriptions (continued) Field Description 4 FACCERR Access Error Flag — FACCERR is set automatically when the proper command sequence is not obeyed exactly (the erroneous command is ignored), if a program or erase operation is attempted before the FCDIV register has been initialized, or if the MCU enters stop while a command was in progress. For a more detailed discussion of the exact actions that are considered access errors, see Section 4.5.
Chapter 5 Resets, Interrupts, and General System Control 5.1 Introduction This section discusses basic reset and interrupt mechanisms and their various sources in the MC9S08DN60 Series. Some interrupt sources from peripheral modules are discussed in greater detail within other sections of this data sheet. This section gathers basic information about all reset and interrupt sources in one place for easy reference.
Chapter 5 Resets, Interrupts, and General System Control 5.4 Computer Operating Properly (COP) Watchdog The COP watchdog is intended to force a system reset when the application software fails to execute as expected. To prevent a system reset from the COP timer (when it is enabled), application software must reset the COP counter periodically.
Chapter 5 Resets, Interrupts, and General System Control 5.5 Interrupts Interrupts provide a way to save the current CPU status and registers, execute an interrupt service routine (ISR), and then restore the CPU status so processing resumes where it left off before the interrupt. Other than the software interrupt (SWI), which is a program instruction, interrupts are caused by hardware events such as an edge on the IRQ pin or a timer-overflow event.
Chapter 5 Resets, Interrupts, and General System Control 5.5.1 Interrupt Stack Frame Figure 5-1 shows the contents and organization of a stack frame. Before the interrupt, the stack pointer (SP) points at the next available byte location on the stack. The current values of CPU registers are stored on the stack starting with the low-order byte of the program counter (PCL) and ending with the CCR.
Chapter 5 Resets, Interrupts, and General System Control The IRQ pin, when enabled, defaults to use an internal pull device (IRQPDD = 0), the device is a pull-up or pull-down depending on the polarity chosen. If the user desires to use an external pull-up or pull-down, the IRQPDD can be written to a 1 to turn off the internal device. BIH and BIL instructions may be used to detect the level on the IRQ pin when the pin is configured to act as the IRQ input. 5.5.2.
Chapter 5 Resets, Interrupts, and General System Control Table 5-1. Vector Summary1 Vector No.
Chapter 5 Resets, Interrupts, and General System Control comprised of a power-on reset (POR) circuit and a LVD circuit with trip voltages for warning and detection. The LVD circuit is enabled when LVDE in SPMSC1 is set to 1. The LVD is disabled upon entering any of the stop modes unless LVDSE is set in SPMSC1. If LVDSE and LVDE are both set, then the MCU cannot enter stop2 (it will enter stop3 instead), and the current consumption in stop3 with the LVD enabled will be higher. 5.6.
Chapter 5 Resets, Interrupts, and General System Control 5.8 Reset, Interrupt, and System Control Registers and Control Bits One 8-bit register in the direct page register space and eight 8-bit registers in the high-page register space are related to reset and interrupt systems. Refer to Table 4-2 and Table 4-3 in Chapter 4, “Memory,” of this data sheet for the absolute address assignments for all registers. This section refers to registers and control bits only by their names.
Chapter 5 Resets, Interrupts, and General System Control 5.8.1 Interrupt Pin Request Status and Control Register (IRQSC) This direct page register includes status and control bits which are used to configure the IRQ function, report status, and acknowledge IRQ events. 7 R 6 5 4 IRQPDD IRQEDG IRQPE 0 3 2 IRQF 0 W Reset 1 0 IRQIE IRQMOD 0 0 IRQACK 0 0 0 0 0 0 = Unimplemented or Reserved Figure 5-2. Interrupt Request Status and Control Register (IRQSC) Table 5-2.
Chapter 5 Resets, Interrupts, and General System Control 5.8.2 System Reset Status Register (SRS) This high page register includes read-only status flags to indicate the source of the most recent reset. When a debug host forces reset by writing 1 to BDFR in the SBDFR register, none of the status bits in SRS will be set. Writing any value to this register address causes a COP reset when the COP is enabled except the values 0x55 and 0xAA.
Chapter 5 Resets, Interrupts, and General System Control Table 5-3. SRS Register Field Descriptions Field Description 2 LOC Loss of Clock — Reset was caused by a loss of external clock. 0 Reset not caused by loss of external clock 1 Reset caused by loss of external clock 1 LVD Low-Voltage Detect — If the LVDRE bit is set and the supply drops below the LVD trip voltage, an LVD reset will occur. This bit is also set by POR. 0 Reset not caused by LVD trip or POR. 1 Reset caused by LVD trip or POR. 5.8.
Chapter 5 Resets, Interrupts, and General System Control 5.8.4 System Options Register 1 (SOPT1) This high page register is a write-once register so only the first write after reset is honored. It can be read at any time. Any subsequent attempt to write to SOPT1 (intentionally or unintentionally) is ignored to avoid accidental changes to these sensitive settings.
Chapter 5 Resets, Interrupts, and General System Control 5.8.5 System Options Register 2 (SOPT2) This high page register contains bits to configure MCU specific features on the MC9S08DN60 Series devices. R 7 6 5 COPCLKS1 COPW1 0 0 4 3 0 2 1 0 0 ADHTS MCSEL W Reset: 0 0 0 0 0 0 = Unimplemented or Reserved Figure 5-6. System Options Register 2 (SOPT2) 1 This bit can be written only one time after reset. Additional writes are ignored. Table 5-7.
Chapter 5 Resets, Interrupts, and General System Control 5.8.6 System Device Identification Register (SDIDH, SDIDL) These high page read-only registers are included so host development systems can identify the HCS08 derivative and revision number. This allows the development software to recognize where specific memory blocks, registers, and control bits are located in a target MCU.
Chapter 5 Resets, Interrupts, and General System Control 5.8.7 System Power Management Status and Control 1 Register (SPMSC1) This high page register contains status and control bits to support the low-voltage detect function, and to enable the bandgap voltage reference for use by the ADC and ACMP modules. This register should be written during the user’s reset initialization program to set the desired controls even if the desired settings are the same as the reset settings.
Chapter 5 Resets, Interrupts, and General System Control 5.8.8 System Power Management Status and Control 2 Register (SPMSC2) This register is used to report the status of the low-voltage warning function, and to configure the stop mode behavior of the MCU. This register should be written during the user’s reset initialization program to set the desired controls even if the desired settings are the same as the reset settings.
Chapter 6 Parallel Input/Output Control This section explains software controls related to parallel input/output (I/O) and pin control. The MC9S08DN60 Series has seven parallel I/O ports which include a total of up to 53 I/O pins and one input-only pin. See Chapter 2, “Pins and Connections,” for more information about pin assignments and external hardware considerations of these pins.
Chapter 6 Parallel Input/Output Control In general, whenever a pin is shared with both an alternate digital function and an analog function, the analog function has priority such that if both the digital and analog functions are enabled, the analog function controls the pin. It is a good programming practice to write to the port data register before changing the direction of a port pin to become an output.
Chapter 6 Parallel Input/Output Control An output pin can be selected to have high output drive strength by setting the corresponding bit in the drive strength select register (PTxDSn). When high drive is selected, a pin is capable of sourcing and sinking greater current. Even though every I/O pin can be selected as high drive, the user must ensure that the total current source and sink limits for the MCU are not exceeded. Drive strength selection is intended to affect the DC behavior of I/O pins.
Chapter 6 Parallel Input/Output Control 6.3.2 Edge and Level Sensitivity A valid edge or level on an enabled port pin will set PTxIF in PTxSC. If PTxIE in PTxSC is set, an interrupt request will be presented to the CPU. Clearing of PTxIF is accomplished by writing a 1 to PTxACK in PTxSC provided all enabled port inputs are at their deasserted levels. PTxIF will remain set if any enabled port pin is asserted while attempting to clear by writing a 1 to PTxACK. 6.3.
Chapter 6 Parallel Input/Output Control 6.5 Parallel I/O and Pin Control Registers This section provides information about the registers associated with the parallel I/O ports. The data and data direction registers are located in page zero of the memory map. The pull up, slew rate, drive strength, and interrupt control registers are located in the high page section of the memory map.
Chapter 6 Parallel Input/Output Control 6.5.1 Port A Registers Port A is controlled by the registers listed below. 6.5.1.1 Port A Data Register (PTAD) 7 6 5 4 3 2 1 0 PTAD7 PTAD6 PTAD5 PTAD4 PTAD3 PTAD2 PTAD1 PTAD0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-3. Port A Data Register (PTAD) Table 6-1. PTAD Register Field Descriptions Field Description 7:0 PTAD[7:0] Port A Data Register Bits — For port A pins that are inputs, reads return the logic level on the pin.
Chapter 6 Parallel Input/Output Control 6.5.1.3 Port A Pull Enable Register (PTAPE) 7 6 5 4 3 2 1 0 PTAPE7 PTAPE6 PTAPE5 PTAPE4 PTAPE3 PTAPE2 PTAPE1 PTAPE0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-5. Internal Pull Enable for Port A Register (PTAPE) Table 6-3. PTAPE Register Field Descriptions Field Description 7:0 Internal Pull Enable for Port A Bits — Each of these control bits determines if the internal pull-up or pull-down PTAPE[7:0] device is enabled for the associated PTA pin.
Chapter 6 Parallel Input/Output Control 6.5.1.5 Port A Drive Strength Selection Register (PTADS) 7 6 5 4 3 2 1 0 PTADS7 PTADS6 PTADS5 PTADS4 PTADS3 PTADS2 PTADS1 PTADS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-7. Drive Strength Selection for Port A Register (PTADS) Table 6-5.
Chapter 6 Parallel Input/Output Control 6.5.1.7 Port A Interrupt Pin Select Register (PTAPS) 7 6 5 4 3 2 1 0 PTAPS7 PTAPS6 PTAPS5 PTAPS4 PTAPS3 PTAPS2 PTAPS1 PTAPS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-9. Port A Interrupt Pin Select Register (PTAPS) Table 6-7. PTAPS Register Field Descriptions Field Description 7:0 Port A Interrupt Pin Selects — Each of the PTAPSn bits enable the corresponding port A interrupt pin. PTAPS[7:0] 0 Pin not enabled as interrupt.
Chapter 6 Parallel Input/Output Control 6.5.2 Port B Registers Port B is controlled by the registers listed below. 6.5.2.1 Port B Data Register (PTBD) 7 6 5 4 3 2 1 0 PTBD7 PTBD6 PTBD5 PTBD4 PTBD3 PTBD2 PTBD1 PTBD0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-11. Port B Data Register (PTBD) Table 6-9. PTBD Register Field Descriptions Field Description 7:0 PTBD[7:0] Port B Data Register Bits — For port B pins that are inputs, reads return the logic level on the pin.
Chapter 6 Parallel Input/Output Control 6.5.2.3 Port B Pull Enable Register (PTBPE) 7 6 5 4 3 2 1 0 PTBPE7 PTBPE6 PTBPE5 PTBPE4 PTBPE3 PTBPE2 PTBPE1 PTBPE0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-13. Internal Pull Enable for Port B Register (PTBPE) Table 6-11. PTBPE Register Field Descriptions Field Description 7:0 Internal Pull Enable for Port B Bits — Each of these control bits determines if the internal pull-up or pull-down PTBPE[7:0] device is enabled for the associated PTB pin.
Chapter 6 Parallel Input/Output Control 6.5.2.5 Port B Drive Strength Selection Register (PTBDS) 7 6 5 4 3 2 1 0 PTBDS7 PTBDS6 PTBDS5 PTBDS4 PTBDS3 PTBDS2 PTBDS1 PTBDS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-15. Drive Strength Selection for Port B Register (PTBDS) Table 6-13.
Chapter 6 Parallel Input/Output Control 6.5.2.7 Port B Interrupt Pin Select Register (PTBPS) 7 6 5 4 3 2 1 0 PTBPS7 PTBPS6 PTBPS5 PTBPS4 PTBPS3 PTBPS2 PTBPS1 PTBPS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-17. Port B Interrupt Pin Select Register (PTBPS) Table 6-15. PTBPS Register Field Descriptions Field Description 7:0 Port B Interrupt Pin Selects — Each of the PTBPSn bits enable the corresponding port B interrupt pin. PTBPS[7:0] 0 Pin not enabled as interrupt.
Chapter 6 Parallel Input/Output Control 6.5.3 Port C Registers Port C is controlled by the registers listed below. 6.5.3.1 Port C Data Register (PTCD) 7 6 5 4 3 2 1 0 PTCD7 PTCD6 PTCD5 PTCD4 PTCD3 PTCD2 PTCD1 PTCD0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-19. Port C Data Register (PTCD) Table 6-17. PTCD Register Field Descriptions Field Description 7:0 PTCD[7:0] Port C Data Register Bits — For port C pins that are inputs, reads return the logic level on the pin.
Chapter 6 Parallel Input/Output Control 6.5.3.3 Port C Pull Enable Register (PTCPE) 7 6 5 4 3 2 1 0 PTCPE7 PTCPE6 PTCPE5 PTCPE4 PTCPE3 PTCPE2 PTCPE1 PTCPE0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-21. Internal Pull Enable for Port C Register (PTCPE) Table 6-19. PTCPE Register Field Descriptions Field Description 7:0 Internal Pull Enable for Port C Bits — Each of these control bits determines if the internal pull-up device is PTCPE[7:0] enabled for the associated PTC pin.
Chapter 6 Parallel Input/Output Control 6.5.3.5 Port C Drive Strength Selection Register (PTCDS) 7 6 5 4 3 2 1 0 PTCDS7 PTCDS6 PTCDS5 PTCDS4 PTCDS3 PTCDS2 PTCDS1 PTCDS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-23. Drive Strength Selection for Port C Register (PTCDS) Table 6-21.
Chapter 6 Parallel Input/Output Control 6.5.4 Port D Registers Port D is controlled by the registers listed below. 6.5.4.1 Port D Data Register (PTDD) 7 6 5 4 3 2 1 0 PTDD7 PTDD6 PTDD5 PTDD4 PTDD3 PTDD2 PTDD1 PTDD0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-24. Port D Data Register (PTDD) Table 6-22. PTDD Register Field Descriptions Field Description 7:0 PTDD[7:0] Port D Data Register Bits — For port D pins that are inputs, reads return the logic level on the pin.
Chapter 6 Parallel Input/Output Control 6.5.4.3 Port D Pull Enable Register (PTDPE) 7 6 5 4 3 2 1 0 PTDPE7 PTDPE6 PTDPE5 PTDPE4 PTDPE3 PTDPE2 PTDPE1 PTDPE0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-26. Internal Pull Enable for Port D Register (PTDPE) Table 6-24. PTDPE Register Field Descriptions Field Description 7:0 Internal Pull Enable for Port D Bits — Each of these control bits determines if the internal pull-up or pull-down PTDPE[7:0] device is enabled for the associated PTD pin.
Chapter 6 Parallel Input/Output Control 6.5.4.5 Port D Drive Strength Selection Register (PTDDS) 7 6 5 4 3 2 1 0 PTDDS7 PTDDS6 PTDDS5 PTDDS4 PTDDS3 PTDDS2 PTDDS1 PTDDS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-28. Drive Strength Selection for Port D Register (PTDDS) Table 6-26.
Chapter 6 Parallel Input/Output Control 6.5.4.7 Port D Interrupt Pin Select Register (PTDPS) 7 6 5 4 3 2 1 0 PTDPS7 PTDPS6 PTDPS5 PTDPS4 PTDPS3 PTDPS2 PTDPS1 PTDPS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-30. Port D Interrupt Pin Select Register (PTDPS) Table 6-28. PTDPS Register Field Descriptions Field Description 7:0 Port D Interrupt Pin Selects — Each of the PTDPSn bits enable the corresponding port D interrupt pin. PTDPS[7:0] 0 Pin not enabled as interrupt.
Chapter 6 Parallel Input/Output Control 6.5.5 Port E Registers Port E is controlled by the registers listed below. 6.5.5.1 Port E Data Register (PTED) 7 6 5 4 3 2 1 0 PTED7 PTED6 PTED5 PTED4 PTED3 PTED2 PTED11 PTED0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-32. Port E Data Register (PTED) 1 Reads of this bit always return the pin value of the associated pin, regardless of the value stored in the port data direction bit. Table 6-30.
Chapter 6 Parallel Input/Output Control 6.5.5.3 Port E Pull Enable Register (PTEPE) 7 6 5 4 3 2 1 0 PTEPE7 PTEPE6 PTEPE5 PTEPE4 PTEPE3 PTEPE2 PTEPE1 PTEPE0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-34. Internal Pull Enable for Port E Register (PTEPE) Table 6-32. PTEPE Register Field Descriptions Field Description 7:0 Internal Pull Enable for Port E Bits — Each of these control bits determines if the internal pull-up device is PTEPE[7:0] enabled for the associated PTE pin.
Chapter 6 Parallel Input/Output Control 6.5.5.5 Port E Drive Strength Selection Register (PTEDS) 7 6 5 4 3 2 1 0 PTEDS7 PTEDS6 PTEDS5 PTEDS4 PTEDS3 PTEDS2 PTEDS11 PTEDS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-36. Drive Strength Selection for Port E Register (PTEDS) 1 PTEDS1 has no effect on the input-only PTE1 pin. Table 6-34.
Chapter 6 Parallel Input/Output Control 6.5.6 Port F Registers Port F is controlled by the registers listed below. 6.5.6.1 Port F Data Register (PTFD) 7 6 5 4 3 2 1 0 PTFD7 PTFD6 PTFD5 PTFD4 PTFD3 PTFD2 PTFD1 PTFD0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-37. Port F Data Register (PTFD) Table 6-35. PTFD Register Field Descriptions Field Description 7:0 PTFD[7:0] Port F Data Register Bits — For port F pins that are inputs, reads return the logic level on the pin.
Chapter 6 Parallel Input/Output Control 6.5.6.3 Port F Pull Enable Register (PTFPE) 7 6 5 4 3 2 1 0 PTFPE7 PTFPE6 PTFPE5 PTFPE4 PTFPE3 PTFPE2 PTFPE1 PTFPE0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-39. Internal Pull Enable for Port F Register (PTFPE) Table 6-37. PTFPE Register Field Descriptions Field Description 7:0 Internal Pull Enable for Port F Bits — Each of these control bits determines if the internal pull-up device is PTFPE[7:0] enabled for the associated PTF pin.
Chapter 6 Parallel Input/Output Control 6.5.6.5 Port F Drive Strength Selection Register (PTFDS) 7 6 5 4 3 2 1 0 PTFDS7 PTFDS6 PTFDS5 PTFDS4 PTFDS3 PTFDS2 PTFDS1 PTFDS0 0 0 0 0 0 0 0 0 R W Reset: Figure 6-41. Drive Strength Selection for Port F Register (PTFDS) Table 6-39.
Chapter 6 Parallel Input/Output Control 6.5.7 Port G Registers Port G is controlled by the registers listed below. 6.5.7.1 R Port G Data Register (PTGD) 7 6 0 0 5 4 3 2 1 0 PTGD5 PTGD4 PTGD3 PTGD2 PTGD1 PTGD0 0 0 0 0 0 0 W Reset: 0 0 = Unimplemented or Reserved Figure 6-42. Port G Data Register (PTGD) Table 6-40.
Chapter 6 Parallel Input/Output Control 6.5.7.3 R Port G Pull Enable Register (PTGPE) 7 6 0 0 5 4 3 2 1 0 PTGPE5 PTGPE4 PTGPE3 PTGPE2 PTGPE1 PTGPE0 0 0 0 0 0 0 W Reset: 0 0 = Unimplemented or Reserved Figure 6-44. Internal Pull Enable for Port G Register (PTGPE) Table 6-42.
Chapter 6 Parallel Input/Output Control 6.5.7.5 R Port G Drive Strength Selection Register (PTGDS) 7 6 0 0 5 4 3 2 1 0 PTGDS5 PTGDS4 PTGDS3 PTGDS2 PTGDS1 PTGDS0 0 0 0 0 0 0 W Reset: 0 0 = Unimplemented or Reserved Figure 6-46. Drive Strength Selection for Port G Register (PTGDS) Table 6-44.
Chapter 6 Parallel Input/Output Control MC9S08DN60 Series Data Sheet, Rev 3 108 Freescale Semiconductor
Chapter 7 Central Processor Unit (S08CPUV3) 7.1 Introduction This section provides summary information about the registers, addressing modes, and instruction set of the CPU of the HCS08 Family. For a more detailed discussion, refer to the HCS08 Family Reference Manual, volume 1, Freescale Semiconductor document order number HCS08RMV1/D. The HCS08 CPU is fully source- and object-code-compatible with the M68HC08 CPU.
Chapter 7 Central Processor Unit (S08CPUV3) 7.2 Programmer’s Model and CPU Registers Figure 7-1 shows the five CPU registers. CPU registers are not part of the memory map. 7 0 ACCUMULATOR A 16-BIT INDEX REGISTER H:X H INDEX REGISTER (HIGH) 8 15 INDEX REGISTER (LOW) 7 X 0 SP STACK POINTER 0 15 PROGRAM COUNTER 7 0 CONDITION CODE REGISTER V 1 1 H I N Z C PC CCR CARRY ZERO NEGATIVE INTERRUPT MASK HALF-CARRY (FROM BIT 3) TWO’S COMPLEMENT OVERFLOW Figure 7-1. CPU Registers 7.2.
Chapter 7 Central Processor Unit (S08CPUV3) 7.2.3 Stack Pointer (SP) This 16-bit address pointer register points at the next available location on the automatic last-in-first-out (LIFO) stack. The stack may be located anywhere in the 64-Kbyte address space that has RAM and can be any size up to the amount of available RAM. The stack is used to automatically save the return address for subroutine calls, the return address and CPU registers during interrupts, and for local variables.
Chapter 7 Central Processor Unit (S08CPUV3) 7 0 CONDITION CODE REGISTER V 1 1 H I N Z C CCR CARRY ZERO NEGATIVE INTERRUPT MASK HALF-CARRY (FROM BIT 3) TWO’S COMPLEMENT OVERFLOW Figure 7-2. Condition Code Register Table 7-1. CCR Register Field Descriptions Field Description 7 V Two’s Complement Overflow Flag — The CPU sets the overflow flag when a two’s complement overflow occurs. The signed branch instructions BGT, BGE, BLE, and BLT use the overflow flag.
Chapter 7 Central Processor Unit (S08CPUV3) 7.3 Addressing Modes Addressing modes define the way the CPU accesses operands and data. In the HCS08, all memory, status and control registers, and input/output (I/O) ports share a single 64-Kbyte linear address space so a 16-bit binary address can uniquely identify any memory location. This arrangement means that the same instructions that access variables in RAM can also be used to access I/O and control registers or nonvolatile program space.
Chapter 7 Central Processor Unit (S08CPUV3) 7.3.5 Extended Addressing Mode (EXT) In extended addressing mode, the full 16-bit address of the operand is located in the next two bytes of program memory after the opcode (high byte first). 7.3.6 Indexed Addressing Mode Indexed addressing mode has seven variations including five that use the 16-bit H:X index register pair and two that use the stack pointer as the base reference. 7.3.6.
Chapter 7 Central Processor Unit (S08CPUV3) 7.3.6.7 SP-Relative, 16-Bit Offset (SP2) This variation of indexed addressing uses the 16-bit value in the stack pointer (SP) plus a 16-bit offset included in the instruction as the address of the operand needed to complete the instruction. 7.4 Special Operations The CPU performs a few special operations that are similar to instructions but do not have opcodes like other CPU instructions.
Chapter 7 Central Processor Unit (S08CPUV3) interrupt service routine, this would allow nesting of interrupts (which is not recommended because it leads to programs that are difficult to debug and maintain). For compatibility with the earlier M68HC05 MCUs, the high-order half of the H:X index register pair (H) is not saved on the stack as part of the interrupt sequence.
Chapter 7 Central Processor Unit (S08CPUV3) 7.4.5 BGND Instruction The BGND instruction is new to the HCS08 compared to the M68HC08. BGND would not be used in normal user programs because it forces the CPU to stop processing user instructions and enter the active background mode. The only way to resume execution of the user program is through reset or by a host debug system issuing a GO, TRACE1, or TAGGO serial command through the background debug interface.
Chapter 7 Central Processor Unit (S08CPUV3) 7.5 HCS08 Instruction Set Summary Table 7-2 provides a summary of the HCS08 instruction set in all possible addressing modes. The table shows operand construction, execution time in internal bus clock cycles, and cycle-by-cycle details for each addressing mode variation of each instruction.
Chapter 7 Central Processor Unit (S08CPUV3) Operation Object Code Cycles Source Form Address Mode Table 7-2.
Chapter 7 Central Processor Unit (S08CPUV3) Operation Object Code Cycles Source Form Address Mode Table 7-2.
Chapter 7 Central Processor Unit (S08CPUV3) CMP CMP CMP CMP CMP CMP CMP CMP #opr8i opr8a opr16a oprx16,X oprx8,X ,X oprx16,SP oprx8,SP Operation Compare Accumulator with Memory A–M (CCR Updated But Operands Not Changed) Object Code IMM DIR EXT IX2 IX1 IX SP2 SP1 A1 B1 C1 D1 E1 F1 9E D1 9E E1 ii dd hh ll ee ff ff ee ff ff Cycles Source Form Address Mode Table 7-2.
Chapter 7 Central Processor Unit (S08CPUV3) INC opr8a INCA INCX INC oprx8,X INC ,X INC oprx8,SP Operation Increment M ← (M) + $01 A ← (A) + $01 X ← (X) + $01 M ← (M) + $01 M ← (M) + $01 M ← (M) + $01 Object Code Cycles Source Form Address Mode Table 7-2.
Chapter 7 Central Processor Unit (S08CPUV3) Operation Object Code MOV opr8a,opr8a MOV opr8a,X+ MOV #opr8i,opr8a MOV ,X+,opr8a Move (M)destination ← (M)source In IX+/DIR and DIR/IX+ Modes, H:X ← (H:X) + $0001 DIR/DIR DIR/IX+ IMM/DIR IX+/DIR 4E 5E 6E 7E MUL Unsigned multiply X:A ← (X) × (A) INH NEG opr8a NEGA NEGX NEG oprx8,X NEG ,X NEG oprx8,SP Negate M ← – (M) = $00 – (M) (Two’s Complement) A ← – (A) = $00 – (A) X ← – (X) = $00 – (X) M ← – (M) = $00 – (M) M ← – (M) = $00 – (M) M ← – (M) = $00 – (
Chapter 7 Central Processor Unit (S08CPUV3) Operation Object Code Cycles Source Form Address Mode Table 7-2.
Chapter 7 Central Processor Unit (S08CPUV3) SUB SUB SUB SUB SUB SUB SUB SUB #opr8i opr8a opr16a oprx16,X oprx8,X ,X oprx16,SP oprx8,SP Operation Object Code IMM DIR EXT IX2 IX1 IX SP2 SP1 A0 B0 C0 D0 E0 F0 9E D0 9E E0 SWI Software Interrupt PC ← (PC) + $0001 Push (PCL); SP ← (SP) – $0001 Push (PCH); SP ← (SP) – $0001 Push (X); SP ← (SP) – $0001 Push (A); SP ← (SP) – $0001 Push (CCR); SP ← (SP) – $0001 I ← 1; PCH ← Interrupt Vector High Byte PCL ← Interrupt Vector Low Byte INH TAP Transfer Accumul
Chapter 7 Central Processor Unit (S08CPUV3) Operation Object Code Cycles Source Form Address Mode Table 7-2. Instruction Set Summary (Sheet 9 of 9) Affect on CCR Cyc-by-Cyc Details V11H INZC TXS Transfer Index Reg. to SP SP ← (H:X) – $0001 INH 94 2 fp – 1 1 – – – – – WAIT Enable Interrupts; Wait for Interrupt I bit ← 0; Halt CPU INH 8F 2+ fp...
Chapter 7 Central Processor Unit (S08CPUV3) Table 7-3.
Chapter 7 Central Processor Unit (S08CPUV3) Table 7-3.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.1 Introduction The multi-purpose clock generator (MCG) module provides several clock source choices for the MCU. The module contains a frequency-locked loop (FLL) and a phase-locked loop (PLL) that are controllable by either an internal or an external reference clock. The module can select either of the FLL or PLL clocks, or either of the internal or external reference clocks as a source for the MCU system clock.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.1.1 Features Key features of the MCG module are: • Frequency-locked loop (FLL) — 0.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) External Oscillator (XOSC) RANGE EREFS ERCLKEN MCGERCLK HGO EREFSTEN IRCLKEN MCGIRCLK CME IREFSTEN CLKS Clock Monitor LOC BDIV / 2n Internal Reference Clock OSCINIT 9 IREFS MCGOUT n=0-3 LP DCO DCOOUT TRIM PLLS / 2n RDIV_CLK Lock Detector Filter n=0-7 FLL RDIV LOLS LOCK MCGFFCLK MCGFFCLKVALID MCGLCLK LP VCOOUT Phase Detector Charge Pump VDIV Internal Filter /2 VCO PLL /(4,8,12,...
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.1.2 Modes of Operation There are nine modes of operation for the MCG: • FLL Engaged Internal (FEI) • FLL Engaged External (FEE) • FLL Bypassed Internal (FBI) • FLL Bypassed External (FBE) • PLL Engaged External (PEE) • PLL Bypassed External (PBE) • Bypassed Low Power Internal (BLPI) • Bypassed Low Power External (BLPE) • Stop For details see Section 8.4.1, “Operational Modes. 8.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.3 Register Definition 8.3.1 MCG Control Register 1 (MCGC1) 7 6 5 4 3 2 1 0 IREFS IRCLKEN IREFSTEN 1 0 0 R CLKS RDIV W Reset: 0 0 0 0 0 Figure 8-3. MCG Control Register 1 (MCGC1) Table 8-1. MCG Control Register 1 Field Descriptions Field Description 7:6 CLKS Clock Source Select — Selects the system clock source. 00 Encoding 0 — Output of FLL or PLL is selected. 01 Encoding 1 — Internal reference clock is selected.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.3.2 MCG Control Register 2 (MCGC2) 7 6 5 4 3 2 RANGE HGO LP EREFS 0 0 0 0 1 0 R BDIV ERCLKEN EREFSTEN W Reset: 0 1 0 0 Figure 8-4. MCG Control Register 2 (MCGC2) Table 8-2. MCG Control Register 2 Field Descriptions Field Description 7:6 BDIV Bus Frequency Divider — Selects the amount to divide down the clock source selected by the CLKS bits in the MCGC1 register. This controls the bus frequency.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.3.3 MCG Trim Register (MCGTRM) 7 6 5 4 3 2 1 0 R TRIM W POR: 1 0 0 0 0 0 0 0 Reset: U U U U U U U U Figure 8-5. MCG Trim Register (MCGTRM) Table 8-3. MCG Trim Register Field Descriptions Field Description 7:0 TRIM MCG Trim Setting — Controls the internal reference clock frequency by controlling the internal reference clock period. The TRIM bits are binary weighted (i.e., bit 1 will adjust twice as much as bit 0).
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.3.4 MCG Status and Control Register (MCGSC) R 7 6 5 4 3 LOLS LOCK PLLST IREFST 2 CLKST 1 0 OSCINIT FTRIM W POR: Reset: 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 U Figure 8-6. MCG Status and Control Register (MCGSC) Table 8-4. MCG Status and Control Register Field Descriptions Field Description 7 LOLS Loss of Lock Status — This bit is a sticky indication of lock status for the FLL or PLL.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) Table 8-4. MCG Status and Control Register Field Descriptions (continued) Field Description 1 OSCINIT OSC Initialization — If the external reference clock is selected by ERCLKEN or by the MCG being in FEE, FBE, PEE, PBE, or BLPE mode, and if EREFS is set, then this bit is set after the initialization cycles of the external oscillator clock have completed.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) Table 8-5. MCG PLL Register Field Descriptions (continued) Field Description 5 CME Clock Monitor Enable — Determines if a reset request is made following a loss of external clock indication. The CME bit should only be set to a logic 1 when either the MCG is in an operational mode that uses the external clock (FEE, FBE, PEE, PBE, or BLPE) or the external reference is enabled (ERCLKEN=1 in the MCGC2 register).
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.4 Functional Description 8.4.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) The nine states of the MCG are shown as a state diagram and are described below. The arrows indicate the allowed movements between the states. 8.4.1.1 FLL Engaged Internal (FEI) FLL engaged internal (FEI) is the default mode of operation and is entered when all the following conditions occur: • CLKS bits are written to 00 • IREFS bit is written to 1 • PLLS bit is written to 0 • RDIV bits are written to 000.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) • LP bit is written to 0 In FLL bypassed internal mode, the MCGOUT clock is derived from the internal reference clock. The FLL clock is controlled by the internal reference clock, and the FLL clock frequency locks to 1024 times the reference frequency, as selected by the RDIV bits. The MCGLCLK is derived from the FLL and the PLL is disabled in a low power state. 8.4.1.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) multiplication factor, as selected by the VDIV bits, times the reference frequency, as selected by the RDIV bits. If BDM is enabled then the MCGLCLK is derived from the DCO (open-loop mode) divided by two. If BDM is not enabled then the FLL is disabled in a low power state. 8.4.1.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) • • LP bit is written to 1 BDM mode is not active In bypassed low power external mode, the MCGOUT clock is derived from the external reference clock. The external reference clock which is enabled can be an external crystal/resonator or it can be another external clock source. The PLL and the FLL are disabled at all times in BLPE mode and the MCGLCLK will not be available for BDC communications.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.4.3 Bus Frequency Divider The BDIV bits can be changed at anytime and the actual switch to the new frequency will occur immediately. 8.4.4 Low Power Bit Usage The low power bit (LP) is provided to allow the FLL or PLL to be disabled and thus conserve power when these systems are not being used. However, in some applications it may be desirable to enable the FLL or PLL and allow it to lock for maximum accuracy before switching to an engaged mode.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.4.7 Fixed Frequency Clock The MCG presents the divided reference clock as MCGFFCLK for use as an additional clock source. The MCGFFCLK frequency must be no more than 1/4 of the MCGOUT frequency to be valid.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) — If entering FEE, set RDIV appropriately, clear the IREFS bit to switch to the external reference, and leave the CLKS bits at %00 so that the output of the FLL is selected as the system clock source. — If entering FBE, clear the IREFS bit to switch to the external reference and change the CLKS bits to %10 so that the external reference clock is selected as the system clock source.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) The table below shows MCGOUT frequency calculations using RDIV, BDIV, and VDIV settings for each clock mode. The bus frequency is equal to MCGOUT divided by 2. Table 8-6. MCGOUT Frequency Calculation Options fMCGOUT1 Clock Mode Note FEI (FLL engaged internal) (fint * 1024) / B Typical fMCGOUT = 16 MHz immediately after reset. RDIV bits set to %000. FEE (FLL engaged external) (fext / R *1024) / B fext / R must be in the range of 31.25 kHz to 39.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) c) MCGC1 = 0xB8 (%10111000) – CLKS (bits 7 and 6) set to %10 in order to select external reference clock as system clock source – RDIV (bits 5-3) set to %111, or divide-by-128 because 4 MHz / 128 = 31.25 kHz which is in the 31.25 kHz to 39.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) START IN FEI MODE MCGC2 = $36 IN BLPE MODE ? (LP=1) CHECK NO NO YES OSCINIT = 1 ? MCGC2 = $36 (LP = 0) YES MCGC1 = $B8 CHECK PLLST = 1? CHECK NO NO YES IREFST = 0? YES CHECK LOCK = 1? CHECK CLKST = %10? NO NO YES MCGC1 = $10 YES ENTER BLPE MODE ? NO CHECK CLKST = %11? NO YES YES MCGC2 = $3E (LP = 1) CONTINUE IN PEE MODE MCGC1 = $90 MCGC3 = $44 Figure 8-9.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.5.2.2 Example # 2: Moving from PEE to BLPI Mode: External Crystal = 4 MHz, Bus Frequency =16 kHz In this example, the MCG will move through the proper operational modes from PEE mode with a 4 MHz crystal configured for an 8 MHz bus frequency (see previous example) to BLPI mode with a 16 kHz bus frequency.First, the code sequence will be described. Then a flowchart will be included which illustrates the sequence. 1.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 4. Lastly, FBI transitions into BLPI mode. a) MCGC2 = 0x08 (%00001000) – LP (bit 3) in MCGSC is 1 START IN PEE MODE MCGC1 = $90 CHECK PLLST = 0? CHECK NO CLKST = %10 ? YES YES OPTIONAL: CHECK LOCK = 1? ENTER NO NO NO BLPE MODE ? YES MCGC1 = $44 YES MCGC2 = $3E CHECK IREFST = 0? MCGC1 = $B8 MCGC3 = $04 IN BLPE MODE ? (LP=1) NO YES NO CHECK CLKST = %01? NO YES YES MCGC2 = $36 (LP = 0) MCGC2 = $08 CONTINUE IN BLPI MODE Figure 8-10.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.5.2.3 Example #3: Moving from BLPI to FEE Mode: External Crystal = 4 MHz, Bus Frequency = 16 MHz In this example, the MCG will move through the proper operational modes from BLPI mode at a 16 kHz bus frequency running off of the internal reference clock (see previous example) to FEE mode using a 4 MHz crystal configured for a 16 MHz bus frequency. First, the code sequence will be described.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) START IN BLPI MODE CHECK NO IREFST = 0? MCGC2 = $00 YES OPTIONAL: CHECK LOCK = 1? NO OPTIONAL: CHECK LOCK = 1? NO YES YES MCGC2 = $36 CHECK CLKST = %00? CHECK NO NO YES OSCINIT = 1 ? CONTINUE YES IN FEE MODE MCGC1 = $38 Figure 8-11. Flowchart of BLPI to FEE Mode Transition using a 4 MHz crystal 8.5.2.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) external crystal and a maximum reference divider factor of 128, the resulting frequency of the reference clock for the FLL is 62.5 kHz (greater than the 39.0625 kHz maximum allowed). Care must be taken in the software to minimize the amount of time spent in this state where the FLL is operating in this condition.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) c) MCGC1 = 0x98 (%10011000) – RDIV (bits 5-3) set to %011, or divide-by-8 because 8 MHz / 8= 1 MHz which is in the 1 MHz to 2 MHz range required by the PLL. In BLPE mode, the configuration of the RDIV does not matter because both the FLL and PLL are disabled. Changing them only sets up the the dividers for PLL usage in PBE mode d) MCGC3 = 0x44 (%01000100) – PLLS (bit 6) set to 1, selects the PLL.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) START IN FEI MODE MCGC2 = $36 CHECK NO CHECK PLLST = 1? NO OSCINIT = 1 ? YES YES MCGC2 = $36 (LP = 0) MCGC1 = $B8 CHECK NO IREFST = 0? CHECK LOCK = 1? NO YES YES CHECK CLKST = %10? NO MCGC1 = $18 YES CHECK CLKST = %11? MCGC2 = $3E (LP = 1) NO YES MCGC1 = $98 MCGC3 = $44 CONTINUE IN PEE MODE Figure 8-12.
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) 8.5.3 Calibrating the Internal Reference Clock (IRC) The IRC is calibrated by writing to the MCGTRM register first, then using the FTRIM bit to “fine tune” the frequency. We will refer to this total 9-bit value as the trim value, ranging from 0x000 to 0x1FF, where the FTRIM bit is the LSB. The trim value after a POR is always 0x100 (MCGTRM = 0x80 and FTRIM = 0).
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) Initial conditions: 1) Clock supplied from ATE has 500 μs duty period 2) MCG configured for internal reference with 8MHz bus START TRIM PROCEDURE TRMVAL = $100 n=1 MEASURE INCOMING CLOCK WIDTH (COUNT = # OF BUS CLOCKS / 8) COUNT < EXPECTED = 500 (RUNNING TOO SLOW) .
Chapter 8 Multi-Purpose Clock Generator (S08MCGV1) MC9S08DN60 Series Data Sheet, Rev 3 160 Freescale Semiconductor
Chapter 9 Analog Comparator (S08ACMPV3) 9.1 Introduction The analog comparator module (ACMP) provides a circuit for comparing two analog input voltages or for comparing one analog input voltage to an internal reference voltage. The comparator circuit is designed to operate across the full range of the supply voltage (rail-to-rail operation). All MC9S08DN60 Series MCUs have two full function ACMPs in a 64-pin package. MCUs in the 48-pin package have two ACMPs, but the output of ACMP2 is not accessible.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 9 Analog Comparator (S08ACMPV3) 9.1.2 Features The ACMP has the following features: • Full rail to rail supply operation. • Selectable interrupt on rising edge, falling edge, or either rising or falling edges of comparator output. • Option to compare to fixed internal bandgap reference voltage. • Option to allow comparator output to be visible on a pin, ACMPxO. 9.1.3 Modes of Operation This section defines the ACMP operation in wait, stop, and background debug modes. 9.1.3.
Chapter 9 Analog Comparator (S08ACMPV3) 9.1.4 Block Diagram The block diagram for the analog comparator module is shown Figure 9-2. Internal Bus Internal Reference ACIE ACBGS ACME Status & Control Register ACMPx INTERRUPT REQUEST ACF ACMPx+ + set ACF ACMOD ACOPE Interrupt Control Comparator ACMPx- ACMPxO Figure 9-2. Analog Comparator (ACMP) Block Diagram 9.2 External Signal Description The ACMP has two analog input pins, ACMPx+ and ACMPx− and one digital output pin ACMPxO.
Chapter 9 Analog Comparator (S08ACMPV3) 9.3 Memory Map/Register Definition The ACMP includes one register: • An 8-bit status and control register Refer to the direct-page register summary in the memory section of this document for the absolute address assignments for the ACMP register.This section refers to register and control bits only by their names and relative address offsets.
Chapter 9 Analog Comparator (S08ACMPV3) Table 9-3. ACMPxSC Field Descriptions (continued) Field 3 ACO Description Analog Comparator Output. Reading ACO returns the current value of the analog comparator output. ACO is reset to a 0 and reads as a 0 when the ACMP is disabled (ACME = 0). 2 ACOPE Analog Comparator Output Pin Enable. Enables the comparator output to be placed onto the external pin, ACMPxO.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.1 Introduction The 12-bit analog-to-digital converter (ADC) is a successive approximation ADC designed for operation within an integrated microcontroller system-on-chip. NOTE MC9S08DN60 Series devices operate at a higher voltage range (2.7 V to 5.5 V) and do not include stop1 mode. Please ignore references to stop1. 10.1.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) Table 10-1.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.1.5 Temperature Sensor To use the on-chip temperature sensor, the user must perform the following: • Configure ADC for long sample with a maximum of 1 MHz clock • Convert the bandgap voltage reference channel (AD27) — By converting the digital value of the bandgap voltage reference channel using the value of VBG the user can determine VDD. For value of bandgap voltage, see Section A.6, “DC Characteristics”.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.1.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) ADIV ADLPC MODE ADLSMP ADTRG 2 ADCO ADCH 1 ADCCFG complete COCO ADCSC1 ADICLK Compare true AIEN 3 Async Clock Gen ADACK MCU STOP ADCK ÷2 ALTCLK abort transfer sample initialize ••• AD0 convert Control Sequencer ADHWT Bus Clock Clock Divide AIEN 1 Interrupt COCO 2 ADVIN SAR Converter AD27 VREFH Data Registers Sum VREFL Compare true 3 Compare Value Registers ACFGT Value Compare Logic ADCSC2 Figure 10-2.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.2.1 Analog Power (VDDAD) The ADC analog portion uses VDDAD as its power connection. In some packages, VDDAD is connected internally to VDD. If externally available, connect the VDDAD pin to the same voltage potential as VDD. External filtering may be necessary to ensure clean VDDAD for good results. 10.2.2 Analog Ground (VSSAD) The ADC analog portion uses VSSAD as its ground connection. In some packages, VSSAD is connected internally to VSS.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 7 R 6 5 AIEN ADCO 0 0 4 3 2 1 0 1 1 COCO ADCH W Reset: 0 1 1 1 Figure 10-3. Status and Control Register (ADCSC1) Table 10-3. ADCSC1 Field Descriptions Field Description 7 COCO Conversion Complete Flag. The COCO flag is a read-only bit set each time a conversion is completed when the compare function is disabled (ACFE = 0).
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.3.2 Status and Control Register 2 (ADCSC2) The ADCSC2 register controls the compare function, conversion trigger, and conversion active of the ADC module. Reset: 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 Figure 10-4. Status and Control Register 2 (ADCSC2) Table 10-5. ADCSC2 Register Field Descriptions Field Description 7 ADACT Conversion Active. Indicates that a conversion is in progress.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) If the MODE bits are changed, any data in ADCRH becomes invalid. R 7 6 5 4 3 2 1 0 0 0 0 0 ADR11 ADR10 ADR9 ADR8 0 0 0 0 0 0 0 0 W Reset: Figure 10-5. Data Result High Register (ADCRH) 10.3.4 Data Result Low Register (ADCRL) ADCRL contains the lower eight bits of the result of a 12-bit or 10-bit conversion, and all eight bits of an 8-bit conversion.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) In 10-bit mode, the ADCCVH register holds the upper two bits of the 10-bit compare value (ADCV[9:8]). These bits are compared to the upper two bits of the result following a conversion in 10-bit mode when the compare function is enabled. In 8-bit mode, ADCCVH is not used during compare. 10.3.6 Compare Value Low Register (ADCCVL) This register holds the lower 8 bits of the 12-bit or 10-bit compare value or all 8 bits of the 8-bit compare value.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) Table 10-6. ADCCFG Register Field Descriptions (continued) Field Description 3:2 MODE Conversion Mode Selection. MODE bits are used to select between 12-, 10-, or 8-bit operation. See Table 10-8. 1:0 ADICLK Input Clock Select. ADICLK bits select the input clock source to generate the internal clock ADCK. See Table 10-9. Table 10-7.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) used to control the pins associated with channels 0–7 of the ADC module. 7 6 5 4 3 2 1 0 ADPC7 ADPC6 ADPC5 ADPC4 ADPC3 ADPC2 ADPC1 ADPC0 0 0 0 0 0 0 0 0 R W Reset: Figure 10-10. Pin Control 1 Register (APCTL1) Table 10-10. APCTL1 Register Field Descriptions Field Description 7 ADPC7 ADC Pin Control 7. ADPC7 controls the pin associated with channel AD7.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) Table 10-11. APCTL2 Register Field Descriptions Field Description 7 ADPC15 ADC Pin Control 15. ADPC15 controls the pin associated with channel AD15. 0 AD15 pin I/O control enabled 1 AD15 pin I/O control disabled 6 ADPC14 ADC Pin Control 14. ADPC14 controls the pin associated with channel AD14. 0 AD14 pin I/O control enabled 1 AD14 pin I/O control disabled 5 ADPC13 ADC Pin Control 13. ADPC13 controls the pin associated with channel AD13.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) Table 10-12. APCTL3 Register Field Descriptions Field Description 7 ADPC23 ADC Pin Control 23. ADPC23 controls the pin associated with channel AD23. 0 AD23 pin I/O control enabled 1 AD23 pin I/O control disabled 6 ADPC22 ADC Pin Control 22. ADPC22 controls the pin associated with channel AD22. 0 AD22 pin I/O control enabled 1 AD22 pin I/O control disabled 5 ADPC21 ADC Pin Control 21. ADPC21 controls the pin associated with channel AD21.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.4.1 Clock Select and Divide Control One of four clock sources can be selected as the clock source for the ADC module. This clock source is then divided by a configurable value to generate the input clock to the converter (ADCK). The clock is selected from one of the following sources by means of the ADICLK bits. • The bus clock, which is equal to the frequency at which software is executed. This is the default selection following reset.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) configured for low power operation, long sample time, continuous conversion, and automatic compare of the conversion result to a software determined compare value. 10.4.4.1 Initiating Conversions A conversion is initiated: • Following a write to ADCSC1 (with ADCH bits not all 1s) if software triggered operation is selected. • Following a hardware trigger (ADHWT) event if hardware triggered operation is selected.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) When a conversion is aborted, the contents of the data registers, ADCRH and ADCRL, are not altered. However, they continue to be the values transferred after the completion of the last successful conversion. If the conversion was aborted by a reset, ADCRH and ADCRL return to their reset states. 10.4.4.4 Power Control The ADC module remains in its idle state until a conversion is initiated.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) Table 10-13. Total Conversion Time vs. Control Conditions Conversion Type ADICLK ADLSMP Max Total Conversion Time Subsequent continuous 10-bit or 12-bit; fBUS > fADCK/11 xx 1 40 ADCK cycles The maximum total conversion time is determined by the clock source chosen and the divide ratio selected. The clock source is selectable by the ADICLK bits, and the divide ratio is specified by the ADIV bits.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) ALTCLK for this MCU. Consult the module introduction for information on ALTCLK specific to this MCU. A conversion complete event sets the COCO and generates an ADC interrupt to wake the MCU from wait mode if the ADC interrupt is enabled (AIEN = 1). 10.4.7 MCU Stop3 Mode Operation Stop mode is a low power-consumption standby mode during which most or all clock sources on the MCU are disabled. 10.4.7.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.5 Initialization Information This section gives an example that provides some basic direction on how to initialize and configure the ADC module. You can configure the module for 8-, 10-, or 12-bit resolution, single or continuous conversion, and a polled or interrupt approach, among many other options. Refer to Table 10-7, Table 10-8, and Table 10-9 for information used in this example.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) ADCSC1 = 0x41 (%01000001) Bit Bit Bit Bit 7 6 5 4:0 COCO AIEN ADCO ADCH 0 1 0 00001 Read-only flag which is set when a conversion completes Conversion complete interrupt enabled One conversion only (continuous conversions disabled) Input channel 1 selected as ADC input channel ADCRH/L = 0xxx Holds results of conversion. Read high byte (ADCRH) before low byte (ADCRL) so that conversion data cannot be overwritten with data from the next conversion.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.6 Application Information This section contains information for using the ADC module in applications. The ADC has been designed to be integrated into a microcontroller for use in embedded control applications requiring an A/D converter. 10.6.1 External Pins and Routing The following sections discuss the external pins associated with the ADC module and how they should be used for best results. 10.6.1.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.6.1.3 Analog Input Pins The external analog inputs are typically shared with digital I/O pins on MCU devices. The pin I/O control is disabled by setting the appropriate control bit in one of the pin control registers. Conversions can be performed on inputs without the associated pin control register bit set. It is recommended that the pin control register bit always be set when using a pin as an analog input.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) 10.6.2.3 Noise-Induced Errors System noise that occurs during the sample or conversion process can affect the accuracy of the conversion. The ADC accuracy numbers are guaranteed as specified only if the following conditions are met: • There is a 0.1 μF low-ESR capacitor from VREFH to VREFL. • There is a 0.1 μF low-ESR capacitor from VDDAD to VSSAD.
Chapter 10 Analog-to-Digital Converter (S08ADC12V1) For 12-bit conversions the code transitions only after the full code width is present, so the quantization error is −1 lsb to 0 lsb and the code width of each step is 1 lsb. 10.6.2.5 Linearity Errors The ADC may also exhibit non-linearity of several forms. Every effort has been made to reduce these errors but the system should be aware of them because they affect overall accuracy.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.1 Introduction The inter-integrated circuit (IIC) provides a method of communication between a number of devices. The interface is designed to operate up to 100 kbps with maximum bus loading and timing. The device is capable of operating at higher baud rates, up to a maximum of clock/20, with reduced bus loading. The maximum communication length and the number of devices that can be connected are limited by a maximum bus capacitance of 400 pF.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.1.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.1.3 Block Diagram Figure 11-2 is a block diagram of the IIC. Address Data Bus Interrupt ADDR_DECODE CTRL_REG DATA_MUX FREQ_REG ADDR_REG STATUS_REG DATA_REG Input Sync Start Stop Arbitration Control Clock Control In/Out Data Shift Register Address Compare SCL SDA Figure 11-2. IIC Functional Block Diagram 11.2 External Signal Description This section describes each user-accessible pin signal. 11.2.
Chapter 11 Inter-Integrated Circuit (S08IICV2) Refer to the direct-page register summary in the memory chapter of this document for the absolute address assignments for all IIC registers. This section refers to registers and control bits only by their names. A Freescale-provided equate or header file is used to translate these names into the appropriate absolute addresses. 11.3.
Chapter 11 Inter-Integrated Circuit (S08IICV2) Table 11-2. IICF Field Descriptions Field 7–6 MULT 5–0 ICR Description IIC Multiplier Factor. The MULT bits define the multiplier factor, mul. This factor, along with the SCL divider, generates the IIC baud rate. The multiplier factor mul as defined by the MULT bits is provided below. 00 mul = 01 01 mul = 02 10 mul = 04 11 Reserved IIC Clock Rate. The ICR bits are used to prescale the bus clock for bit rate selection.
Chapter 11 Inter-Integrated Circuit (S08IICV2) Table 11-4.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.3.3 IIC Control Register (IICC1) 7 6 5 4 3 IICEN IICIE MST TX TXAK R W Reset 2 1 0 0 0 0 0 0 RSTA 0 0 0 0 0 0 = Unimplemented or Reserved Figure 11-5. IIC Control Register (IICC1) Table 11-5. IICC1 Field Descriptions Field Description 7 IICEN IIC Enable. The IICEN bit determines whether the IIC module is enabled. 0 IIC is not enabled 1 IIC is enabled 6 IICIE IIC Interrupt Enable.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.3.4 IIC Status Register (IICS) 7 R 6 TCF 5 4 BUSY IAAS 3 2 0 SRW ARBL 1 0 RXAK IICIF W Reset 1 0 0 0 0 0 0 0 = Unimplemented or Reserved Figure 11-6. IIC Status Register (IICS) Table 11-6. IICS Field Descriptions Field Description 7 TCF Transfer Complete Flag. This bit is set on the completion of a byte transfer. This bit is only valid during or immediately following a transfer to the IIC module or from the IIC module.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.3.5 IIC Data I/O Register (IICD) 7 6 5 4 3 2 1 0 0 0 0 0 R DATA W Reset 0 0 0 0 Figure 11-7. IIC Data I/O Register (IICD) Table 11-7. IICD Field Descriptions Field Description 7–0 DATA Data — In master transmit mode, when data is written to the IICD, a data transfer is initiated. The most significant bit is sent first. In master receive mode, reading this register initiates receiving of the next byte of data.
Chapter 11 Inter-Integrated Circuit (S08IICV2) Table 11-8. IICC2 Field Descriptions Field Description 7 GCAEN General Call Address Enable. The GCAEN bit enables or disables general call address. 0 General call address is disabled 1 General call address is enabled 6 ADEXT Address Extension. The ADEXT bit controls the number of bits used for the slave address. 0 7-bit address scheme 1 10-bit address scheme 2–0 AD[10:8] Slave Address.
Chapter 11 Inter-Integrated Circuit (S08IICV2) msb SCL 1 SDA lsb 2 3 4 5 6 7 8 msb 9 AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W Start Signal 1 SDA 3 4 5 6 7 8 Calling Address 3 4 5 6 7 8 D7 D6 D5 D4 D3 D2 D1 D0 1 XX Read/ Ack Write Bit Repeated Start Signal 9 No Ack Bit msb 9 AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W Start Signal 2 Data Byte lsb 2 1 Read/ Ack Write Bit Calling Address msb SCL XXX lsb Stop Signal lsb 2 3 4 5 6 7 8 9 AD7 AD6 AD5 AD4 AD3 AD2 AD1 R/W
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.4.1.3 Data Transfer Before successful slave addressing is achieved, the data transfer can proceed byte-by-byte in a direction specified by the R/W bit sent by the calling master. All transfers that come after an address cycle are referred to as data transfers, even if they carry sub-address information for the slave device Each data byte is 8 bits long.
Chapter 11 Inter-Integrated Circuit (S08IICV2) the transition from master to slave mode does not generate a stop condition. Meanwhile, a status bit is set by hardware to indicate loss of arbitration. 11.4.1.7 Clock Synchronization Because wire-AND logic is performed on the SCL line, a high-to-low transition on the SCL line affects all the devices connected on the bus.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.4.2 10-bit Address For 10-bit addressing, 0x11110 is used for the first 5 bits of the first address byte. Various combinations of read/write formats are possible within a transfer that includes 10-bit addressing. 11.4.2.1 Master-Transmitter Addresses a Slave-Receiver The transfer direction is not changed (see Table 11-9).
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.4.3 General Call Address General calls can be requested in 7-bit address or 10-bit address. If the GCAEN bit is set, the IIC matches the general call address as well as its own slave address. When the IIC responds to a general call, it acts as a slave-receiver and the IAAS bit is set after the address cycle.
Chapter 11 Inter-Integrated Circuit (S08IICV2) Arbitration is lost in the following circumstances: • SDA sampled as a low when the master drives a high during an address or data transmit cycle. • SDA sampled as a low when the master drives a high during the acknowledge bit of a data receive cycle. • A start cycle is attempted when the bus is busy. • A repeated start cycle is requested in slave mode. • A stop condition is detected when the master did not request it.
Chapter 11 Inter-Integrated Circuit (S08IICV2) 11.7 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 6. 7.
Chapter 11 Inter-Integrated Circuit (S08IICV2) Clear IICIF Master Mode ? Y TX N Y RX Tx/Rx ? Arbitration Lost ? N Last Byte Transmitted ? N Clear ARBL Y RXAK=0 ? Last Byte to Be Read ? N N N Y Y IAAS=1 ? Y IAAS=1 ? Y Address Transfer See Note 1 Y End of Addr Cycle (Master Rx) ? Y Y (Read) 2nd Last Byte to Be Read ? N SRW=1 ? Write Next Byte to IICD Set TXACK =1 Generate Stop Signal (MST = 0) Switch to Rx Mode Generate Stop Signal (MST = 0) Read Data from IICD and Store A
Chapter 11 Inter-Integrated Circuit (S08IICV2) MC9S08DN60 Series Data Sheet, Rev 3 212 Freescale Semiconductor
Chapter 12 Serial Peripheral Interface (S08SPIV3) 12.1 Introduction The serial peripheral interface (SPI) module provides for full-duplex, synchronous, serial communication between the MCU and peripheral devices. These peripheral devices can include other microcontrollers, analog-to-digital converters, shift registers, sensors, memories, etc. The SPI runs at a baud rate up to the bus clock divided by two in master mode and bus clock divided by four in slave mode.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 12 Serial Peripheral Interface (S08SPIV3) 12.1.1 Features Features of the SPI module include: • Master or slave mode operation • Full-duplex or single-wire bidirectional option • Programmable transmit bit rate • Double-buffered transmit and receive • Serial clock phase and polarity options • Slave select output • Selectable MSB-first or LSB-first shifting 12.1.
Chapter 12 Serial Peripheral Interface (S08SPIV3) The most common uses of the SPI system include connecting simple shift registers for adding input or output ports or connecting small peripheral devices such as serial A/D or D/A converters. Although Figure 12-2 shows a system where data is exchanged between two MCUs, many practical systems involve simpler connections where data is unidirectionally transferred from the master MCU to a slave or from a slave to the master MCU. 12.1.2.
Chapter 12 Serial Peripheral Interface (S08SPIV3) PIN CONTROL M SPE MOSI (MOMI) S Tx BUFFER (WRITE SPID) ENABLE SPI SYSTEM M SHIFT OUT SPI SHIFT REGISTER SHIFT IN MISO (SISO) S SPC0 Rx BUFFER (READ SPID) BIDIROE SHIFT DIRECTION LSBFE SHIFT CLOCK Rx BUFFER FULL Tx BUFFER EMPTY MASTER CLOCK BUS RATE CLOCK SPIBR CLOCK GENERATOR MSTR CLOCK LOGIC SLAVE CLOCK MASTER/SLAVE M SPSCK S MASTER/ SLAVE MODE SELECT MODFEN SSOE MODE FAULT DETECTION SS SPRF SPTEF SPTIE MODF SPIE SPI INTERRUPT R
Chapter 12 Serial Peripheral Interface (S08SPIV3) BUS CLOCK PRESCALER CLOCK RATE DIVIDER DIVIDE BY 1, 2, 3, 4, 5, 6, 7, or 8 DIVIDE BY 2, 4, 8, 16, 32, 64, 128, or 256 SPPR2:SPPR1:SPPR0 SPR2:SPR1:SPR0 MASTER SPI BIT RATE Figure 12-4. SPI Baud Rate Generation 12.2 External Signal Description The SPI optionally shares four port pins. The function of these pins depends on the settings of SPI control bits.
Chapter 12 Serial Peripheral Interface (S08SPIV3) 12.3 Modes of Operation 12.3.1 SPI in Stop Modes The SPI is disabled in all stop modes, regardless of the settings before executing the STOP instruction. During either stop1 or stop2 mode, the SPI module will be fully powered down. Upon wake-up from stop1 or stop2 mode, the SPI module will be in the reset state. During stop3 mode, clocks to the SPI module are halted. No registers are affected.
Chapter 12 Serial Peripheral Interface (S08SPIV3) Table 12-1. SPIC1 Field Descriptions (continued) Field Description 4 MSTR Master/Slave Mode Select 0 SPI module configured as a slave SPI device 1 SPI module configured as a master SPI device 3 CPOL Clock Polarity — This bit effectively places an inverter in series with the clock signal from a master SPI or to a slave SPI device. Refer to Section 12.5.1, “SPI Clock Formats” for more details.
Chapter 12 Serial Peripheral Interface (S08SPIV3) Table 12-3. SPIC2 Register Field Descriptions Field Description 4 MODFEN Master Mode-Fault Function Enable — When the SPI is configured for slave mode, this bit has no meaning or effect. (The SS pin is the slave select input.) In master mode, this bit determines how the SS pin is used (refer to Table 12-2 for more details).
Chapter 12 Serial Peripheral Interface (S08SPIV3) Table 12-5. SPI Baud Rate Prescaler Divisor SPPR2:SPPR1:SPPR0 Prescaler Divisor 0:0:0 1 0:0:1 2 0:1:0 3 0:1:1 4 1:0:0 5 1:0:1 6 1:1:0 7 1:1:1 8 Table 12-6. SPI Baud Rate Divisor 12.4.4 SPR2:SPR1:SPR0 Rate Divisor 0:0:0 2 0:0:1 4 0:1:0 8 0:1:1 16 1:0:0 32 1:0:1 64 1:1:0 128 1:1:1 256 SPI Status Register (SPIS) This register has three read-only status bits. Bits 6, 3, 2, 1, and 0 are not implemented and always read 0.
Chapter 12 Serial Peripheral Interface (S08SPIV3) Table 12-7. SPIS Register Field Descriptions Field Description 7 SPRF SPI Read Buffer Full Flag — SPRF is set at the completion of an SPI transfer to indicate that received data may be read from the SPI data register (SPID). SPRF is cleared by reading SPRF while it is set, then reading the SPI data register.
Chapter 12 Serial Peripheral Interface (S08SPIV3) 12.5 Functional Description An SPI transfer is initiated by checking for the SPI transmit buffer empty flag (SPTEF = 1) and then writing a byte of data to the SPI data register (SPID) in the master SPI device.
Chapter 12 Serial Peripheral Interface (S08SPIV3) pin from a master and the MISO waveform applies to the MISO output from a slave. The SS OUT waveform applies to the slave select output from a master (provided MODFEN and SSOE = 1). The master SS output goes to active low one-half SPSCK cycle before the start of the transfer and goes back high at the end of the eighth bit time of the transfer. The SS IN waveform applies to the slave select input of a slave. BIT TIME # (REFERENCE) 1 2 ...
Chapter 12 Serial Peripheral Interface (S08SPIV3) in LSBFE. Both variations of SPSCK polarity are shown, but only one of these waveforms applies for a specific transfer, depending on the value in CPOL. The SAMPLE IN waveform applies to the MOSI input of a slave or the MISO input of a master. The MOSI waveform applies to the MOSI output pin from a master and the MISO waveform applies to the MISO output from a slave.
Chapter 12 Serial Peripheral Interface (S08SPIV3) 12.5.2 SPI Interrupts There are three flag bits, two interrupt mask bits, and one interrupt vector associated with the SPI system. The SPI interrupt enable mask (SPIE) enables interrupts from the SPI receiver full flag (SPRF) and mode fault flag (MODF). The SPI transmit interrupt enable mask (SPTIE) enables interrupts from the SPI transmit buffer empty flag (SPTEF).
Chapter 12 Serial Peripheral Interface (S08SPIV3) MC9S08DN60 Series Data Sheet, Rev 3 228 Freescale Semiconductor
Chapter 13 Serial Communications Interface (S08SCIV4) 13.1 Introduction All MCUs in the MC9S08DN60 Series include SCI1. • • NOTE MC9S08DN60 Series devices operate at a higher voltage range (2.7 V to 5.5 V) and do not include stop1 mode. Please ignore references to stop1. The RxD1 pin does not contain a clamp diode to VDD and should not be driven above VDD. The voltage measured on the internally pulled up RxD1 pin may be as low as VDD – 0.7 V.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 13 Serial Communications Interface (S08SCIV4) 13.1.
Chapter 13 Serial Communications Interface (S08SCIV4) 13.1.3 Block Diagram Figure 13-2 shows the transmitter portion of the SCI.
Chapter 13 Serial Communications Interface (S08SCIV4) Figure 13-3 shows the receiver portion of the SCI.
Chapter 13 Serial Communications Interface (S08SCIV4) 13.2 Register Definition The SCI has eight 8-bit registers to control baud rate, select SCI options, report SCI status, and for transmit/receive data. Refer to the direct-page register summary in the Memory chapter of this data sheet for the absolute address assignments for all SCI registers. This section refers to registers and control bits only by their names.
Chapter 13 Serial Communications Interface (S08SCIV4) 7 6 5 4 3 2 1 0 SBR7 SBR6 SBR5 SBR4 SBR3 SBR2 SBR1 SBR0 0 0 0 0 0 1 0 0 R W Reset Figure 13-5. SCI Baud Rate Register (SCI1BDL) Table 13-2. SCI1BDL Field Descriptions Field 7:0 SBR[7:0] 13.2.2 Description Baud Rate Modulo Divisor — These 13 bits in SBR[12:0] are referred to collectively as BR, and they set the modulo divide rate for the SCI baud rate generator.
Chapter 13 Serial Communications Interface (S08SCIV4) Table 13-3. SCI1C1 Field Descriptions (continued) Field 3 WAKE Description Receiver Wakeup Method Select — Refer to Section 13.3.3.2, “Receiver Wakeup Operation” for more information. 0 Idle-line wakeup. 1 Address-mark wakeup. 2 ILT Idle Line Type Select — Setting this bit to 1 ensures that the stop bit and logic 1 bits at the end of a character do not count toward the 10 or 11 bit times of logic high level needed by the idle line detection logic.
Chapter 13 Serial Communications Interface (S08SCIV4) Table 13-4. SCI1C2 Field Descriptions (continued) Field Description 3 TE Transmitter Enable 0 Transmitter off. 1 Transmitter on. TE must be 1 in order to use the SCI transmitter. When TE = 1, the SCI forces the TxD pin to act as an output for the SCI system. When the SCI is configured for single-wire operation (LOOPS = RSRC = 1), TXDIR controls the direction of traffic on the single SCI communication line (TxD pin).
Chapter 13 Serial Communications Interface (S08SCIV4) Table 13-5. SCI1S1 Field Descriptions Field Description 7 TDRE Transmit Data Register Empty Flag — TDRE is set out of reset and when a transmit data value transfers from the transmit data buffer to the transmit shifter, leaving room for a new character in the buffer. To clear TDRE, read SCI1S1 with TDRE = 1 and then write to the SCI data register (SCI1D). 0 Transmit data register (buffer) full. 1 Transmit data register (buffer) empty.
Chapter 13 Serial Communications Interface (S08SCIV4) Table 13-5. SCI1S1 Field Descriptions (continued) Field Description 1 FE Framing Error Flag — FE is set at the same time as RDRF when the receiver detects a logic 0 where the stop bit was expected. This suggests the receiver was not properly aligned to a character frame. To clear FE, read SCI1S1 with FE = 1 and then read the SCI data register (SCI1D). 0 No framing error detected. This does not guarantee the framing is correct. 1 Framing error.
Chapter 13 Serial Communications Interface (S08SCIV4) Table 13-6. SCI1S2 Field Descriptions (continued) Field 1 LBKDE 0 RAF 1 Description LIN Break Detection Enable— LBKDE is used to select a longer break character detection length. While LBKDE is set, framing error (FE) and receive data register full (RDRF) flags are prevented from setting. 0 Break character is detected at length of 10 bit times (11 if M = 1). 1 Break character is detected at length of 11 bit times (12 if M = 1).
Chapter 13 Serial Communications Interface (S08SCIV4) Table 13-7. SCI1C3 Field Descriptions (continued) Field 4 TXINV1 1 Description Transmit Data Inversion — Setting this bit reverses the polarity of the transmitted data output. 0 Transmit data not inverted 1 Transmit data inverted 3 ORIE Overrun Interrupt Enable — This bit enables the overrun flag (OR) to generate hardware interrupt requests. 0 OR interrupts disabled (use polling). 1 Hardware interrupt requested when OR = 1.
Chapter 13 Serial Communications Interface (S08SCIV4) MODULO DIVIDE BY (1 THROUGH 8191) BUSCLK SBR12:SBR0 BAUD RATE GENERATOR OFF IF [SBR12:SBR0] = 0 DIVIDE BY 16 Tx BAUD RATE Rx SAMPLING CLOCK (16 × BAUD RATE) BAUD RATE = BUSCLK [SBR12:SBR0] × 16 Figure 13-12. SCI Baud Rate Generation SCI communications require the transmitter and receiver (which typically derive baud rates from independent clock sources) to use the same baud rate.
Chapter 13 Serial Communications Interface (S08SCIV4) Writing 0 to TE does not immediately release the pin to be a general-purpose I/O pin. Any transmit activity that is in progress must first be completed. This includes data characters in progress, queued idle characters, and queued break characters. 13.3.2.1 Send Break and Queued Idle The SBK control bit in SCI1C2 is used to send break characters which were originally used to gain the attention of old teletype receivers.
Chapter 13 Serial Communications Interface (S08SCIV4) flag is set. If RDRF was already set indicating the receive data register (buffer) was already full, the overrun (OR) status flag is set and the new data is lost. Because the SCI receiver is double-buffered, the program has one full character time after RDRF is set before the data in the receive data buffer must be read to avoid a receiver overrun.
Chapter 13 Serial Communications Interface (S08SCIV4) message characters. At the end of a message, or at the beginning of the next message, all receivers automatically force RWU to 0 so all receivers wake up in time to look at the first character(s) of the next message. 13.3.3.2.1 Idle-Line Wakeup When WAKE = 0, the receiver is configured for idle-line wakeup. In this mode, RWU is cleared automatically when the receiver detects a full character time of the idle-line level.
Chapter 13 Serial Communications Interface (S08SCIV4) Instead of hardware interrupts, software polling may be used to monitor the TDRE and TC status flags if the corresponding TIE or TCIE local interrupt masks are 0s. When a program detects that the receive data register is full (RDRF = 1), it gets the data from the receive data register by reading SCI1D. The RDRF flag is cleared by reading SCI1S1 while RDRF = 1 and then reading SCI1D.
Chapter 13 Serial Communications Interface (S08SCIV4) 13.3.5.2 Stop Mode Operation During all stop modes, clocks to the SCI module are halted. In stop1 and stop2 modes, all SCI register data is lost and must be re-initialized upon recovery from these two stop modes. No SCI module registers are affected in stop3 mode. The receive input active edge detect circuit is still active in stop3 mode, but not in stop2..
Chapter 13 Serial Communications Interface (S08SCIV4) MC9S08DN60 Series Data Sheet, Rev 3 248 Freescale Semiconductor
Chapter 14 Real-Time Counter (S08RTCV1) 14.1 Introduction The RTC module consists of one 8-bit counter, one 8-bit comparator, several binary-based and decimal-based prescaler dividers, three clock sources, and one programmable periodic interrupt. This module can be used for time-of-day, calendar or any task scheduling functions. It can also serve as a cyclic wake up from low power modes without the need of external components. All devices in the MC9S08DN60 Series feature the RTC. 14.1.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 14 Real-Time Counter (S08RTCV1) 14.1.2 Features Features of the RTC module include: • 8-bit up-counter — 8-bit modulo match limit — Software controllable periodic interrupt on match • Three software selectable clock sources for input to prescaler with selectable binary-based and decimal-based divider values — 1-kHz internal low-power oscillator (LPO) — External clock (ERCLK) — 32-kHz internal clock (IRCLK) 14.1.
Chapter 14 Real-Time Counter (S08RTCV1) 14.1.4 Block Diagram The block diagram for the RTC module is shown in Figure 14-2. LPO Clock Source Select ERCLK IRCLK 8-Bit Modulo (RTCMOD) RTCLKS VDD RTCLKS[0] RTCPS Prescaler Divide-By Q D Background Mode E 8-Bit Comparator RTC Clock RTC Interrupt Request RTIF R Write 1 to RTIF 8-Bit Counter (RTCCNT) RTIE Figure 14-2. Real-Time Counter (RTC) Block Diagram 14.2 External Signal Description The RTC does not include any off-chip signals. 14.
Chapter 14 Real-Time Counter (S08RTCV1) 14.3.1 RTC Status and Control Register (RTCSC) RTCSC contains the real-time interrupt status flag (RTIF), the clock select bits (RTCLKS), the real-time interrupt enable bit (RTIE), and the prescaler select bits (RTCPS). 7 6 5 4 3 2 1 0 0 0 R RTIF RTCLKS RTIE RTCPS W Reset: 0 0 0 0 0 0 Figure 14-3. RTC Status and Control Register (RTCSC) Table 14-2.
Chapter 14 Real-Time Counter (S08RTCV1) 14.3.2 RTC Counter Register (RTCCNT) RTCCNT is the read-only value of the current RTC count of the 8-bit counter. 7 6 5 4 R 3 2 1 0 0 0 0 0 RTCCNT W Reset: 0 0 0 0 Figure 14-4. RTC Counter Register (RTCCNT) Table 14-4. RTCCNT Field Descriptions Field Description 7:0 RTCCNT RTC Count. These eight read-only bits contain the current value of the 8-bit counter. Writes have no effect to this register.
Chapter 14 Real-Time Counter (S08RTCV1) RTCPS and the RTCLKS[0] bit select the desired divide-by value. If a different value is written to RTCPS, the prescaler and RTCCNT counters are reset to 0x00. Table 14-6 shows different prescaler period values. Table 14-6. Prescaler Period RTCPS 1-kHz Internal Clock (RTCLKS = 00) 1-MHz External Clock 32-kHz Internal Clock 32-kHz Internal Clock (RTCLKS = 01) (RTCLKS = 10) (RTCLKS = 11) 0000 Off Off Off Off 0001 8 ms 1.024 ms 250 μs 32 ms 0010 32 ms 2.
Chapter 14 Real-Time Counter (S08RTCV1) Internal 1-kHz Clock Source RTC Clock (RTCPS = 0xA) RTCCNT 0x52 0x53 0x54 0x55 0x00 0x01 RTIF RTCMOD 0x55 Figure 14-6. RTC Counter Overflow Example In the example of Figure 14-6, the selected clock source is the 1-kHz internal oscillator clock source. The prescaler (RTCPS) is set to 0xA or divide-by-4. The modulo value in the RTCMOD register is set to 0x55.
Chapter 14 Real-Time Counter (S08RTCV1) #pragma TRAP_PROC void RTC_ISR(void) { /* Clear the interrupt flag */ RTCSC.byte = RTCSC.
Chapter 14 Real-Time Counter (S08RTCV1) MC9S08DN60 Series Data Sheet, Rev 3 258 Freescale Semiconductor
Chapter 15 Timer Pulse-Width Modulator (S08TPMV3) NOTE This chapter refers to S08TPM version 3, which applies to the 0M74K and newer mask sets of this device. 3M05C and older mask set devices use S08TPM version 2. If your device uses mask 3M05C or older, please refer to Appendix B, “Timer Pulse-Width Modulator (TPMV2) on page 331 for information pertaining to that module. 15.
PORT A PTA7/PIA7/ADP7/IRQ PTA6/PIA6/ADP6 PTA5/PIA5/ADP5 PTA4/PIA4/ADP4 PTA3/PIA3/ADP3/ACMP1O PTA2/PIA2/ADP2/ACMP1PTA1/PIA1/ADP1/ACMP1+ PTA0/PIA0/ADP0/MCLK PORT B PTB7/PIB7/ADP15 PTB6/PIB6/ADP14 PTB5/PIB5/ADP13 PTB4/PIB4/ADP12 PTB3/PIB3/ADP11 PTB2/PIB2/ADP10 PTB1/PIB1/ADP9 PTB0/PIB0/ADP8 PORT C PTC7 PTC6 PTC5 PTC4 PTC3 PTC2 PTC1 PTC0 PORT D PTD7/PID7/TPM1CH5 PTD6/PID6/TPM1CH4 PTD5/PID5/TPM1CH3 PTD4/PID4/TPM1CH2 PTD3/PID3/TPM1CH1 PTD2/PID2/TPM1CH0 PTD1/PID1/TPM2CH1 PTD0/PID0/TPM2CH0 PORT E PTE7 PTE6
Chapter 15 Timer/PWM Module (S08TPMV3) 15.1.
Chapter 15 Timer/PWM Module (S08TPMV3) • • Edge-aligned PWM mode The value of a 16-bit modulo register plus 1 sets the period of the PWM output signal. The channel value register sets the duty cycle of the PWM output signal. The user may also choose the polarity of the PWM output signal. Interrupts are available at the end of the period and at the duty-cycle transition point.
Chapter 15 Timer/PWM Module (S08TPMV3) BUS CLOCK FIXED SYSTEM CLOCK SYNC EXTERNAL CLOCK CLOCK SOURCE SELECT OFF, BUS, FIXED SYSTEM CLOCK, EXT PRESCALE AND SELECT 1, 2, 4, 8, 16, 32, 64, or 128 CLKSB:CLKSA PS2:PS1:PS0 CPWMS 16-BIT COUNTER TOF COUNTER RESET TOIE INTERRUPT LOGIC 16-BIT COMPARATOR TPMxMODH:TPMxMODL CHANNEL 0 ELS0B ELS0A PORT LOGIC TPMxCH0 16-BIT COMPARATOR TPMxC0VH:TPMxC0VL CH0F INTERNAL BUS 16-BIT LATCH CHANNEL 1 MS0B MS0A ELS1B ELS1A CH0IE INTERRUPT LOGIC PORT LO
Chapter 15 Timer/PWM Module (S08TPMV3) The TPM channels are programmable independently as input capture, output compare, or edge-aligned PWM channels. Alternately, the TPM can be configured to produce CPWM outputs on all channels. When the TPM is configured for CPWMs, the counter operates as an up/down counter; input capture, output compare, and EPWM functions are not practical. If a channel is configured as input capture, an internal pullup device may be enabled for that channel.
Chapter 15 Timer/PWM Module (S08TPMV3) 15.2.1.1 EXTCLK — External Clock Source Control bits in the timer status and control register allow the user to select nothing (timer disable), the bus-rate clock (the normal default source), a crystal-related clock, or an external clock as the clock which drives the TPM prescaler and subsequently the 16-bit TPM counter. The external clock source is synchronized in the TPM.
Chapter 15 Timer/PWM Module (S08TPMV3) When a channel is configured for edge-aligned PWM (CPWMS=0, MSnB=1 and ELSnB:ELSnA not = 0:0), the data direction is overridden, the TPMxCHn pin is forced to be an output controlled by the TPM, and ELSnA controls the polarity of the PWM output signal on the pin. When ELSnB:ELSnA=1:0, the TPMxCHn pin is forced high at the start of each new period (TPMxCNT=0x0000), and the pin is forced low when the channel value register matches the timer counter.
Chapter 15 Timer/PWM Module (S08TPMV3) When the TPM is configured for center-aligned PWM (and ELSnB:ELSnA not = 0:0), the data direction for all channels in this TPM are overridden, the TPMxCHn pins are forced to be outputs controlled by the TPM, and the ELSnA bits control the polarity of each TPMxCHn output.
Chapter 15 Timer/PWM Module (S08TPMV3) 15.3 Register Definition This section consists of register descriptions in address order. 15.3.1 TPM Status and Control Register (TPMxSC) TPMxSC contains the overflow status flag and control bits used to configure the interrupt enable, TPM configuration, clock source, and prescale factor. These controls relate to all channels within this timer module.
Chapter 15 Timer/PWM Module (S08TPMV3) Table 15-3. TPM-Clock-Source Selection CLKSB:CLKSA TPM Clock Source to Prescaler Input 00 No clock selected (TPM counter disable) 01 Bus rate clock 10 Fixed system clock 11 External source Table 15-4. Prescale Factor Selection 15.3.
Chapter 15 Timer/PWM Module (S08TPMV3) R 7 6 5 4 3 2 1 0 Bit 7 6 5 4 3 2 1 Bit 0 0 0 W Reset Any write to TPMxCNTL clears the 16-bit counter 0 0 0 0 0 0 Figure 15-9.
Chapter 15 Timer/PWM Module (S08TPMV3) 7 6 5 4 3 2 1 0 Bit 7 6 5 4 3 2 1 Bit 0 0 0 0 0 0 0 0 0 R W Reset Reset the TPM counter before writing to the TPM modulo registers to avoid confusion about when the first counter overflow will occur. 15.3.4 TPM Channel n Status and Control Register (TPMxCnSC) TPMxCnSC contains the channel-interrupt-status flag and control bits used to configure the interrupt enable, channel configuration, and pin function.
Chapter 15 Timer/PWM Module (S08TPMV3) Table 15-5. TPMxCnSC Field Descriptions (continued) Field Description 4 MSnA Mode select A for TPM channel n. When CPWMS=0 and MSnB=0, MSnA configures TPM channel n for input-capture mode or output compare mode. Refer to Table 15-6 for a summary of channel mode and setup controls. Note: If the associated port pin is not stable for at least two bus clock cycles before changing to input capture mode, it is possible to get an unexpected indication of an edge trigger.
Chapter 15 Timer/PWM Module (S08TPMV3) 7 6 5 4 3 2 1 0 Bit 15 14 13 12 11 10 9 Bit 8 0 0 0 0 0 0 0 0 R W Reset Figure 15-13. TPM Channel Value Register High (TPMxCnVH) 7 6 5 4 3 2 1 0 Bit 7 6 5 4 3 2 1 Bit 0 0 0 0 0 0 0 0 0 R W Reset Figure 15-14. TPM Channel Value Register Low (TPMxCnVL) In input capture mode, reading either byte (TPMxCnVH or TPMxCnVL) latches the contents of both bytes into a buffer where they remain latched until the other half is read.
Chapter 15 Timer/PWM Module (S08TPMV3) are used for PWM & output compare operation once normal execution resumes. Writes to the channel registers while BDM is active do not interfere with partial completion of a coherency sequence. After the coherency mechanism has been fully exercised, the channel registers are updated using the buffered values written (while BDM was not active) by the user. 15.
Chapter 15 Timer/PWM Module (S08TPMV3) Table 15-7. TPM Clock Source Selection CLKSB:CLKSA TPM Clock Source to Prescaler Input 00 No clock selected (TPM counter disabled) 01 Bus rate clock 10 Fixed system clock 11 External source The bus rate clock is the main system bus clock for the MCU. This clock source requires no synchronization because it is the clock that is used for all internal MCU activities including operation of the CPU and buses.
Chapter 15 Timer/PWM Module (S08TPMV3) 15.4.1.3 Counting Modes The main timer counter has two counting modes. When center-aligned PWM is selected (CPWMS=1), the counter operates in up/down counting mode. Otherwise, the counter operates as a simple up counter. As an up counter, the timer counter counts from 0x0000 through its terminal count and then continues with 0x0000. The terminal count is 0xFFFF or a modulus value in TPMxMODH:TPMxMODL.
Chapter 15 Timer/PWM Module (S08TPMV3) In output compare mode, values are transferred to the corresponding timer channel registers only after both 8-bit halves of a 16-bit register have been written and according to the value of CLKSB:CLKSA bits, so: • If (CLKSB:CLKSA = 0:0), the registers are updated when the second byte is written • If (CLKSB:CLKSA not = 0:0), the registers are updated at the next change of the TPM counter (end of the prescaler counting) after the second byte is written.
Chapter 15 Timer/PWM Module (S08TPMV3) the TPM counter is a free-running counter then the update is made when the TPM counter changes from 0xFFFE to 0xFFFF. 15.4.2.4 Center-Aligned PWM Mode This type of PWM output uses the up/down counting mode of the timer counter (CPWMS=1). The output compare value in TPMxCnVH:TPMxCnVL determines the pulse width (duty cycle) of the PWM signal while the period is determined by the value in TPMxMODH:TPMxMODL.
Chapter 15 Timer/PWM Module (S08TPMV3) Input capture, output compare, and edge-aligned PWM functions do not make sense when the counter is operating in up/down counting mode so this implies that all active channels within a TPM must be used in CPWM mode when CPWMS=1. The TPM may be used in an 8-bit MCU. The settings in the timer channel registers are buffered to ensure coherent 16-bit updates and to avoid unexpected PWM pulse widths.
Chapter 15 Timer/PWM Module (S08TPMV3) All TPM interrupts are listed in Table 15-8 which shows the interrupt name, the name of any local enable that can block the interrupt request from leaving the TPM and getting recognized by the separate interrupt processing logic. Table 15-8.
Chapter 15 Timer/PWM Module (S08TPMV3) 15.6.2.1.2 Center-Aligned PWM Case When CPWMS=1, TOF gets set when the timer counter changes direction from up-counting to down-counting at the end of the terminal count (the value in the modulo register). In this case the TOF corresponds to the end of a PWM period. 15.6.2.2 Channel Event Interrupt Description The meaning of channel interrupts depends on the channel’s current mode (input-capture, output-compare, edge-aligned PWM, or center-aligned PWM). 15.6.2.2.
Chapter 15 Timer/PWM Module (S08TPMV3) BDM mode returns the latched value of TPMxCNTH:L from the read buffer instead of the frozen TPM counter value. — This read coherency mechanism is cleared in TPM v3 in BDM mode if there is a write to TPMxSC, TPMxCNTH or TPMxCNTL. Instead, in these conditions the TPM v2 does not clear this read coherency mechanism. 3. Read of TPMxCnVH:L registers (Section 15.3.
Chapter 15 Timer/PWM Module (S08TPMV3) TPM counter changes from (TPMxMODH:L - 1) to (TPMxMODH:L). If the TPM counter is a free-running counter, then this update is made when the TPM counter changes from $FFFE to $FFFF. Instead, the TPM v2 makes this update after that the both bytes were written and when the TPM counter changes from TPMxMODH:L to $0000. — Center-Aligned PWM (Section 15.4.2.
Chapter 15 Timer/PWM Module (S08TPMV3) EPWM mode TPMxMODH:TPMxMODL = 0x0007 TPMxCnVH:TPMxCnVL = 0x0005 RESET (active low) BUS CLOCK TPMxCNTH:TPMxCNTL 0 1 2 3 4 5 00 CLKSB:CLKSA BITS 6 7 0 1 2 ... 01 MSnB:MSnA BITS 00 10 ELSnB:ELSnA BITS 00 10 TPMv2 TPMxCHn TPMv3 TPMxCHn CHnF BIT (in TPMv2 and TPMv3) Figure 0-1.
Chapter 15 Timer/PWM Module (S08TPMV3) ... configure the channel pin as output port pin and set the output pin; configure the channel to generate the EPWM signal but keep ELSnB:ELSnA as 00; configure the other registers (TPMxMODH, TPMxMODL, TPMxCnVH, TPMxCnVL, ...
Chapter 15 Timer/PWM Module (S08TPMV3) MC9S08DN60 Series Data Sheet, Rev 3 286 Freescale Semiconductor
Chapter 16 Development Support 16.1 Introduction Development support systems in the HCS08 include the background debug controller (BDC) and the on-chip debug module (DBG). The BDC provides a single-wire debug interface to the target MCU that provides a convenient interface for programming the on-chip Flash and other nonvolatile memories.
Chapter 16 Development Support 16.1.
Chapter 16 Development Support • Non-intrusive commands can be executed at any time even while the user’s program is running. Non-intrusive commands allow a user to read or write MCU memory locations or access status and control registers within the background debug controller. Typically, a relatively simple interface pod is used to translate commands from a host computer into commands for the custom serial interface to the single-wire background debug system.
Chapter 16 Development Support When no debugger pod is connected to the 6-pin BDM interface connector, the internal pullup on BKGD chooses normal operating mode. When a debug pod is connected to BKGD it is possible to force the MCU into active background mode after reset. The specific conditions for forcing active background depend upon the HCS08 derivative (refer to the introduction to this Development Support section).
Chapter 16 Development Support Figure 16-2 shows an external host transmitting a logic 1 or 0 to the BKGD pin of a target HCS08 MCU. The host is asynchronous to the target so there is a 0-to-1 cycle delay from the host-generated falling edge to where the target perceives the beginning of the bit time. Ten target BDC clock cycles later, the target senses the bit level on the BKGD pin.
Chapter 16 Development Support Figure 16-3 shows the host receiving a logic 1 from the target HCS08 MCU. Because the host is asynchronous to the target MCU, there is a 0-to-1 cycle delay from the host-generated falling edge on BKGD to the perceived start of the bit time in the target MCU. The host holds the BKGD pin low long enough for the target to recognize it (at least two target BDC cycles).
Chapter 16 Development Support Figure 16-4 shows the host receiving a logic 0 from the target HCS08 MCU. Because the host is asynchronous to the target MCU, there is a 0-to-1 cycle delay from the host-generated falling edge on BKGD to the start of the bit time as perceived by the target MCU. The host initiates the bit time but the target HCS08 finishes it.
Chapter 16 Development Support 16.2.3 BDC Commands BDC commands are sent serially from a host computer to the BKGD pin of the target HCS08 MCU. All commands and data are sent MSB-first using a custom BDC communications protocol. Active background mode commands require that the target MCU is currently in the active background mode while non-intrusive commands may be issued at any time whether the target MCU is in active background mode or running a user application program.
Chapter 16 Development Support Table 16-1. BDC Command Summary Command Mnemonic 1 Active BDM/ Non-intrusive Coding Structure Description SYNC Non-intrusive n/a1 Request a timed reference pulse to determine target BDC communication speed ACK_ENABLE Non-intrusive D5/d Enable acknowledge protocol. Refer to Freescale document order no. HCS08RMv1/D. ACK_DISABLE Non-intrusive D6/d Disable acknowledge protocol. Refer to Freescale document order no. HCS08RMv1/D.
Chapter 16 Development Support The SYNC command is unlike other BDC commands because the host does not necessarily know the correct communications speed to use for BDC communications until after it has analyzed the response to the SYNC command. To issue a SYNC command, the host: • Drives the BKGD pin low for at least 128 cycles of the slowest possible BDC clock (The slowest clock is normally the reference oscillator/64 or the self-clocked rate/64.
Chapter 16 Development Support 16.3 On-Chip Debug System (DBG) Because HCS08 devices do not have external address and data buses, the most important functions of an in-circuit emulator have been built onto the chip with the MCU. The debug system consists of an 8-stage FIFO that can store address or data bus information, and a flexible trigger system to decide when to capture bus information and what information to capture.
Chapter 16 Development Support the host must perform ((8 – CNT) – 1) dummy reads of the FIFO to advance it to the first significant entry in the FIFO. In most trigger modes, the information stored in the FIFO consists of 16-bit change-of-flow addresses. In these cases, read DBGFH then DBGFL to get one coherent word of information out of the FIFO. Reading DBGFL (the low-order byte of the FIFO data port) causes the FIFO to shift so the next word of information is available at the FIFO data port.
Chapter 16 Development Support A force-type breakpoint waits for the current instruction to finish and then acts upon the breakpoint request. The usual action in response to a breakpoint is to go to active background mode rather than continuing to the next instruction in the user application program. The tag vs. force terminology is used in two contexts within the debug module. The first context refers to breakpoint requests from the debug module to the CPU.
Chapter 16 Development Support A-Only — Trigger when the address matches the value in comparator A A OR B — Trigger when the address matches either the value in comparator A or the value in comparator B A Then B — Trigger when the address matches the value in comparator B but only after the address for another cycle matched the value in comparator A. There can be any number of cycles after the A match and before the B match.
Chapter 16 Development Support 16.3.6 Hardware Breakpoints The BRKEN control bit in the DBGC register may be set to 1 to allow any of the trigger conditions described in Section 16.3.5, “Trigger Modes,” to be used to generate a hardware breakpoint request to the CPU. TAG in DBGC controls whether the breakpoint request will be treated as a tag-type breakpoint or a force-type breakpoint. A tag breakpoint causes the current opcode to be marked as it enters the instruction queue.
Chapter 16 Development Support 16.4.1.1 BDC Status and Control Register (BDCSCR) This register can be read or written by serial BDC commands (READ_STATUS and WRITE_CONTROL) but is not accessible to user programs because it is not located in the normal memory map of the MCU. 7 R 6 5 4 3 BKPTEN FTS CLKSW BDMACT ENBDM 2 1 0 WS WSF DVF W Normal Reset 0 0 0 0 0 0 0 0 Reset in Active BDM: 1 1 0 0 1 0 0 0 = Unimplemented or Reserved Figure 16-5.
Chapter 16 Development Support Table 16-2. BDCSCR Register Field Descriptions (continued) Field Description 2 WS Wait or Stop Status — When the target CPU is in wait or stop mode, most BDC commands cannot function. However, the BACKGROUND command can be used to force the target CPU out of wait or stop and into active background mode where all BDC commands work.
Chapter 16 Development Support R 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 BDFR1 W Reset 0 0 0 0 0 0 0 0 = Unimplemented or Reserved 1 BDFR is writable only through serial background mode debug commands, not from user programs. Figure 16-6. System Background Debug Force Reset Register (SBDFR) Table 16-3.
Chapter 16 Development Support 16.4.3.5 Debug FIFO High Register (DBGFH) This register provides read-only access to the high-order eight bits of the FIFO. Writes to this register have no meaning or effect. In the event-only trigger modes, the FIFO only stores data into the low-order byte of each FIFO word, so this register is not used and will read 0x00. Reading DBGFH does not cause the FIFO to shift to the next word.
Chapter 16 Development Support 16.4.3.7 Debug Control Register (DBGC) This register can be read or written at any time. 7 6 5 4 3 2 1 0 DBGEN ARM TAG BRKEN RWA RWAEN RWB RWBEN 0 0 0 0 0 0 0 0 R W Reset Figure 16-7. Debug Control Register (DBGC) Table 16-4. DBGC Register Field Descriptions Field Description 7 DBGEN Debug Module Enable — Used to enable the debug module. DBGEN cannot be set to 1 if the MCU is secure.
Chapter 16 Development Support 16.4.3.8 Debug Trigger Register (DBGT) This register can be read any time, but may be written only if ARM = 0, except bits 4 and 5 are hard-wired to 0s. 7 6 TRGSEL BEGIN 0 0 R 5 4 0 0 3 2 1 0 TRG3 TRG2 TRG1 TRG0 0 0 0 0 W Reset 0 0 = Unimplemented or Reserved Figure 16-8. Debug Trigger Register (DBGT) Table 16-5.
Chapter 16 Development Support 16.4.3.9 Debug Status Register (DBGS) This is a read-only status register. R 7 6 5 4 3 2 1 0 AF BF ARMF 0 CNT3 CNT2 CNT1 CNT0 0 0 0 0 0 0 0 0 W Reset = Unimplemented or Reserved Figure 16-9. Debug Status Register (DBGS) Table 16-6. DBGS Register Field Descriptions Field Description 7 AF Trigger Match A Flag — AF is cleared at the start of a debug run and indicates whether a trigger match A condition was met since arming.
Appendix A Electrical Characteristics A.1 Introduction This section contains the most accurate electrical and timing information for the MC9S08DN60 Series of microcontrollers available at the time of publication. A.2 Parameter Classification The electrical parameters shown in this supplement are guaranteed by various methods. To give the customer a better understanding the following classification is used and the parameters are tagged accordingly in the tables where appropriate: Table A-1.
Appendix A Electrical Characteristics This device contains circuitry protecting against damage due to high static voltage or electrical fields; however, it is advised that normal precautions be taken to avoid application of any voltages higher than maximum-rated voltages to this high-impedance circuit. Reliability of operation is enhanced if unused inputs are tied to an appropriate logic voltage level (for instance, either VSS or VDD). Table A-2.
Appendix A Electrical Characteristics Table A-3. Thermal Characteristics Num C 1 D Symbol Value Unit Temp.
Appendix A Electrical Characteristics where K is a constant pertaining to the particular part. K can be determined from equation 3 by measuring PD (at equilibrium) for a known TA. Using this value of K, the values of PD and TJ can be obtained by solving equations 1 and 2 iteratively for any value of TA. A.
Appendix A Electrical Characteristics A.6 DC Characteristics This section includes information about power supply requirements, I/O pin characteristics, and power supply current in various operating modes. Table A-6. DC Characteristics Num 1 C Typ1 Max Unit 2.7 V — 5.5 — — C 3 V, ILoad = –0.6 mA VDD – 1.5 — — C Output high C voltage 5 V, ILoad = –0.4 mA VDD – 0.8 — — 3 V, ILoad = –0.24 mA VDD – 0.8 5 V, ILoad = –10 mA VDD – 1.5 — — — — C 3 V, ILoad = –3 mA VDD – 1.
Appendix A Electrical Characteristics Table A-6. DC Characteristics (continued) Num 14 C Min Typ1 Max Unit VPOR 0.9 1.4 2.0 V tPOR 10 — — μs 3.9 4.0 4.0 4.1 4.1 4.2 V 2.48 2.54 2.56 2.62 2.64 2.70 V 4.5 4.6 4.6 4.7 4.7 4.8 V 4.2 4.3 4.3 4.4 4.4 4.5 V 2.84 2.90 2.92 2.98 3.00 3.06 V 2.66 2.72 2.74 2.80 2.82 2.88 V 5V — 100 — 3V — 60 — VIN > VDD 0 — 2 VIN < VSS 0 — –0.2 VIN > VDD 0 — 25 VIN < VSS 0 — –5 1.19 1.20 1.
Appendix A Electrical Characteristics 7 Input must be current limited to the value specified. To determine the value of the required current-limiting resistor, calculate resistance values for positive and negative clamp voltages, then use the larger of the two values. 8 PTE1 does not have a clamp diode to VDD. Do not drive PTE1 above VDD. A.7 Supply Current Characteristics Table A-7.
Appendix A Electrical Characteristics Table A-7. Supply Current Characteristics (continued) Num C 6 C Parameter Symbol VDD (V) Typical1 Max2 Unit 5 300 — nA 3 300 — nA 5 110 — μA 3 90 — μA 5 5 — μA 3 5 — μA RTC adder to stop2 or stop35, 25°C LVD adder to stop3 (LVDE = LVDSE = 1) 7 C 8 1 2 3 4 5 6 A.8 C Adder to stop3 for oscillator enabled6 (IRCLKEN = 1 and IREFSTEN = 1 or ERCLKEN = 1 and EREFSTEN = 1) Typicals are measured at 25°C, unless otherwise noted.
Appendix A Electrical Characteristics Table A-9. 12-bit ADC Operating Conditions (continued) Symb Min Typ1 Max Unit Comment Ref Voltage High VREFH 2.7 VDDAD VDDAD V Applicable in only 64-pin packages {VREFH < VDDAD characterized but not production test} Ref Voltage Low VREFL VSSAD VSSAD VSSAD V Not Applicable in 64-pin packages (only 32- and 48-pin packages) Input Voltage VADIN VREFL — VREFH V Input Capacitance CADIN — 4.5 5.
Appendix A Electrical Characteristics SIMPLIFIED INPUT PIN EQUIVALENT CIRCUIT ZADIN SIMPLIFIED CHANNEL SELECT CIRCUIT Pad leakage due to input protection ZAS RAS ADC SAR ENGINE RADIN + VADIN VAS – CAS + – RADIN INPUT PIN RADIN INPUT PIN RADIN INPUT PIN CADIN Figure A-1. ADC Input Impedance Equivalency Diagram Table A-10.
Appendix A Electrical Characteristics Table A-10. 12-bit ADC Characteristics (VREFH = VDDAD, VREFL = VSSAD) (continued) Characteristic Conditions C Symb Min Typ1 Max Unit Comment Conversion Time (Including sample time) Short Sample (ADLSMP=0) D tADC — 20 — — 40 — ADCK cycles Sample Time Short Sample (ADLSMP=0) — 3.5 — See Table 10-13 for conversion time variances — 23.5 — — ±3.
Appendix A Electrical Characteristics 3 4 Monotonicity and No-Missing-Codes guaranteed in 10 bit and 8 bit modes Based on input pad leakage current. Refer to pad electricals. A.10 External Oscillator (XOSC) Characteristics Table A-11. Oscillator Electrical Specifications (Temperature Range = –40 to 125°C Ambient) Num C Rating Symbol Min Typ1 Max Unit Oscillator crystal or resonator (EREFS = 1, ERCLKEN = 1 Low range (RANGE = 0) C 1 flo 32 — 38.
Appendix A Electrical Characteristics MCU EXTAL XTAL RS RF C1 A.11 Crystal or Resonator C2 MCG Specifications Table A-12. MCG Frequency Specifications (Temperature Range = –40 to 125°C Ambient) Num C Rating Symbol Min Typical Max Unit 1 P Internal reference frequency - factory trimmed at VDD = 5 V and temperature = 25 °C fint_ft — 31.25 — kHz 2 P Average internal reference frequency untrimmed 1 fint_ut 25 32.7 41.
Appendix A Electrical Characteristics Table A-12. MCG Frequency Specifications (Temperature Range = –40 to 125°C Ambient) (continued) Num C 1 2 3 4 5 6 7 8 Rating Symbol Min Typical Max Unit 18 T RMS frequency variation of a single clock cycle measured 625 ns after reference edge.6 fpll_cycjit_625ns — 0.5664 — %fpll 19 T Maximum frequency variation averaged over 625 ns window. fpll_maxjit_625ns — 0.113 — %fpll 20 D Lock entry frequency tolerance 7 Dlock ± 1.49 — ± 2.
Appendix A Electrical Characteristics A.12 AC Characteristics This section describes ac timing characteristics for each peripheral system. A.12.1 Control Timing Table A-13. Control Timing Nu m C 1 D/ P 2 Symbol Min Typical1 Max Unit Bus frequency (tcyc = 1/fBus) fBus dc — 20 MHz T Internal low-power oscillator period tLPO — 1500 — μs 3 D External reset pulse width2 textrst 1.
Appendix A Electrical Characteristics BKGD/MS RESET tMSH tMSSU Figure A-3. Active Background Debug Mode Latch Timing tIHIL PIAx/PIBx/PIDx IRQ/PIAx/PIBx/PIDx tILIH Figure A-4. Pin Interrupt Timing A.12.2 Timer/PWM Synchronizer circuits determine the shortest input pulses that can be recognized or the fastest clock that can be used as the optional external source to the timer counter. These synchronizers operate from the current bus rate clock. Table A-14.
Appendix A Electrical Characteristics tTCLK tclkh TPMxCHn tclkl Figure A-5. Timer External Clock tICPW TPMxCHn TPMxCHn tICPW Figure A-6.
Appendix A Electrical Characteristics A.12.3 SPI Table A-15 and Figure A-7 through Figure A-10 describe the timing requirements for the SPI system. Table A-15.
Appendix A Electrical Characteristics SS1 (OUTPUT) 1 2 SCK (CPOL = 0) (OUTPUT) 3 5 4 SCK (CPOL = 1) (OUTPUT) 5 4 6 MISO (INPUT) 7 MSB IN2 BIT 6 . . . 1 10 MOSI (OUTPUT) LSB IN 10 MSB OUT2 11 BIT 6 . . . 1 LSB OUT NOTES: 1. SS output mode (MODFEN = 1, SSOE = 1). 2. LSBF = 0. For LSBF = 1, bit order is LSB, bit 1, ..., bit 6, MSB. Figure A-7.
Appendix A Electrical Characteristics SS (INPUT) 3 1 SCK (CPOL = 0) (INPUT) 5 4 2 SCK (CPOL = 1) (INPUT) 5 4 8 MISO (OUTPUT) 11 10 BIT 6 . . . 1 MSB OUT SLAVE SEE NOTE SLAVE LSB OUT 7 6 MOSI (INPUT) 9 BIT 6 . . . 1 MSB IN LSB IN NOTE: 1. Not defined but normally MSB of character just received Figure A-9. SPI Slave Timing (CPHA = 0) SS (INPUT) 1 3 2 SCK (CPOL = 0) (INPUT) 5 4 SCK (CPOL = 1) (INPUT) 5 4 10 MISO (OUTPUT) SEE NOTE 8 MOSI (INPUT) SLAVE 11 MSB OUT 6 BIT 6 . . .
Appendix A Electrical Characteristics A.13 Flash and EEPROM This section provides details about program/erase times and program-erase endurance for the Flash and EEPROM memory. Program and erase operations do not require any special power sources other than the normal VDD supply. For more detailed information about program/erase operations, see Chapter 4, “Memory.” Table A-16. Flash and EEPROM Characteristics Num C 1 — 2 Symbol Min Max Unit Supply voltage for program/erase Vprog/erase 2.7 5.
Appendix A Electrical Characteristics A.14 EMC Performance Electromagnetic compatibility (EMC) performance is highly dependant on the environment in which the MCU resides. Board design and layout, circuit topology choices, location and characteristics of external components as well as MCU software operation all play a significant role in EMC performance.
Appendix B Timer Pulse-Width Modulator (TPMV2) NOTE This chapter refers to S08TPM version 2, which applies to the 3M05C and older mask sets of this device. )M74K and newer mask set devices use S08TPM version 3. If your device uses mask 0M74K or newer, please refer to Chapter 15, “Timer Pulse-Width Modulator (S08TPMV3) for information pertaining to that module.
Appendix B Timer Pulse-Width Modulator (TPMV2) BUSCLK XCLK TPMxCLK SYNC CLOCK SOURCE SELECT OFF, BUS, XCLK, EXT CLKSB PRESCALE AND SELECT DIVIDE BY 1, 2, 4, 8, 16, 32, 64, or 128 PS2 CLKSA PS1 PS0 CPWMS MAIN 16-BIT COUNTER TOF COUNTER RESET INTERRUPT LOGIC TOIE 16-BIT COMPARATOR TPMxMODH:TPMxMODL CHANNEL 0 ELS0B ELS0A PORT LOGIC 16-BIT COMPARATOR TPMxC0VH:TPMxC0VL CH0F INTERRUPT LOGIC 16-BIT LATCH INTERNAL BUS CHANNEL 1 MS0B MS0A ELS1B ELS1A CH0IE TPMxCH1 PORT LOGIC 16-BIT COMPA
Appendix B Timer Pulse-Width Modulator (TPMV2) All TPM channels are programmable independently as input capture, output compare, or buffered edge-aligned PWM channels. B.1 External Signal Description When any pin associated with the timer is configured as a timer input, a passive pullup can be enabled. After reset, the TPM modules are disabled and all pins default to general-purpose inputs with the passive pullups disabled. B.1.
Appendix B Timer Pulse-Width Modulator (TPMV2) Freescale-provided equate or header file is used to translate these names into the appropriate absolute addresses. B.2.1 Timer Status and Control Register (TPMxSC) TPMxSC contains the overflow status flag and control bits that are used to configure the interrupt enable, TPM configuration, clock source, and prescale divisor. These controls relate to all channels within this timer module.
Appendix B Timer Pulse-Width Modulator (TPMV2) Table B-2. TPM Clock Source Selection CLKSB:CLKSA TPM Clock Source to Prescaler Input 0:0 No clock selected (TPMx disabled) 0:1 Bus rate clock (BUSCLK) 1:0 Fixed system clock (XCLK) 1:1 External source (TPMxCLK)1,2 1 The maximum frequency that is allowed as an external clock is one-fourth of the bus frequency.
Appendix B Timer Pulse-Width Modulator (TPMV2) R 7 6 5 4 3 2 1 0 Bit 7 6 5 4 3 2 1 Bit 0 0 0 W Reset Any write to TPMxCNTL clears the 16-bit counter. 0 0 0 0 0 0 Figure B-4. Timer Counter Register Low (TPMxCNTL) When background mode is active, the timer counter and the coherency mechanism are frozen such that the buffer latches remain in the state they were in when the background mode became active even if one or both bytes of the counter are read while background mode is active.
Appendix B Timer Pulse-Width Modulator (TPMV2) B.2.4 Timer Channel n Status and Control Register (TPMxCnSC) TPMxCnSC contains the channel interrupt status flag and control bits that are used to configure the interrupt enable, channel configuration, and pin function. 7 6 5 4 3 2 CHnF CHnIE MSnB MSnA ELSnB ELSnA 0 0 0 0 0 0 R 1 0 0 0 0 0 W Reset = Unimplemented or Reserved Figure B-7. Timer Channel n Status and Control Register (TPMxCnSC) Table B-4.
Appendix B Timer Pulse-Width Modulator (TPMV2) Table B-5.
Appendix B Timer Pulse-Width Modulator (TPMV2) In input capture mode, reading either byte (TPMxCnVH or TPMxCnVL) latches the contents of both bytes into a buffer where they remain latched until the other byte is read. This latching mechanism also resets (becomes unlatched) when the TPMxCnSC register is written. In output compare or PWM modes, writing to either byte (TPMxCnVH or TPMxCnVL) latches the value into a buffer.
Appendix B Timer Pulse-Width Modulator (TPMV2) As an up-counter, the main 16-bit counter counts from 0x0000 through its terminal count and then continues with 0x0000. The terminal count is 0xFFFF or a modulus value in TPMxMODH:TPMxMODL. When center-aligned PWM operation is specified, the counter counts upward from 0x0000 through its terminal count and then counts downward to 0x0000 where it returns to up-counting.
Appendix B Timer Pulse-Width Modulator (TPMV2) An input capture event sets a flag bit (CHnF) that can optionally generate a CPU interrupt request. B.3.2.2 Output Compare Mode With the output compare function, the TPM can generate timed pulses with programmable position, polarity, duration, and frequency. When the counter reaches the value in the channel value registers of an output compare channel, the TPM can set, clear, or toggle the channel pin.
Appendix B Timer Pulse-Width Modulator (TPMV2) the value in the TPMxCNTH:TPMxCNTL counter is 0x0000. (The new duty cycle does not take effect until the next full period.) B.3.3 Center-Aligned PWM Mode This type of PWM output uses the up-/down-counting mode of the timer counter (CPWMS = 1). The output compare value in TPMxCnVH:TPMxCnVL determines the pulse width (duty cycle) of the PWM signal and the period is determined by the value in TPMxMODH:TPMxMODL.
Appendix B Timer Pulse-Width Modulator (TPMV2) Because the HCS08 is a family of 8-bit MCUs, the settings in the timer channel registers are buffered to ensure coherent 16-bit updates and to avoid unexpected PWM pulse widths. Writes to any of the registers, TPMxMODH, TPMxMODL, TPMxCnVH, and TPMxCnVL, actually write to buffer registers.
Appendix B Timer Pulse-Width Modulator (TPMV2) at the transition from the value set in the modulus register and the next lower count value. This corresponds to the end of a PWM period. (The 0x0000 count value corresponds to the center of a period.) B.4.3 Channel Event Interrupt Description The meaning of channel interrupts depends on the current mode of the channel (input capture, output compare, edge-aligned PWM, or center-aligned PWM).
Appendix C Ordering Information and Mechanical Drawings C.1 Ordering Information This section contains ordering information for MC9S08DN60 Series devices.
Appendix C Ordering Information and Mechanical Drawings Table C-2. Package Descriptions Pin Count 64 Type Low Quad Flat Package Abbreviation Designator Document No.
How to Reach Us: Home Page: www.freescale.com E-mail: support@freescale.com USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 support@freescale.