MiniDragon-Plus3 Trainer For Freescale HCS12 microcontroller family User’s Manual Revision 1.
Table OF Contents Chapter 1. Introduction ................................................................................................................. 4 1.1 Welcome .................................................................................................................... 4 1.2 MC9S12DG256 features and memory map ...............................................................5 1.3 On-board hardware features ..................................................................................
4.10 LCD display module ................................................................................................ 28 4.11 Keypad ..................................................................................................................... 29 4.12 All jumper settings .................................................................................................. 30 Chapter 5. Code Warrior and serial monitor ...............................................................................
Chapter 1. Introduction 1.1 Welcome Thank you very much for purchasing the MiniDragon-Plus3 trainer. The MiniDragon-Plus3 trainer is a low-cost, feature-packed multi-purpose training board for the Freescale HCS12 microcontroller family. It is compatible with the Freescale 9S12DP256EVB board and other similar development boards on the market today, but it also incorporates many on-board peripherals that make this board one of the best trainers for university classrooms.
1.2 MC9S12DG256 features and memory map: The MiniDragon-Plus3 board may come with theMC9S12DP256CCPV or the MC9S12DG256CVPE installed. The MC9S12DG256 is the best replacement for the MC9S12DP256 since the latter has been discontinued by Freescale. The only difference between DG256 and DP256 is the number of CAN ports. The DG256 has 2 CAN ports, but the DP256 has 5 CAN ports. Other than the different number of CAN port these two microcontrollers have the same features.
Fig 1-1: MC9S12DG256 Memory map 6
Fig 1-2: MC9S12DG256 MCU block diagram 7
Fig 1-3: MC9S12DG256 MCU pin assignments 8
1.3 On-board hardware features: • On-board USB interface based on the flawless FT232RL for programming and debugging code, no BDM needed.
• MC9S12DG256, 256K flash, 12K RAM and 4K EEPROM • Dual UARTs • 16 MHz crystal, 8 MHz default bus speed and up to 25MHz bus speed via PLL • Pre-installed with D-Bug12 monitor ( for AsmIDE ) or Serial Monitor ( for CodeWarrior ) • LED operating mode indication (E,J,P,B) on the 7-segment display during power-up, no need to remember jumper settings • On-board BDM-in connector to be connected with a BDM from multiple venders, including our USBDM, for advanced debugging • Supports C and Assembly lan
Pin Name Pin # I/O Usage PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 Pin 57 Pin 58 Pin 59 Pin 60 Pin 61 Pin 62 Pin 63 Pin 64 Col_0 of keypad (output) Col_1 of keypad (output) Col_2 of keypad (output) Col_3 of keypad (output) Row_0 of keypad (input) Row_1 of keypad (input) Row_2 of keypad (input) Row_3 of keypad (input) PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 Pin 24 Pin 25 Pin 26 Pin 27 Pin 28 Pin 29 Pin 30 Pin 31 H-bridge (output) H-bridge (output) H-bridge (output) H-bridge (output) not used not used not used not used
PM0 PM1 PM2 PM3 PM4 PM5 PM6 PM7 Pin 105 Pin 104 Pin 103 Pin 102 Pin 101 Pin 100 Pin 88 Pin 87 CAN0_RX CAN0_TX not used not used not used not used not used not used PP0 PP1 PP2 PP3 PP4 PP5 PP6 PP7 Pin 4 Pin 3 Pin 2 Pin 1 Pin 112 Pin 111 Pin 110 Pin 109 EN12 of H-bridge (output) EN34 of H-bridge (output) Digital pin 10 of Arduino Digital pin 11 of Arduino Servo motor 1, or Red LED of RGB LED or Digital pin 3 of Arduino Servo motor 2, or Green LED of RGB LED or Digital pin 5 of Arduino Servo motor 3, or B
Chapter 2. Quick Start By default the MiniDragon-Plus3 board is pre-installed with the bootloader (Freescale AN2153.pdf) and the D-Bug12 monitor (Freescale DB12RG4.pdf). In chapters 2 and 3 the AsmIDE is used as the main software tool to develop and debug assembly programs. If your board is pre-installed with serial monitor (Freescale AN2548.pdf) to use Code Warrior IDE for C program development, skip the chapters 2 and 3 after installing software. People often use different terminologies.
2.2 Getting Started To operate the MiniDragon-Plus3 board, follow steps1 through 5 below: 1. Make sure that the two DIP switches of S7 must be set in the “low” positions for EVB mode, then plug in the USB cable. The speaker should chirp once, the 7-segment LED should display the letter “E” momentarily. The letter E stands for EVB mode. Here is the code explanation: The letter: E = EVB mode, J = Jump to EEPROM, P = Pod and b = Bootloader mode.
8. You can program text values for function keys to be sent from the terminal window. Some function keys are pre-programmed, but you can change it any time in configuration options (View->Options->Terminal Func Keys). In the View->Option->Assembler menu, make sure that the chip family is 68HC12, not 68HC11. If you would like to use your own assembler, you can replace the as12.exe with the name of your own assembler. 9. The screen is divided into two windows.
2.3 Test Hardware: To help users up and running, the MiniDragon-Plus3 board comes with many fully debugged, ready-to-run sample programs including source code. The hardware test program, test16_P3.asm, simultaneously scans the keypad, plays a song, senses ambient light, changes 7-segment display brightness by adjusting the trimmer pot and vary music playing tempo according to temperature change. All sample programs must be run from RAM in EVB mode.
Chapter 3. Software descriptions 3.1 Bootloader and D-Bug12 Monitor The MC9S12DG256 on the MiniDragon-Plus3 board is pre-loaded with bootloader and D-Bug12 monitor firmware and it will operate in 4 different modes depending on the setting of the 2position DIP switch, S7. After power up or reset, the MC9S12DG256 will read the PAD0 and PAD1 to decide which mode to boot up. The bootloader (AN2153.PDF), the D-Bug12 reference guide (DB12RG4.PDF) and the MC9S12DG256 data book (MC9SDG256.
3.1.2 Jump-to-EEPROM mode: PAD1=0, PAD0=1 This mode enables the MC9S12DG256 to jump directly to the internal EEPROM at location $0400 upon reset. This mode makes the MC9S12DG256 a replacement for the old 68HC811E2 microcontroller, but it also gives you 3K EEPROM instead of 2K EEPROM with the 68HC811E2.
You first must set the target speed with the choice 1). After entering the first choice, you will be prompted to enter the target speed. It’s the crystal frequency, not the bus speed that is boosted up by the on-chip PLL. After a reset, before the PLL is enabled, the target MC9S12DG256 is running from the crystal frequency, not the PLL frequency. Enter 16000 for the target speed. After the correct speed is entered, the master will try to communicate with the target board.
Now we are going to program the bootloader and the D-Bug12 into the flash memory of the target MC9S12DG256. Before we actually program the flash memory, we must understand there are two different types of s-record file that can be generated by compilers and assemblers. An s1-record uses a 16-bit starting address field while an s2-record uses a 24-bit starting address field.
***************************************************************************** ***************************************************************************** ************************************************************* S> With the bootloader and the D-Bug12 programmed in the flash memory, the target board now becomes a true development board. That’s how we program the board before we ship it. Your MiniDragon-Plus3 board actually becomes a programmer.
The option a) will erase the D-Bug12 portion of flash memory, not the bootloader itself. The option b) will program the D-Bug12 portion of flash memory, not the bootloader itself. The file to be programmed into flash memory must be an s2-record file. If your assembler and compiler generate s1-record files only, you must convert an s1-record file to an s-2 record file before programming flash memory with the bootloader. The option c) will set a new baud rate. The option d) will erase all on-chip EEPROM.
It will assemble your source program and generate hex code within 4K locations from $2000 to $2FFF. Here is a very simple program, but it’s complete. It will light up all 7 segments one at a time when it’s running. The RAM byte named ‘counter’ is added for demonstrating how a RAM data byte is used in a user program. In this simple program it’s not really necessary, because the accumulator A can be used as the RAM byte ‘counter’.
3. Click Build button, select Assemble option, or click the assembler button on the toolbar to assemble your code and generate an s19 file. If the assembler detects an error, the error message will show the line numbers of your source code that caused the error. You have to correct all errors in your program. 4. Go to the line and correct the errors and go back to step 3 until there are no errors. 5. Press the reset button on the board, you will see: D-Bug12 v4.0.
3.3.3 Use on-chip flash for testing your code in BOOTLOADER mode. In this mode, you download your program directly into on-chip flash memory. You first erase the D-Bug12 monitor portion of flash memory, and then program that portion of the flash memory by downloading your application program code in an s29 file. Your program will replace the D-Bug12 monitor in the flash memory. The bootloader portion of the flash memory remains intact.
Chapter 4: Hardware Descriptions The crystal frequency is 16 MHz and usually it will result in an 8 MHz bus speed, but on this board the MC9S12DG256’s internal PLL boosts the bus speed up to 24 MHz. The circuits are designed in such way that the value of all resistors and capacitors are not critical and they can be off -50% or +100%. 4.1 Power LED: The power LED is made of the decimal point of the 7-segment display. It will always be lit when power is applied. 4.
The segment A, B, C, D, E, F and G are driven by PH0, PH1, PH2, PH3, PH4, PH5 and PH6, respectively. The hex value of the segment code for common cathode LED display is shown in the following table: Number DP G F E D C B A Hex Value 1 0 0 0 0 0 1 1 0 $06 2 0 1 0 1 1 0 1 1 $5B 3 0 1 0 0 1 1 1 1 $4F 4 0 1 1 0 0 1 1 0 $66 To flash the number 1234 on the 7-segment display, the following steps should be taken: 1.
4.8 RS485 port The RS485 interface IC (SN75176) is not installed. To make RS485 work, user has to install the U9, shorting the J27 and install a terminal resistor (100 ohm) at the last node. 4.9 External SPI interface SPI port (J10) pinouts are as follows: Pin 1 Pin 3 Pin 5 MISO SPSLK /SS Pin 2 Pin 4 Pin 6 VCC (5V) MOSI VSS (GND) 4.10 LCD display (optinal) Port K is an 8-bit bi-directional port. It’s used for the LCD display module.
4.11 Keypad (optional) Port A is an 8-bit bi-directional port. Its primary usage is for a 4X4 keypad. If the port is not used for the keypad, it can be used as a general-purpose I/O.
If PA6 = low, the key 6 is down. If PA5 = low, the key 5 is down. If PA4 = low, the key 4 is down. Keypad scan routine sets PA0 low and PA1, PA2, PA3 high, then tests PA4-PA7. If no key is down, PA4-PA7 remain high. If PA7 = low, the key 3 is down. If PA6 = low, the key 2 is down. If PA5 = low, the key 1 is down. If PA4 = low, the key 0 is down. 4.
Chapter 5: Code Warrior and serial monitor Code Warrior is a very powerful and professional IDE. The main feature of Code Warrior IDE is the source level debugger in assembler and C. Code Warrior Special Edition is a wonderful gift from Freescale to all of us and it’s free for educational use. What's more, by Code Warrior supporting serial monitor, they have made it very affordable to support Code Warrior for the OEM.
Chapter 6: PLL code ; The crystal frequency on the MiniDragon-Plus3 board is 16 MHz so the default bus speed is ; 8 MHz. In order to set the bus speed high than 8 MHz the PLL must be initialized. ; ; You can cut and paste the following code to the beginning of your program.
Chapter 7: Appendix 7.1 D-Bug12 utility routines The AN1280 was written for OLD 68HC12 family. If you happen to use printf routine with your old 68HC12 board you should be aware that I/O utility routines are moved to different addresses in D-Bug12 V4.x.
7.
Fig 8-3: MC9S12DG256 Interrupt vector table 2 35
Fig 8-4: MC9S12DG256 secondary interrupt vector table 36