ELMICRO S12compact Versatile Controller Module

Specyfikacje
- Model: S12compact
- Wersja sprzętu: 1.10
- Mikrokontrolery Unit: MC9S12DG256
- Pamięć Flash: 256 KB
- BARAN: 12 KB
- EEPROM: 4 KB
- Wymiary: Half-Euro form factor, 80mm x 100mm
Instrukcje użytkowania produktu
Nadview
- The S12compact is a versatile controller module based on the HCS12 16-bit microcontroller family from Motorola.
- It combines compact size with powerful computing features and a rich set of peripherals, suitable for industrial controllers, measuring devices, and data loggers.
Szybki start
- Refer to the quick start guide included in the package for initial setup instructions.
Parts Location Diagram
- Use the provided parts location diagram to identify different components on the S12compact module.
Jumpers and Solder Bridges
- Understand the jumpers and solder bridges on the module for configuring connections as needed.
Mapa pamięci
- Refer to the memory map section for information on memory allocation and usage.
WSTĘP
- This manual and the product described herein were designed carefully by the manufacturer. We have made every effort to avoid mistakes, but we cannot guarantee that it is 100% free of errors.
- The manufacturer’s entire liability and your exclusive remedy shall be, at the manufacturer’s option, return of the price paid or repair or replacement of the product.
- The manufacturer disclaims all other warranties, either expressed or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with respect to the product, including accompanying written material, hardware, and firmware.
- In no event shall the manufacturer or its supplier be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the product, even if the manufacturer has been advised of the possibility of such damages. The product is not designed, intended, or authorized for use in applications in which the failure of the product could create a situation where personal injury or death may occur. Should you use the product for any such unintended or unauthorized application, you shall indemnify and hold the manufacturer and its suppliers harmless against all claims, even if such a claim alleges that the manufacturer was negligent regarding the design or implementation of the product.
- Product features and prices may change without notice.
- Wszystkie znaki towarowe są własnością ich odpowiednich właścicieli.
Nadview
- The S12compact is a versatile controller module based on the HCS12 16-bit microcontroller family from Motorola. It combines compact size (Half-Euro form factor, 80mm x 100mm) with powerful computing features and a rich set of peripherals. The controller module can be used for a wide range of applications, e.g., industrial controllers, measuring devices, and data loggers.
- The S12compact is equipped with an MC9S12DG256 microcontroller unit (MCU). It contains a 16-bit HCS12 CPU, 256KB of Flash memory, 12KB RAM, 4KB EEPROM, and a large number of peripheral function blocks, such as SCI, SPI, CAN, IIC, Timer, PWM, ADC, and General-Purpose I/Os. The MC9S12DG256 has full 16-bit data paths throughout. An integrated PLL-circuit allows adjusting performance vs. current consumption according to the needs of the user application.
- In addition to the on-chip controller functions, the S12compact module provides many useful peripheral options: 16-bit
- A/D-Converter and 16-bit D/A-Converter including precision voltage reference, battery-backed Real Time Clock (RTC), USB-Interface and 2MB (16Mbit) extra memory using Serial Data Flash.
- For HCS12 microcontrollers, a wide range of software tools (Monitors, C-Compilers, BDM-Debuggers) is available to accelerate the development process.
Dane techniczne
- MCU MC9S12DG256 with LQFP112 package (SMD)
- HCS12 16-bit CPU, uses the same programming model and command set as the HC12
- 16 MHz crystal clock, up to 25 MHz bus clock using PLL
- 256KB Flash
- 4 KB pamięci EEPROM
- 12 KB pamięci RAM
- 2x SCI – asynch. serial Interface (e.g. RS232, LIN)
- 3x SPI – synch. serial Interface
- 1x IIC – Inter-IC-Bus
- 2x msCAN-Module (CAN 2.0A/B-compatible)
- 8x 16-Bit Timer (Input Capture/Output Compare)
- 8x PWM (Pulse Width Modulator)
- 16-channel 10-bit A/D-Converter
- BDM – Background Debug Mode Interface
- Special LVI-Circuit (Reset Controller)
- BDM-Connector for Download and Debugging
- Serial Interface with RS232-Transceiver (for PC connection)
- Second serial port for IF-Modules (RS232, RS485, LIN…)
- Indicator-LED
- Sound Transducer (Buzzer)
- High-Speed phys. CAN-Interface
- Przycisk resetowania
- up to 70 free General-Purpose-I/Os
- eight additional digital inputs
- eight additional digital outputs
- Objętość operacyjnatage 5V, current consumption 70 mA typ.
- Mech. Dimensions: 80mm x 100mm
Komponenty opcjonalne
- Option RTC: battery-backed Real Time Clock
- Option ADC: 8-channel 16-bit A/D-Converter (4096mV)
- Option DAC: 2-channel 16-bit D/A-Converter (4096mV)
- Option USB: Full-speed USB2.0 Interface (uses second SCI)
- Option SDF: 2MB (16Mbit) Serial Data Flash
Zawartość opakowania
- Controller Module (with options as ordered)
- D-Bug12 Monitor (in the MCU’s Flash Memory)
- RS232 Cable (Sub-D9)
- USB Cable (only for option /USB)
- set of header connectors (two 72-pin male headers)
- Instrukcja obsługi (ten dokument)
- Schematy
- CD-ROM: contains assembler software, data sheets, CPU12
- Reference Manual, code examples, C-Compiler (evaluation version), etc.
Szybki start
- Nobody likes to read big manuals. For that reason we will summarize the most important things in the following section. If you need additional information, please refer to the more detailed sections of this manual.
Here is how you can start:
- Please check the board for any damage due to transportation
- Connect the Controller Module via RS232 to a PC. The connection between S12compact (interface SCI0, connector X2) and PC is simply made using the flat cable, which is in the box.
- On the PC, start a Terminal Program. An easy-to-use Terminal
- The program is OC-Console, which is available at no charge from our Webstrona!
- Select a baudrate of 9600 Bd. Disable all hardware or software protocols.
- Connect a (stabilized!) Power supply, for instance, at this point:
- Ground on X4 pin 70
- +5V on X4 pin 72
- But at first: double-check voltage and polarity!
- Once powered up, the Monitor Program starts and displays a short message. The Prompt appears, and now the Module is waiting for your commands.
- We hope you will enjoy working with the S12compact Controller Module!
Parts Location Diagram

