Notice: Vacation shutdown from 4/29/2024 through 5/14/2024. Store will be offline.

NanoCore12 User Manual

1  INTRODUCTION 


1.1    PRODUCT CONFIGURATION

NanoCore12 was designed as a versatile evaluation and application tool for the Freescale S12 “C” family of microcontrollers.  It is suitable for developing applications for any of the derivatives (e.g. 9S12C32, 9S12C128).  All of the subsystems are identical, with the differentiating factor among the chips being the amounts of Flash and RAM included on the chip.  NanoCore12 modules are completely self-contained, including RS232 interface and 5V regulator circuitry right on the module.  You can simply plug it into any solderless breadboard to use it.
For added convenience, though, a Docking Module is offered, which provides additional support for working with the microcontroller.  It includes a larger voltage regulator, which has extra current to spare for your applications.  The voltage regulator also has a jumper option to enable 3-Volt operation.  Other features include a standard 9-pin D-sub connector (“DB9”) for the RS232 serial interface, a socket to accommodate any size of  NanoCore12 module, a couple of user LEDs and pushbuttons, and a snap-off prototyping area.  A similar product, the School Board, is configured with a section of solderless breadboard instead of the snap-off prototyping area.  This configuration is ideal for quick experimentation and training purposes.  Product bundles are offered for both, and include a power supply and serial cable.  Resources, including documentation, tools, and examples, are available at www.NanoCore12.com.
NanoCore12 modules are offered in 24-pin, 32-pin, and 40-pin DIP footprints that plug directly into a solderless breadboard, or into the DIP socket on the Docking Module, or into the socket strips on a School Board.  While the standard configuration incorporates the 9S12C32 MCU, a 9S12C128 version is available on the 40-pin “MAX”, offering four times the program space (128K vs. 32K) and double the RAM (4K vs. 2K).  All the modules mentioned have gold-plated 0.025” square pins.

1.2    RESIDENT DEBUG/MONITOR

 Residing in a 2K protected block of on-chip flash memory is Freescale’s standard Serial Monitor program (see Freescale Application Note AN2548).  When used with uBug12 (a free multi-platform application created by Technological Arts), you can display and edit memory and registers, erase and program flash, set breakpoints, do instruction tracing, disassemble a range of program memory, and much more.  When using CodeWarrior, you  can load programs into flash, and do source-level debugging in C and assembler.  When you’ve finished developing your program, flip a switch on NanoCore12 to Run mode, and your standalone program runs automatically from Flash, following reset or powerup.  See Chapter 2 for more on using uBug12 and CodeWarrior, and Appendix A for details on the resident Serial Monitor.

 1.3    COMMUNICATIONS

An RS-232C serial interface port connector (RX & TX only) is included on both the Docking Module and School Board, allowing communication with a PC com port,  or any other device which has an RS-232 serial port, via a standard 9-pin serial port extension cable.   The RS-232 channel is implemented via the SCI of the MCU, and when NanoCore is reset in Load mode, the resident Serial Monitor uses this port to communicate with an companion program running on your PC (e.g. uBug12).  In Run mode, the RS-232 port is available for your application.
While the MCU does support Controller Area Network (CAN),  it is not accessible on the 24-pin module.  On the 32-pin module, no physical layer circuit is provided for CAN, so if you would like to use it, you’ll need to add the appropriate transceiver circuit externally, connected to PM0 and PM1 of the MCU module.  However, the 40-pin module (NanoCore12MAX) includes an on-board CAN transceiver circuit, so the CAN interface can be used directly, without the need for additional circuitry.
In passing, it should be mentioned that the MCU also supports Serial Peripheral Interface (SPI).  Since this is a logic-level protocol, meant for local communications among peripheral chips, no transceivers are required nor are they provided.  Commonly used SPI chips and modules include:  serial memory (e.g. EEPROM, Flash), temperature controllers, clock/calendar chips, DACs, MP3 decoders, SD memory cards, etc.  The SPI pins are not accessible on the 24-pin module.
A block diagram of the 9S12C MCU is shown here.  Refer to the 9S12C data sheets for details on all of these subsystems.


2  GETTING STARTED

 2.1 HARDWARE SETUP

There are various commonly-used configurations for working with NanoCore12 modules.  Follow the directions below for the particular setup you are using.

2.11 Using With a Solderless Breadboard.

Standard RS232 version of NanoCore12:  If you're using a solderless breadboard, plug your NanoCore12 module into the breadboard.  Attach a serial cable between the TX, RX, and GROUND pins of the module (pins 1, 2, and 4, respectively) and the RX, TX, and Ground pins of a PC's Com Port (i.e. serial port),  respectively.  A suitable cable is available from Technological Arts (#SCSB36) which will plug directly into the breadboard adjacent to the serial communication pins (see Fig. 3).  If your PC does not have a ComPort, you'll also need a USB-to-Comport adapter (#USB2COM).  The first time you plug in the USB adapter, Windows will prompt you to install the driver for it, which you’ll find on the CD that came with it.  Before using the adapter, you’ll need to configure it as a Virtual Comport via the Windows Device Manager.  See Appendix D for detailed instructions on how to do that.
Apply power to the module in one of the following ways:
1) unregulated DC voltage (maximum 8V) may be applied to the Vin (+) and VSS/Ground (-) pins of the module.  These are the highest numbered pins on the module
(i.e. pins 23 and 24 on a 24-pin module, pins 31 and 32 on a 32 pin module, etc.).
2) or, regulated 5V may be applied directly to the VCC (+) and Ground (-) pins.  If you use this arrangement, make sure to leave the Vin pin unconnected.
A power cable (#PCJ1-8SB) which plugs conveniently into your solderless breadboard next to the Vin and Ground pins is available from Technological Arts.
Special TTL version of NanoCore12 (blue chip):  If you have a TTL version of a NanoCore12 module, you should use the Technological Arts USB2NCT module for power and communications.  Plug USB2NCT into your breadboard such that the two power pins plug into the breadboard’s power bus.  Then plug your NanoCore12 module into the breadboard such that the four pins line up with the last four pins of the module.  Be sure the power jumper is in place on the USB2NCT module, so that your PC’s USB port will supply 5V power to your breadboard and NanoCore12 module.
Plug a USB cable between your PC and the USB2NCT module.  The first time you plug it in, Windows will prompt you to install the driver for it, which you can download from the Resources tab on the USB2NCT web page.  Before using the Comport, you’ll need to configure it as a Virtual Comport via the Windows Device Manager.  See Appendix D for detailed instructions on how to do that.
You can now continue to section 2.2.

2.12 Using With the Docking Module.  If you have a Docking Module (e.g. Kit1 bundle), plug the NanoCore12 module into the universal 40-pin DIP socket on the Docking Module, taking care to orient it correctly (pin 1 dot on module lined up with pin 1 dot adjacent to the socket).  The socket accommodates all three sizes of NanoCore12 modules (24-pin, 32-pin, and 40-pin), so be sure to plug your module into the correct end of the socket.  Refer to Figure 7.
Attach a standard 9-pin serial extension cable (not a "Null Modem") between the Docking Module and your PC serial port.  A suitable cable is available from Technological Arts (#CX09B06).  If your PC does not have a Com port, you'll also need a USB-to-Comport adapter (#USB2COM).  The first time you plug it in, Windows will prompt you to install the driver for it, which you’ll find on the CD that came with it.  Before using the Comport, you’ll need to configure it as a Virtual Comport via the Windows Device Manager.  See Appendix D for detailed instructions on how to do that.
Use an AC-to-DC adapter ("wall wart") with a DC output voltage rating anywhere between 6 and 9 V, capable of delivering a minimum of 100 mA.  The output plug needs to be a 2.1mm diameter barrel type, with center positive.  This is the most common type available, and may be ordered from Technological Arts (#DC9V).  It is also the adapter supplied with all Kit1 bundles.
We're going to use the setup in its default 5V power mode, so double check that jumper block JB1 is "open" (i.e. the shorting plug is not in place).  Once you have connected power, you'll see that the green Power LED (D1) on the Docking Module is glowing.
You’re now ready to move continue with section 2.2.

2.13 Using With the NanoCore12 School Board.  There are three pairs of single-row receptacle strips on the School Board, corresponding to the three sizes of NanoCore12 modules available.  Plug your NanoCore12 module into the correct set of receptacle strips, taking care to orient it correctly (pin 1 dot on module lined up with pin 1 dot adjacent to receptacles).  See Figure 7.
Attach a standard 9-pin serial extension cable (not a "Null Modem") between the School Board and your PC serial port.  A suitable cable is available from Technological Arts
(#CX09B06).  If your PC does not have a Com Port, you'll also need a USB-to-Comport adapter (#USB2COM).  The first time you plug it in, Windows will prompt you to install the driver for it, which you’ll find on the CD that came with it.  Before using the Comport, you’ll need to configure it as a Virtual Comport via the Windows Device Manager.  See Appendix D for detailed instructions on how to do that.
Use an AC-to-DC adapter ("wall wart") with a DC output voltage rating anywhere between 6 and 9 V, capable of delivering a minimum of 100 mA.  The output plug needs to be a 2.1mm diameter barrel type, with center positive.  This is the most common type available, and may be ordered from Technological Arts (#DC9V).  It is also the adapter that is supplied with all Kit2 bundles.
We're going to use the setup in its default 5V power mode, so double check that jumper block JB1 is "open" (i.e. the shorting plug is not in place).  Once you have connected power, confirm that the green Power LED (D1) on the School Board is glowing.
You’re now ready to move on to section 2.2.

2.2 VERIFYING YOUR SETUP

At this point, you should have your hardware all set up and ready to test.  You’ll do that by using a terminal program on your PC, acting as the user interface to the Demo program that has been pre-loaded at the factory into each NanoCore12 module.
To use the Demo program, you will need to launch a terminal program on your PC.  Some examples of terminal programs you can use are:  HyperTerminal (included with Windows), TeraTermPro (free download from Sourceforge), the terminal program integrated into MiniIDE, and the terminal program integrated into ImageCraft's C compiler (ICC for CPU12).  For help setting up a connection with any of these programs, see Appendix D in this manual.
Launch your selected terminal program and set up a connection to the com port you are using, configuring it for 9600 baud, no parity, 8 data bits, one stop bit.  For handshaking, select "none".  Now power up your module, as described above, making sure the Load/Run switch is in the Run position.  You should immediately see a menu displayed in your terminal window.  If you are using a Docking Module or School Board, you should also see one of the red LEDs blink a couple of times.  If you don't see it, press the Reset button on the Docking Module or School Board.  If you are not using the Docking Module or School Board, you'll need to momentarily bring the RESET pin on the module to "logic low" (i.e. temporarily ground it).  Refer to your module's data sheet to determine which pin is the RESET pin.
Now press the Enter key on your PC keyboard, and NanoCore12 will re-transmit the Demo Menu to your terminal window.  If you got this far, it means that your module is successfully powered up and running, and communication is working in both directions (ie. transmit and receive).

 2.3  EXPLORING THE DEMO PROGRAM

If you are using a solderless breadboard or your own board, you'll need to wire up a few simple circuits to see the results of some of the Demo Program commands.  Refer to Appendix E for details.
If you are using the Docking Module or School Board, the demo circuits are already in place, so you can proceed:
•Type the digit 0 repeatedly and observe that LED D2 toggles on and off.
•Type the digit 1 repeatedly and observe that LED D3 toggles on and off.
•Type the letter F to flash LED D2 to twice.
Typing E, H, M, or T will cause a hexadecimal number to be displayed, whose bit values represent the logic levels of the respective port pins.  The pins which are not connected to external circuitry (i.e. floating pins) will assume a logic 1 level, due to internal pullup resistors.  You can connect input port pins to Ground or +5V with jumper wires and observe the change in value when you type the E, H, M, or T commands (as appropriate for the input port you want to observe).  If you attach a small piezo speaker between the PT0 pin and Ground, you’ll here two beeps whenever you type F to flash the LED.  This is because the routine actually generates an audio tone, but the LED turns on and off so fast that it appears steady to the eye.

 2.4     LOADING A NEW PROGRAM INTO MEMORY

As mentioned earlier, each NanoCore12 module is shipped from the factory with a small Serial Monitor program residing in a protected block of flash memory.  It is this Serial Monitor that facilitates the loading of user programs into NanoCore12.  Since the Serial Monitor implements a compact binary command set, it requires some sort of user-friendly interface on the host machine.  Technological Arts has developed a Graphical User Interface called uBug12 for this purpose.  It was written in Java, and can be used on Windows, Mac, and Linux platforms.  Freescale’s CodeWarrior Compiler/Assembler/IDE can also be used with the Serial Monitor, and will be covered in a later chapter.
2.41  Using uBug12.  Following reset, the startup code detects the position of the Load/Run switch to determine whether to run the monitor or jump to the user program.  If the switch is in the Load position, the Serial Monitor is activated.  To use the Serial Monitor you'll first need to install and launch uBug12.  If you don't already have it, you can download it from the Support Library, at http://support.technologicalarts.ca/docs/uBug12/.  Be sure to also download the manual that is in the same directory.
2.42  Establishing a Serial Port Connection.  Once you have launched uBug12, place the switch in the Load position and reset your NanoCore12.  Then type the command con 1 to establish communication between uBug12 and NanoCore12 on comport 1 of your PC.  If you're using a com port other than 1, substitute the correct number (eg. con 3 if using com port 3).  After a second or two, a message will appear in the uBug12 display window showing that the connection was successful.
2.43  Loading a Program.  Loading a new program into memory is a two-step process--  first you erase the program “Flash” memory and then you load in the new program.  
Here's how to do it:
Type fbulk and press enter.
Then type fload and press enter.
When the file browser pops up, select the s-record file you want to load, and click OK.
After loading has finished, move switch SW2 to the Run position and reset NanoCore12.
If the program you just loaded uses the serial port (like the Demo Program, for example), you can just type the command term in uBug12 to launch a TeraTermPro window (assuming you have previously installed it).  If not, close uBug12 and open the terminal program you used in section 2.2, above.
For a list of all uBug12 commands, type help at the command prompt.  Other commands are covered in more detail in the uBug12 manual.  One nice feature you’ll discover is command line history.  Use the UP and DOWN arrows on your keyboard to recall previously typed commands.  You can then edit them, as needed, before hitting <ENTER>.

 2.5    EXAMPLE PROGRAMS

We’ve included a few example programs in the Support Library at http://support.technologicalarts.ca/docs/NanoCore12/Code to give you a starting point.  There are some examples in Assembler, some in BASIC, and some in C.  The source code is included, so you’re free to modify them all you want!  To just load them and try them out, use uBug12 to load the .s19, .s2, or .sx file included with each example.  Those are the output files containing the s-records that uBug12 sends to the Serial Monitor for programming into flash.


3  HARDWARE DESIGN FEATURES

3.1    3-VOLT OPERATION

One of the nice features of the MCU is that it can operate on 3 to 5 V, while maintaining full bus speed capability.  To support 3 Volt operation, the Docking Module incorporates an adjustable regulator whose output voltage is set by a resistive voltage divider.  The circuit has been designed such that simply inserting a shorting jumper causes the regulator’s output to shift from 5V to 3.3V.  (Note:  If you aren’t using a Docking Module (e.g. you’re just plugging the DIP module into a breadboard), you’ll need to supply your own 3 Volt regulated supply to the Vcc pin to take advantage of 3-Volt mode.)  When operated at 3V, there are a few precautions that should be noted, however:
The logic pins are not 5V-tolerant, so you will need to take the necessary steps to prevent damage to the I/O pins of the MCU.  Also, the maximum VRH voltage is limited to 3.3V, so any external voltage or precision voltage reference you supply for use with the Analog-to-Digital converter subsystem should be scaled accordingly.  If you're using the MAX (40-pin) module, the CAN transceiver will not work--  it is 5-Volt only.  One last point is that some BDM pods (eg. MicroBDM12LX5) will not work with 3V targets, so you should check the specs of the BDM pod you intend to use.  A good choice is USBDMLT, which works with both 3V and 5V targets.

3.2    RESET

Unlike previous HC11 and HC12 designs, the 9S12C MCU has an on-chip low-voltage inhibit (LVI) reset circuit, so it is not necessary to provide such a circuit externally.  A momentary tact switch is provided for manual reset, and the LVI circuit will provide a clean reset signal upon power-up.

3.3    ABOUT THE DOCKING MODULE VOLTAGE REGULATOR

The NanoCore12 Docking Module (also, the School Board) includes an LM1086CT-ADJ voltage regulator.  Housed in a TO-220 package, it is capable of dissipating about 500 mW at room temperature.  Other nice features are:  reasonably low quiescent current, and low dropout voltage--  it will work with an input voltage down to about 5 Volts (or 3 Volts, in 3-Volt Mode), making it quite well-suited to battery operation.  It is also designed to withstand reverse polarity.  One drawback, however, is that it can become unstable and start to oscillate at low temperatures, especially if the input voltage source is connected to J1 via long wires.  If low-temperature operation is anticipated, the on-board 10uF tantalum capacitor can be replaced with a higher value (47uF or 100uF).  To compensate for long lead-in wires, add capacitance of about 100uF at, or close to, the J1 connector.

3.4    ABOUT THE ON-BOARD VOLTAGE REGULATOR

NanoCore12 modules include a tiny LP2981AIM-5 voltage regulator mounted on the underside of the module.  It is a low-dropout 5V regulator capable of supplying the on-board circuitry with the required current, with as much as 50 mA to spare for user applications, if the supplied input voltage to the regulator is limited to 6V.  The higher the input voltage, the less current will be available for the user application before thermal shutdown occurs.

3.5    PLL

While the supplied crystal is only 8MHz, the MCU is capable of running at a much higher speed.  The phase-locked loop feature of the MCU allows you to boost the bus speed by an integer multiple of the crystal frequency, so by enabling the PLL, you can actually run the MCU at 24Mhz.


4  WRITING SOFTWARE

 4.1    IMPACT OF THE SERIAL MONTIOR

When you are working without a BDM pod, the Serial Monitor is the only method available to load and erase flash.  Fortunately, it is in a protected block of flash, so there’s no way to accidentally erase it.  The Serial Monitor has two modes, controlled by switch SW2:  Run and Load.  The monitor determines the mode immediately following reset by checking the position of switch SW2.  When working with the monitor program in place, there are a few points to be noted:  

1) while the user vectors are implemented by the monitor at 0xF780 to 0xF7FF, you don’t really have to worry about it, because the monitor program will automatically adjust them when your s-record is loaded.  Just make sure to always include a reset vector in your program, as well as any interrupt vectors your program will use.

2) the monitor relocates RAM to the address range 0x3800 to 0x4000 from the default location after MCU reset of 0x0000 to 0x07FF.  This is done so there is no overlap with the register block.  (On NanoCore12MAXC128, RAM is remapped to the range 0x3000 to 0x4000).  If you launch your program via uBug12, the RAM has already been relocated, but if you switch to Run and launch your program by resetting the MCU, the RAM is at its default location unless you explicitly relocated it at the beginning of your program.  This point is very important, because if your program has any variables, calls any subroutines, or contains any interrupt service routines, it's not going to work if you assumed the relocated RAM and stack pointer addresses the monitor uses.

3) the monitor program enables the phase-locked loop (PLL), so the module runs at 24Mhz instead of the MCU’s default startup speed of 4Mhz.  If you launch your program via uBug12, the bus speed has already been boosted by the monitor to 24MHz, but if you switch to Run and launch your program by resetting the MCU, the bus is at its default speed of 4 MHz unless you explicitly enabled the PLL to boost the bus speed to 24 MHz at the beginning of your program.  This point is very important, because anything based on timing will be running at 1/6th the speed (or 6 times the delay) without the PLL active.  If you're using the SCI, it's not going to work if you assumed the higher bus speed the monitor uses.

4) your code must clear the CCR I-Bit  (e.g. via the CLI  instruction in assembler or the INTR_ON() directive in ICC) if you want to run your program under monitor control via uBug12 for debugging purposes

5) the SCI cannot be used by the your program when in Load mode, since it is dedicated to the monitor program.

6) COP cannot be disabled in Load mode.

4.2    USING A BDM POD

If you have a BDM pod, you can erase the resident monitor program completely.  This will free up all the MCU resources for your program (most importantly, the SCI), but you won't be able to use uBug12 again unless you load the serial monitor back into flash.