Jumpers and Solder Bridges
Swetry
- There are no jumpers on the S12compact.
Mostki lutowane
- On the solder side of the module, the following solder bridges can be found.
BR1: VRH- An Otwarte external supply of VRH is required
- closed* VRH connected to VDDA (VCC) on-board
- BR2: CANR
- open no CAN-Bus termination on-board
- closed* on-board CAN-Bus termination active
- BR3: BUZZ
- Otwarte Port pin PT2 freely available
- closed* PT2 controls buzzer
- BR4: T1IN
- Otwarte Port pin TXD0 (PS1) freely available
- closed* TXD0 connected to RS232 Transceiver IC3
- BR5: T2IN
- Otwarte Port pin PM3 freely available
- closed* PM3 connected to RS232 Transceiver IC3
- BR6: R1OUT
- open Port pin RXD0 (PS0) freely available
- closed* RXD0 conn`ected to RS232 Transceiver IC3
- Domyślne ustawienie fabryczne
- BR7: R2OUT
- open Port pin PM2 freely available
- closed* PM2 connected to RS232 Transceiver IC3
- BR8: TPOUT
- open* TPOUT and /IRQ not connected
- closed TPOUT connected to /IRQ, Real Time Clock IC7 can issue an interrupt
- BR9: VREF
- An open external supply of VREF required
- closed* IC10 delivers reference voltage VREF for the 16-bit A/D-Converter IC11 and the 16-Bit
- D/A-Converter IC12
- BR10: DFLE
- open Port pin MISO1 (PH0) freely available
- closed* MISO1 connected to buffer IC6B (Serial Data Flash)
- BR11: USBR
- open* Reset input of USB Transceiver IC15 and system reset signal /RESET not connected
- closed system /RESET also resets the USB Transceiver
- Domyślne ustawienie fabryczne
Wymiary mechaniczne
- The following table summarizes the mechanical dimensions of the S12compact. The values provide a basis for the design of carrier boards, etc. Please note: Always check all mechanical dimensions using the real hardware module!
- The reference point (0,0) is located at the “south/west” corner of the PCB. The PCB is orientated vertically, as shown in the Parts Location Diagram (see above).
- All data for holes/drills (B) refer to the center of the hole/drill; connectors (X) are referenced by pin 1.
| X
w mm |
Y
w mm |
|
| X1A | 19,5 | 3,2 |
| X1B | 32,2 | 3,2 |
| X2 | 14,8 | 93,8 |
| X3 | 36,4 | 86,4 |
| X4 | 4,5 | 3,0 |
| X5 | 78,1 | 3,0 |
| X6 | 37,8 | 92,3 |
| X7 | 24,4 | 23,3 |
| X8 | 64,4 | 23,3 |
| B1 | 3,0 | 97,0 |
| B2 | 77,0 | 97,0 |
| B3 | 70,0 | 3,0 |
| Płytka drukowana | 80,0 | 100,0 |
Opis obwodu
Schematyczny diagram
To ensure the best visibility of all details, the schematic diagram of the S12compact controller module is provided as a separate document.
Controller Core, Power Supply
- Nominalna objętość roboczatage of the MC9S12DG256 is 5V. This MCU (IC1) has three supply pin pairs: VDDR/VSSR, VDDX/VSSX, and VDDA/VSSA. Internally, the MCU uses a core voltage of only 2.5V. The necessary voltage regulator is already included in the chip, as well as 5V I/O-buffers for all general-purpose input/output pins. Therefore, the MCU behaves like a 5V device from an external point of view. There is just one exception: the signals for oscillator and PLL are based on the core voltage and must not be driven by 5V levels. A high level on the pin VREGEN is needed to enable the internal voltagregulator.
- The three terminal pairs mentioned above must be decoupled carefully. A ceramic capacitor of at least 100nF should be connected directly to each pair (C15, C16, C17).
- It is recommended to add a 10µF (electrolytic or tantalum) capacitor per node, especially if some MCU port pins are loaded heavily (C5, C6, C7).
- Special care must be taken with VDDA, since this is the reference point (VDDA/2) for the internal voltagregulator.
- The internal core voltage appears at the pin pairs VDD1/VSS1, VDD2/VSS2, and VDDPLL/VSSPLL, which have to be decoupled as well (C19, C20, C21). A static current drawn from these terminals is not allowed.
- This is especially true for VDDPLL, which serves as the reference point for the external PLL loop filter combination (R3, C3, C4).
- There are two MCU pins (VRH/VRL) to define the upper and lower voltage limits for the internal analog-to-digital (ATD) converter. While VRL is grounded, VRH is usually tied to VDDA. C18 is used for decoupling.
- VRH can be supplied externally after opening the solder bridge BR1. This can be useful if the main supply is not in the desired tolerance band or if the ATD should work with a reference value lower than 5V.
- VRH must not exceed VDDA, regardless of the selected supply mode.
- The TEST pin is used for factory testing only; in an application circuit, this pin always has to be grounded.
Reset Generation
- RESET is the MCU’s active low bidirectional reset pin. As an input, it initializes the MCU asynchronously to a known start-up state. As an open-drain output, it indicates that a system reset (internal to the MCU) has been triggered.
- The HCS12 MCUs already contain on-chip reset generation circuitry, including power-on reset, COP watchdog timer, and clock monitor. It is, however, necessary to add an external Low Voltage Inhibit (LVI) circuit, also referred to as “reset controller”.
- The task of this reset controller is to issue a stable reset condition if the power supply falls below the level required for proper MCU operation.
- To prevent collisions with the bidirectional /RESET pin of the MCU, the LVI circuit IC2 has an open-drain output. In the inactive state, it is pulled up high by the resistor R6.
- The detector threshold of IC2 is typically 4.6V, which is slightly higher than the required minimum MCU operating voltage 4.5V.
- Furthermore, IC2 is capable of stretching the reset output to filter out short pulses on the power supply effectively. The duration of that delay can be selected using the capacitor C14. A value of 100nF results in a delay of approx 50..80ms.
It is important to note that this delay will only be applied during a power cycle event. IC2 will not stretch pulses coming from the MCU’s internal reset sources. This is essentially important, since otherwise the MCU would not be able to detect the source of a - reset. This would finally lead to a wrong reset vector fetch and could result in a system software crash. Please be aware that a capacitor on the reset line would also cause the same fatal effect, as external circuitry connected to the /RESET pin of a HC12/HCS12
- MCU should never include a large capacitance!
Clock Generation and PLL
- The on-chip oscillator of the MC9S12DG256 can generate the primary clock (OSCCLK) using a quartz crystal (Q1) connected between the EXTAL and XTAL pins. The allowed frequency range is 0.5 to 16MHz. As usual, two load capacitors are part of the oscillator circuit (C1, C2). However, this circuit is modified compared to the standard Pierce oscillator that was used for the HC11 or most HC12 derivatives.
- The MC9S12DG256 uses a Colpitts oscillator with a translated ground scheme. The main advantage is a very low current consumption, though the component selection is more critical. The S12compact circuit uses a 16MHz automotive quartz from NDK together with two load capacitors of only 3.9pF. Furthermore, special care was taken for the PCB design to introduce as little stray capacitance as possible with respect to XTAL and EXTAL.
- With an OSCCLK of 16MHz, the internal bus speed (ECLK) becomes 8MHz by default. To realize higher bus clock rates, the PLL has to be engaged.
- The MC9S12DG256 can be operated with a bus speed of up to 25MHz, though most designs use 24MHz because this value is a better basis to generate a wide range of SCI baud rates.
- A passive external loop filter must be placed on the XFC pin. The filter (R3, C3, C4) is a second-order, low-pass filter to eliminate the VCO input ripple.
- The value of the external filter network and the reference frequency determine the speed of the corrections and the stability of the PLL. If PLL usage is not required, the XFC pin must be tied to VDDPLL.
- The choice of filter component values is always a compromise over lock time and stability of the loop. 5 to 10kHz loop bandwidth and a damping factor of 0.9 are a good starting point for the calculations.
- With a quartz frequency of 16MHz and a desired bus clock of 24MHz, a possible choice is R3 = 4.7k and C3 = 22nF. C4 should be approximately (1/20..1/10) x C3, e.g. 2.2nF in our case. These values
are suitable for a reference frequency of 1MHz (Note: to be defined in example file S12_CRG.H). The according reference divider register value is REFDV=15, and the synthesizer register setting becomes SYNR=23. - Please refer to the chapter “XFC Component
- Selection” in the MC9S12DP256B Device User Guide for a detailed description of how to calculate values for other system configurations.
- The following source listing shows the steps required to initialize the PLL.

- An alternative, external clock source can be used for the MC9S12DG256 if the internal oscillator and PLL are disabled by applying a low level to the /XCLKS pin during reset.
- Since this option is not used on the S12compact Controller Module, R5 is used to pull /XCLKS high. Please note that other HCS12 derivatives will have different features associated with the /XCLKS pin.
Operating Modes, BDM Support
- Three pins of the HCS12 are used to select the MCU operating mode: MODA, MODB, and BKGD (=MODC). While MODA and MODB are pulled low (R1, R2) to select Single Chip Mode, BKGD is pulled high (R7) by default. As a consequence, the MCU will start in Normal Single Chip Mode, which is the most common operating mode for application code running on the HCS12.
- The HCS12 operating mode used for download and debugging is called Background Debug Mode (BDM). BDM is active immediately out of reset if the mode pins MODA/MODB/BKGD are configured for Special Single Chip Mode.
- This is done by pulling the BKGD pin low during reset, while MODA and MODB are pulled down as well.
- Because only the BKGD level is different for the two modes, it is quite easy to change over.
- However, there is no need to switch the BKGD line manually via a jumper or solder bridge because this can be done by a BDM-Pod (such as ComPOD12) attached to connector X1A. A BDM-Pod is required for BDM-based download and/or debugging anyway, so it can handle this task automatically, usually controlled by a PC-based debugging program.
- The 6-pin header X1A uses the suggested standard BDM12 connector layout. Connector X1B carries additional MCU signals, which are normally not needed for BDM12 debugging.
- Some debuggers, however, provide additional features that rely on the presence of these supplemental signals.
Integrated A/D-Converter
- The MC9S12DG256 contains two 10-bit Analog-to-Digital Conver-ter modules. Each module (ATD0, ATD1) provides eight multiplexed input channels.
- VRH is the upper reference voltage for all A/D-channels. On the S12compact, VRH is connected to VDDA (5V) through solder bridge BR1.
- After opening BR1, it is possible to use an external reference volta-ge, which has to be applied to X5/46. For this purpose, the precision voltage reference IC10 could be used (if present). IC10 delivers 4.096V at X5/71.
- Następujący example program shows the initialization sequence for the A/D-converter module ATD0 and a single-channel conversion routine.
- Źródło file S12_ATD.C also contains some additional functions for the integrated ATD module.

Integrated EEPROM
- The internal EEPROM module of the MC9S12DG256 contains 4KB of memory. It consists of 1024 sectors with 4 bytes (32 bits) per sector. For erasure, any single sector can be selected.
- Programming is done by words (2 bytes). Read accesses can be made to any word or byte.
- After reset, the EEPROM module of the MC9S12DG256 is mapped to address 0x0000. In the lower 1KB area (0x0000..0x03FF), control registers take precedence over EEPROM. In order to use the full EEPROM space, the EEPROM module can be relocated (see INITEE control register).
- W poniższym przykładzieample, the EEPROM module is left at its default position. The initialization sequence just takes care of setting up the EEPROM Clock Divider according to the quartz crystal frequency.
- The write function wrSectEETS() copies two words (4 bytes) from source address src to EEPROM address dest. dest must be identical to an EEPROM sector border (aligned 32-bit value).
- If the sector is not erased (erased state = 0xFFFFFFFF), the routine will perform a sector erase before writing to the sector.
- The access functions readItemEETS() and writeItemEETS() provide a more abstract way to deal with EEPROM contents.
- Instead of using certain addresses, which must be part of the EEPROM address range, these routines use abstract “item numbers”, with each item consisting of a variable amount of data (1 to 4 bytes).


Indicator-LED
- The logic level of port pin PE7 is latched at the rising edge of reset and provides the control signal /XCLKS. This signal is used to select one of two possible clock configurations for the MC9S12DG256.
- High level activates the integrated Colpitts oscillator. After reset, PE7 can be used as a general-purpose I/O-pin. On the S12compact, this signal is used to control the indicator LED D2, driven by buffer IC6C.
- To turn the LED on or off, some simple macros can be used, as shown in the following C header file.

Brzęczyk
- The sound transducer (buzzer) SP1 is driven by buffer IC6D and controlled by the MCU’s port pin PT2, provided the solder bridge BR3 is closed.
- PT2 is connected with one of the eight timer channels of the MCU. Frequency generation is realized using the Output-Compare function of the timer system.
- Następujący example demonstrates how Output-Compare interrupts can be used to generate oscillations in the audible range.

Interfejs RS232
- The MC9S12DG256 provides two asynchronous serial interfaces (SCI0, SCI1). Each interface has one receive line and one transmit line (RXDx, TXDx).
- Handshake lines are not provided by the SCI module, though they can be added by using general-purpose I/O port lines if required.
- IC3 is an industry-standard RS232 line transceiver circuit. It is connected to SCI0, which is the MCU’s first asynchronous serial communications channel. In addition to the receive and transmit lines (RXD0, TXD0), two general purpose I/Os (PM2, PM3) can be used as hardware handshake lines. If the RS232 transceiver IC3 is not needed, the dedicated MCU pins can be used freely after opening the four solder bridges BR4.BR7.
- To connect the S12compact to a PC, a 10-wire flat ribbon cable can be used. The cable must have a 10-pin female header connector at the S12compact side (X2) and a female Sub-D9 connector at the PC side.
- Poniższy kod example shows how to use SCI0 in polling mode.
- Notatka: for using SCI interrupts, please refer to the appropriate mask set errata information document for the MC9S12DP256B.


IF-Module Connection
- SCI1 can be used in two different ways on the S12compact. If the USB option is equipped, SCI1 is used to control the USB-Transceiver IC15 (refer to section USB Interface for details).
- Otherwise, SCI1 can be used as a universal TTL-RS232 (without la evel shifter) to control an external IF-Module.
- IF-Modules are serial interface modules, having a standardized connector definition.
- They are available for different physical interface types, such as RS232, RS485, current-loop, or LIN. IF-Modules can be connected to X3 using a 10-wire flat ribbon cable.
- The I/O signals PM4..7 are associated to SCI1 as handshake lines on the S12compact.
- If there is no IF-Module on X3 and also the USB option is not present, these signals (including RXD1 and TXD1) can be used as general-purpose I/Os.
- They are accessible at connector X4 and X5, respectively.
Interfejs USB
- IC15 (FT232BM) is a USB-UART. This chip provides a transparent conversion from RS232 to USB and back. The communication protocol is implemented according to the current USB specification 2.0.
- The FT232BM belongs to the USB “Full-Speed” device class.
- On the S12compact, the microcontroller can send data over SCI1 to the USB-UART. Thereupon, all data is transferred to he USB-bus and can be accessed using a virtual COM-Port driver on the Host-PC. The required driver software is provided by FTDI, the manufacturer of the FT232BM (see http://www.ftdichip.com). The drivers are free of charge. Currently, there are driver versions for Windows PCs (98 to XP), Apple computers, and Linux systems. \
- On the S12compact supplement CD, drivers (for the Windows platform) are provided as well, though there may exist newer versions on the webstrona.
- To transfer data between USB-UART and the microcontroller, only the signals TXD and RXD (MCU pins TXD1 and RXD1) are required. Optionally, a CTS/RTS hardware handshake protocol can be implemented.
- The MCU can read the /RTS output using port pin PM6, while PM7 controls the /CTS input of the USB-UART.
- Transmit- and receive-activities can be displayed using two LEDs. Their anodes must be wired to VCC (5V), while the cathodes have to be connected to /RXLED and /TXLED (X4/67+68), respectively.
- PWREN is set by IC15 according to the enumeration status of the USB device. This signal can be detected by the MCU port pin PM4. The control signal /SLEEP is low if IC15 is in Suspend-Mode; PM5 is used to read this signal.
- BR11 must be closed if a system reset should also reset the USB-UART, which is normally not required. The USB-UART has an independent power-on reset circuit, so normally it does not need an external reset source.
- If BR11 is closed, any system reset will temporarily remove the USB device from the bus “logically”.
- When the reset condition has ended, the device needs to be re-enumerated by the USB-Host.
- The serial EEPROM IC16 can hold configuration data for the USB-UART. If IC16 is erased (default delivery state), the USB-UART uses standard descriptors to answer descriptor requests from the host.
- User descriptors (VID, PID, strings, serial numbers, etc.) can be downloaded to the EEPROM using a PC-based utility program (provided by FTDI). The programming can be done in-circuit via USB.
- Uwaga: If the USB-Option is equipped, the IF-Module connec-tion X3 is not available.
SPI Subsystem
- The MC9S12DG256 provides three independent SPI ports. On the S12compact, port SPI0 is used to control the peripheral components RTC, ADC, DAC, PARIN, and PAROUT. Port SPI1 is used to communicate with the Serial Data Flash; SPI2 is not in use.
SPI0 consists of four individual signals: MISO, MOSI, SCK, and /SS (MCU port pins PS4 to PS7). The slave select signal /SS is not in use on the S12compact, though it can be accessed on the side header connectors. - The SPI chip select signals are derived from the MCU port pins PH[4..6]. The decoder chip IC4 activates one of its eight low-active outputs depending on the Port H pattern.
- This provides an economical way to provide up to eight chip selects with a small number of MCU resources.
The table below shows the usage of SPI chip selects on the S12compact:
| Wybór chipa | Port H | Stosowanie |
| /SPICS0 | x000xxxx | Zegar czasu rzeczywistego |
| /SPICS1 | x001xxxx | Przetwornik C/A |
| /SPICS2 | x010xxxx | A/D-Converter |
| /SPICS3 | x011xxxx | Parallel In Shift |
| /SPICS4 | x100xxxx | Parallel In Latch |
| /SPICS5 | x101xxxx | Wyjście równoległe |
| /SPICS6 | x110xxxx | freely available (X4/20) |
| /SPICS7 | x111xxxx | No chip select active |
- The following listing demonstrates some basic functions (initialization, 8-bit data transfer) for the SPI-Port SPI0:

Extra Ports PARIN and PAROUT
- While the MC9S12DG256 provides a large number of general-pur-pose I/O-pins, it may be desirable for some applications to keep many ports unused. This is especially the case if the external bus interface is intended to be used.
- A preferred way to provide additional input or output ports consists of using one of the Serial Peripheral Interface (SPI) modules of the MC9S12DG256.
- It is quite easy to create eight additional binary outputs by adding a shift register like IC9. In addition to the SPI signals MOSI and SCK, only a chip select signal (/SPICS5) is needed to operate IC9.
- This shift register has an asynchronous reset input for both the shift register and the output latch, so all output lines PO0..PO7 will drive L-level out of reset automatically.
The following listing shows an example for parallel output:
- Using the same SPI port, IC8 provides eight additional input pins. Two chip selects (/SPICS3 and /SPICS4) are needed to latch the input information coming from PI0.PI7 and to shift out data via MISO, respectively.
- IC6A is needed to decouple the push/pull-output QH of IC8 from MISO, to allow multiple slaves on the same SPI port.
The following listing shows an example for parallel input:
Zegar czasu rzeczywistego (RTC)
- The Real Time Clock (RTC) IC7 provides an independent timing reference, including calendar information. Under normal operating conditions, it is supplied by VCC (via D3).
- In case of a power-loss, the lithium cell BT1 delivers a backup supply in order to avoid data corruption. The installed battery type (CR2032) is designed for a lifetime of at least five years.
- The RTC is controlled via the SPI port SPI0. This includes the signals MISO, MOSI, and SCK (port pins PS4/5/6). The chip select signal /SPICS0 is provided by IC4 (see above). The read/write control is done by PH7.
- The following listing shows some basic input/output routines for the RTC. They are based upon the SPI driver functions, which are shown above.
- For more complex functions, such as set date/time, please refer to the software examples contained on the product CD.
- For further instructions how to program the RTC, please refer to the RTC4553 Application Manual.

- On the S12compact, the RTC (including BT1) is an optional component (not included in the standard version).
A/D-Converter (ADC)
- The S12compact can be equipped with a high-resolution A/D-Con-verter (ADC). While the on-chip ATD modules of the HCS12 provide sufficient resolution (10-bit) for a wide range of industrial applications, the external ADC system on the S12compact provides enhanced accuracy, which is suitable for measuring devices and data loggers.
- The ADS8344 (IC11) from Burr Brown is an 8-channel 16-bit ADC with a serial interface and a conversion rate of up to 100ksps. It is connected to the SPI-port SPI0 of the MCU. /SPICS2 is the chip select signal for the ADC (delivered by IC4).
- IC10 is a precision voltage reference, delivering 4.096V for the ADC and the DAC on the S12compact. This reference voltage determines the maximum limit for the analog input AIN0.AIN7. The lower limit is ground (0V).
- After opening the solder bridge BR9, an external reference voltage can be used instead of IC10 (note: influence on DAC IC12). The analog inputs AIN0 to AIN7, as well as the analog supply voltages (VCCA, VREF, GNDA), are available at connector X4.
- The following software example for the ADS8344 uses the basic SPI functions (shown above).

- On the S12compact, the ADC is an optional component (not included in the standard version).
D/A-Converter (DAC)
- The 16-bit D/A-Converter (IC12) is a DAC8532 from Burr Brown. This device contains two output channels (VOUTA, VOUTB), which can be set either simultaneously or individually.
- Odniesienie voltage (4.096V) is delivered by IC10 (see ADC description).
- The load resistance at the output(s) should be at least 2kOhm. At power-up, the output registers of the DAC are reset, thus delivering 0V.
- The DAC is controlled via SPI0. /SPICS1 serves as cthe hip select signal for the DAC.
- The analog outputs VOUTA and VOUTB are available at connec-tor X4.
The following listing shows a software example for the DAC:
- On the S12compact, the DAC is an optional component (not included in the standard version).
Serial Data Flash (SDF)
- The Serial Data Flash (SDF) on the S12compact allows to storing a large amount (up to 2MB / 16Mbit) of data, arriving sequentially at high rates. This is often the case for data logger applications.
- Normally, a disadvantage of Flash memory is the lack of a randomly writeable buffer space. As a consequence, an additional RAM area is required for temporary storage. To avoid the need for extra RAM resources, Atmel provides two 528-byte buffers in its Serial Data Flash devices. This allows one buffer to be filled via SPI, while the contents of the other buffer are programmed into a Flash sector. Using this method, a continous throughput of up to 35KB/s (writing) can be reached.
- The Serial Data Flash (IC14) is connected to SPI1, thus being independent from RTC, ADC, DAC, etc., which are using SPI0. The SPI1 signals MISO1, MOSI1, SCK1, and the chip select signal /SS1 are provided by the MCU’s port pins PH0.PH3.
- Notatka: To use this assignment, bit 5 in the Module Routing Register (MODRR) of the MC9S12DG256 must be set. Otherwise (reset default), SPI1 is associated with port pins PP0..PP3.
- Programowanie cztage and timing are generated on-chip by IC14. The supply voltage of 3.3V is provided by a low-dropout voltage regulator (IC13). The inputs of the Serial Data Flash device are 5V-tolerant, and the output SO is connected to the 5V-based MISO1 signal through a level shifter (IC6B).
- On the S12compact, the SDF is an optional component (not included in the standard version).
- If IC14 is not equipped, R17 will provide a defined input level for IC6B. By opening the solder bridge BR10, the output of IC6B can be decoupled from MISO1.
IIC-Bus
- The port pins PJ6 and PJ7 grant access to the Inter-IC-Bus module (IIC/I2C/I2C) of the MC9S12DG256. Since the IIC-Bus is implemented as a hardware module, an IIC software emulation is obsolete.
- For the two IIC-Bus signals (SDA, SCL), pull-up resistors are required. They can be soldered in directly on the S12compact PCB (R10, R11) or they can be added externally.
- The IIC-Bus signals are accessible at X4/65+66.
Interfejs CAN
- The MC9S12DG256 contains two independent CAN-Modules, designated as CAN0 and CAN4.
- CAN0 is accessed over port pins PM0 and PM1. IC5 serves as a CAN physical bus interface. It is a high-speed interface chip commonly used in industry applications. R9 determines the slope control setting.
- R8 is a termination resistor, required if the S12compact is the last node in a CAN bus chain. BR2 should be closed in this case, otherwise opened.
- For CAN4, there is no physical driver provided on the S12compact.
- It can be added externally through port pins PJ6 and PJ7. However, in this case, a conflict with the IIC-Bus will occur, since both functions share the same two pins. If IIC and CAN4 have to be used at the same time, CAN4 can be rerouted to port pins PM4/5 or PM6/7 by setting the re-routing control register MODRR accordingly (which, in return, may have an influence on using an IF-Module or the USB interface option).
Interfejs magistrali
- The MCU ports A, B, K, and (partly) E are related to the Multiplexed External Bus Interface (MEBI). On the S12compact, all bus signals are accessible via two header connectors (X7, X8; not mounted by default).
- A small memory expansion PCB can be plugged onto these two connectors, which is especially useful for debugging purposes (Flash emulation).
- In Single Chip Mode, which is the default MCU operating mode of the S12compact, the Multiplexed External Bus Interface is not used, and the ports A, B, and K can be used as general-purpose I/O-ports.
Zachowanie po zresetowaniu
- As soon as the reset input of the microcontroller is released, the MCU reads the Interrupt Vector at memory address $FFFE/F and then jumps to the address found there.
- In the default delivery condition of the S12compact, the Flash module of the MCU contains Motorola’s Monitor Program D-Bug12.
- The reset vector points to the start of this Monitor Software. As a result, the monitor will start immediately after the reset.
- The monitor functions are described in a seperate document (D-Bug12 Reference Guide, see product CD).
Startup Code
- Every Microcontroller firmware starts with some hardware initialization commands.
- For the S12compact, only setting up the stack pointer is crucial. While it was important for HC12 derivatives to disable the Watchdog, the COP Watchdog of HCS12 devices is already disabled out of reset.
Additional Information on the Web
- Additional information about the S12compact Controller Module will be published on our Website, as it becomes available: http://elmicro.com/s12compact.html
Mapa pamięci
- The memory map of the MC9S12DG256 can be modified by the application program during runtime. Out of reset, the following default memory map is valid.
| Zaczynać | Koniec | Ressource |
| 0000 XNUMX dolarów | $03FF | Rejestry kontrolne |
| 0400 XNUMX dolarów | $0FFF | 4KB EEPROM (Area $0000-$03FF = 1KB hidden by Control Registers) |
| 1000 XNUMX dolarów | $3FFF | 12 KB pamięci RAM |
| 4000 XNUMX dolarów | $7FFF | 16KB Flash (equals Page $3E) |
| 8000 XNUMX dolarów | $BFFF | 16KB Flash
(any Page $30..$3F, controlled by PPAGE) |
| $C000 | $FFFF | 16KB Flash (equals Page $3F) |
OBSŁUGA KLIENTA
- Copyright (C)2002-2003 by
- MCT Elektronikladen GbR
- Hohe Str. 9-13, D-04107 Leipzig
- Telefon: +4903412118354
- Faks: +4903412118355
- E-mail: support@elmicro.com
- Web: http://elmicro.com
Często zadawane pytania
Can I expand the memory on the S12compact module?
Yes, the S12compact supports additional memory using Serial Data Flash, providing an extra 2MB 16Mbit of memory.
What software tools are available for HCS12 microcontrollers?
A wide range of software tools, such as Monitors, C-Compilers, and BDM-Debuggers, are available to accelerate the development process for HCS12 microcontrollers.
Dokumenty / Zasoby
![]() |
ELMICRO S12compact Versatile Controller Module [plik PDF] Instrukcja obsługi s12cov110, S12compact Versatile Controller Module, S12compact, Versatile Controller Module, Controller Module |

