Home
MiniDragon+USB user`s manual
Contents
1. Get a character from SCIO or SCIL Checks for membership in the set 0 9 a f A F _ Converts lower case characters to upper case istrlen Returns the length of a null terminated string strepy EEN Copies a null terminated string Displays 8 bit number as 2 ASCII hex characters Disp SetUserVector Setup user interrupt service routine S Ge j far WriteEEByte Write a data byte to on chip BEPROM SEAS ReadMem _ Read data from the M68HC12 memory map WriteMem Write data to the M68HC12 memory map Fig 8 1 D Bug12 utility routines 34 8 2 Interrupt vector table Table 5 1 Interrupt Vector Locations Vector Address Interrupt Source FFFE FFFF Reset FFFC FFFD Clock Monitor fail reset FFFA FFFB COP failure reset FFF8 FFF9 Unimplemented instruction trap FFF6 FFF7 SWI FFF4 FFF5 XIRQ FFF2 FFF3 IRQ FFFO FFF1 Real Time interrupt FFEE FFEF Enhanced Capture Timer channel 0 FFEC FFED Enhanced Capture Timer channe 1 FFEA FFEB Enhanced Capture Timer channel 2 HPRIO Value Local Enable to Elevate PLLCTL CME SCME COP rate select None CRGINT RTIE TIE COl TIE C11 TIE C31 TIE C41 BEE ee X Bit None E EC E8 FFE8 FFE9 Enhanced Capture Timer channel 3 l Bit FFE6 FFE7 Enhanced Capture Timer channel
2. If you don t use more than 2 CAN ports these two chips are identical and all datasheets and manuals for the DP256 can be used for the DG256 The MC9S12DG256 microcontroller consists of a powerful 16 bit CPU central processing unit 256K bytes of flash memory 12K bytes of RAM 4K bytes of EEPROM and many on chip peripherals The main features of the MC9S12DG256 are listed below Powerful 16 bit CPU 256K bytes of flash memory 12K bytes of RAM 4K bytes of EEPROM SCI ports SPI ports CAN 2 0 ports C interface 8 ch 16 bit timers 8 ch 8 bit or 4 ch 16 bit PWM 16 channel 10 bit A D converter Fast 25 MHz bus speed via on chip Phase Lock Loop BDM for in circuit programming and debugging 112 pin LQFP package offers up to 91 I O in a small footprint 1000 4000 8000 C000 FFOO SFFFF EXTERN VECTORS VECTORS EXPANDED NORMAL SINGLE CHIP SINGLE CHIP Assuming that a 0 was driven onto port K bit 7 during MCU is reset into normal expanded wide or narrow mode Fig 1 1 MC9S12DG256 Memory map REGISTERS Mappable to any 2k Block within the first 32K 4K Bytes EEPROM Mappable to any 4K Block 12K Bytes RAM Mappable to any 16K and alignable to top or bottom 16K Fixed Flash Page 3E 62 This is dependant on the state of the ROMHM bit 16K Page Window 16 x 16K Flash EEPROM pages 16K Fixed Flash Page 3F 63 BDM if active Single wire Background ei
3. MC9S12DG256 secondary interrupt vector table 37 8 3 8 4 Useful web links The web is the best source for getting more information about the HCS12 The Freescale web site has all documents and application notes that you need The HC12 user group http groups yahoo com group 68HC12 is a good place to ask a question and get a prompt answer from many other HC12 users You also can visit our web site at http www evbplus com he11 68hc11 hc12 68hc12 9s12 hcsi2 sites html to get links to many university web sites that offer course materials and lab assignments for the Dragon12 and MiniDragon boards All HCS12 boards that are pre loaded with Freescale serial monitor bootloader and D Bug12 monitor on the market today are basically the same products as far as software development is concerned If you are going to use a BDM to debug a HCS12 board all HCS12 boards will respond to all BDM commands in the same manner because the BDM directly communicates with the MC9S12DG256 MCU The information on our manual can apply to the boards from other manufacturers and vice versa Troubleshooting notes The following are some important notes that you should know and they may save you time 1 Things to do if the board does not work Many little mistakes can cause a big problem especially for beginners Before troubleshooting the board you must apply power to the board When the board is powered the decimal point of the 7 segment LED must
4. 4 l Bit SFFE4 SEFES Enhanced Capture Timer channel S TB TIE C5 SFFE2 SFFES Enhanced Capture Timer channel 6 Cer TE C6 FFEO FFE1 Enhanced Capture Timer channel 7 L t TIE C71 FFDE FFDF Enhanced Capture Timer overflow L n TSRC2 TOF FFDC FFDD Pulse accumulator A overflow Bit _PACTL PAOV SDC FFDA FFDB Pulse accumulator input edge L t PACTL PAI DA FFD8 FFD9 SPIO Bit SPOCR1 SPIE SPTIE D8 SCOCR2 FFD6 FFD7 SCIO ml TIE TCIE RIE ILIE D6 FFD4 FFD5 SCH LEI TIE ee ILIE D4 ATDO l Bit ATDOCTL2 ASCIE D2 ATD1 L t ATD1CTL2 ASCIE D0 Port J Bit _PTJIF PTJIE CE Port H Bit PTHIF PTHIE SCC Modulus Down Counter underflow L n MCCTL MCZI CA Fig 8 2 MC9S12DG256 Interrupt vector table 1 35 FFC8 FFC9 Pulse Accumulator B Overflow l Bit PBCTL PBOVI C8 FFC6 FFC7 CRGPLLiock Bit CRGINT LOCKIE C6 FFC4 FFC5 CRG Self Clock Mode Bit CRGINT SCMIE C4 FFC2 FFC3 BDLC te oe C2 FFCO FFC1 IC Bus L t IBCR IBIE SCH SFFBE SFFBF Tet seen SPTE SBE FFBC FFBD l Bit SP2CR1 SPIE SPTIE BC FFBA FFBB EEPROM L t SBA FFB8 FFB9 L t FCTL CCIE CBEIE B8 FFB6 FFB7 CANO wake up l Bit CANORI
5. Module Clock and Reset Generation Module CPU12 PE2 oo ER System Enhanced Capture PES aai H Les Integration Timer PE4 m E S es MIM PES a SIM PES we PET ap ER TEST PEPtte et CITT Multiplexed Address Data Bus titit fttit PTB BDLC AXB J1850 TXB AXCAN CANO TXOAN AXCAN TXCAN AXCAN gt PBI oe ADDRO PBO CANI CAN2 ADDR15 PAT ADDR14 PAG ADDR13 PAS es ADDA12 PA4 oe ADDRA11 PAS we ADDAIO PA2 ADDRS PAI es ADDRS PAO ee ADDR PB e ADDR PDG ss ADDRS PBS ee ADDR4 PB4 at ADDRS PBS ADDR2 PB20 ADDR1 Module to Port Routing bal 5 DATA15 DATA14 DATA13 DATA12 DATA11 DATA10 DATAS DATAS VO Driver 5V VDDX ws VSSX ee A D Converter 5V A Voltage Regulator Reference VDDA VSSA Intemal Logic 2 5V VUD7 3 VSS1 2 d PLL 2 5V VDDPLL VSSPLL A Voltage Regulator 5V A VO VODR ee VSSR rat VRH VRL e VDDA ra VSSA PAD08 s PAD09 PAD10 PAD1I1 PAD12 a PAD13 PADI4 s PADIS em e E D D PK1 XADDRI5 PK2 XADDR16 PK3 XADDRI7 PK4 XADDR18 PKS 1 XADDRI9 a 90 v Ka x i o mi x gl S kel D PS 8 iS PTO PT PT2 PT3 PT4 PTS pre PT7 PSO PS1 reg pS P53 DORT PTT t PTS lt PMO we PM zb PM2 PM3 PMG awe PMS gt PMG PM7 PTM PO PJI r PJG PJ res PPO
6. PADOG ANO6 PAD13 AN13 PADOS ANOS PAD12 AN12 PADO4 ANO4 PAD11 AN11 PADO3 ANO3 PAD10 AN10 PADO2 ANO2 PADO9 ANO9 PADO1 ANO1 PADO8 ANO8 PADOO ANOO V vDD2 PA7 ADDR15 DATA15 PA6 ADDR14 DATA14 PAS ADDR13 DATA13 PA4 ADDR12 DATA12 PA3 ADDR1 1 DATA11 PA2 ADDR10 DATA10 PA1 ADDR9 DATAS PAO ADDR8 DATA8 Signals shown in Bold are not available on the 80 Pin Package Fig 1 3 MC9S12DG256 MCU pin assignments 1 3 On board hardware features 1 4 The MiniDragon board includes the following features 18 19 20 21 Dual SCI communication ports CAN port option SPI expansion port for interfacing external SPI devices 7 segment LED display RGB tri color LED Light sensor Two jumper switches Two push button switches 5V regulator with DC jack Speaker to be driver by timer or PWM signal for alarm or music applications Power On LED indicator BDM in connector to be connected with a BDM from multiple vendors for debugging BDM POD mode for programming other HCS12 boards No extra hardware needed Abort switch for stopping program when program is hung in a dead loop Mode switch for selecting 4 operating modes EVB Jump to EEPROM BDM POD and Bootloader 4X 4 keypad header Wytec s TinyBee 3 axis accelerometer interface or GP2 D12 distance measuring sensor interface for distance measurement Potentiometer trimmer pot for analog input Female or male headers provides all I O pins of the MC9S12DG256
7. amp S4 closed 2 S3 closed amp S4 open 3 S3 amp S4 open If it does not occur check the Power On LED indicator The PWR LED is the decimal point of the 7 segment It is lit when VCC 5V is present If the PWR LED is off check the jumper on J7 lt should be set in the up position so the board is powered by the AC adapter Also check the output of the AC adapter It should be about 10V DC without a load the output DC voltage of the AC adapter is rated for 7 5V at 300mA but usually the voltage is much higher without a load Plug the USB cable into the UTA USB to TTL adapter and UTA to J3 via a 4x2 IDC cable then plug the other end of the USB cable into a USB port not a USB hub on your PC The other 4x2 header J2 is the MC9S12DG256 s SCI1 port that can be used by a user s program To invoke the AsmlDE right click the Start button then left click Explorer left click on C MiniDragon and finally double left click on AsmIDE exe If you have created a shortcut icon on the desktop just double click the AsmIDE icon on the desktop Note Always connect the UTA to your PC first before invoking the AsmIDE otherwise the AsmIDE will not be able to find a COM port When ending a debugging session always close the AsmIDE first before disconnecting the UTA Otherwise the AsmIDE may hang up and you need to re establish the USB link again This problem will happen to any IDE In case the AsmIDE hangs up you need to close the
8. assemble and disassemble code as you would in a BUFFALO monitor based Freescale 68HC11 EVB It gives you 12K RAM and 3K EEPROM to develop and debug your code You must place your interrupt vectors at 3E00 3E7F because real interrupt vector addresses are taken by bootloader bootloader and D Bug12 monitor will redirect interrupts to the RAM interrupt vector table at 3E00 3E7F After booting up in this mode you should see the following message on PC screen D Bug12 v4 0 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help gt Typing help then lt Enter gt will display a list of available commands In this mode you cannot erase or program on chip flash memory If the D Bug12 monitor is erased you can use bootloader to re program D Bug12 monitor into flash memory 16 3 1 2 Jump to EEPROM mode PAD1 0 PADO 1 3 1 3 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 The bus speed is 8MHz one half of the crystal frequency by default the PLL function must be initialized by user s code for a higher bus speed because the D Bug12 monitor firmware that boosts bus speed to 24 MHz is bypassed If you need to auto start your code upon reset the procedure is available in the folder named eeprom_p
9. be on If it s off the board does not have 5V DC Sometimes it may be caused by a bad AC adapter or the AC adapter may not even be plugged in To determine if the board malfunctions you can restore the following jumper settings to the original default settings when you receive the board The default settings are as follows 3 AN5 input No jumper S4 AN6 input No jumper J15 Speaker driving source Jumper is placed in the top position driven by PT5 S7 MODE select both DIP switches of S7 are set in the low positions for EVB mode If all above settings are correct and when you press the reset button the 7 segment LED should display the diagnostic code of E 4 3 momentarily If this does not occur the bootloader could have been erased by a BDM You can use a BDM with instructions from the manufacturer or use another MiniDragon board as a BDM POD to re program bootloader and D Bug12 monitor into flash memory according to the instructions on page 17 If the diagnostic code is displayed correctly but the board does not communicate with the terminal the EVB portion of flash memory could be erased or the com port number may not be set correctly by the AsmIDE You can re program the D Bug12 in bootloader mode according the instructions on page 20 The newest firmware can be downloaded at www evbplus com download_hcs12 html 38 If the screen displays some garbled characters the baud rate may not be set correctly The D Bug12
10. resets the baud rate to 9600 at power up if you changed the baud rate you must change the AsmIDE s baud rate to the same value 2 Always reset the board before downloading a new program If the previous application program that you ran was aborted then you may need to reset the board before downloading a new application program The reset action will disable the interrupt that was enabled by the previous application If the interrupt was caused by a timer and is not disabled the timer interrupt will continue even it s not called for in your new application program The result will be unpredictable 3 In EVB mode reset clears your pseudo RAM interrupt vectors When you develop code with interrupts in RAM you must initialize pseudo RAM interrupt vectors in the very beginning of your program because if you press the reset button it will clear all pseudo RAM interrupt vectors If you don t initialize pseudo RAM interrupt vectors in your program and your application program uses interrupts your program may not run correctly since the interrupt vectors do not exist 4 Operating mode changing is only effective after reset There are four operating modes that are selected by S7 The mode change won t be effective until you reset the board So you must always press the reset button after a mode change 39
11. to MiniDragon You can double check the target location by right clicking on the icon then left click on properties You should see that the target location is C MiniDragon If you want to make a shortcut for AsmIDE on the Desktop this is the correct way to do it If you dont follow this method you may have a problem running your program Never drag the AsmIDE exe to the desktop folder The default setting of AsmIDE for the MiniDragon board is created in a text file named c MiniDragon AsmIDE ini In the future if you get lost with all the changes you always can copy this file into the folder c MiniDragon 12 2 2 Getting Started To operate the MiniDragon 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 the AC adapter into a wall outlet and plug the female plug of the AC adapter into the DC jack on the left side of the MiniDragon board After power up the speaker should chirp once the 7 segment LED should display the diagnostic code E 4 3 momentarily The letter E stands for EVB mode the number 4 stands for single chip mode and the number 3 means that 2 switches S3 S4 are open Here is the code explanation First letter E EVB mode J Jump to EEPROM P Pod and b Bootloader mode Second number 4 Single chip mode 6 Narrow expended mode 7 Wide exp mode Third number 0 S3 amp S4 closed 1 S3 open
12. 2D 9AFD 98AD 9D5EFO0EFOOEF0039 S9030000FC 18 We are not going to explain the s record format here If you would like to know more on the subject you can review the D Bug12 reference guide on the CDROM BD12RG4 PDF It explains the subject in great details Right now all you need to know is that an s1 record file must be converted to an s2 record file before using the FLOAD command The FLOAD command in the D Bug12 is for downloading an s2 record file Our MiniDragon bootloader is modified from the Motorola s BootDP256 asm We added our modification to the original source code and the s record file is generated by the AsmIDE It s an s1 record file and we converted it into an s2 record file by using the following commands Sreccvt m c0000 fffff 32 of 0000 o Boot_MDP_16MHz s29 Boot_MDP_16MHz s19 Now we type FLOAD lt Enter gt at the prompt Click the Build button select the Download option and select the file named Boot_MDP_16MHz s29 located in the folder named D Bug12_Monitor You should see the following on the terminal window when programming is done when the prompt s gt appears S gt fload lt Enter gt Kk kk kk kk k k k k RE kk kk kk kk k kk kkk k kk kkk k kk kkk kk kk kk kkk kkk kk kk kk kk dree ek kkkkkkkkkkk S gt Now we are going to program the D Bug12 monitor into the flash memory We need to type FLOAD lt Enter gt at the prompt Cl
13. 400 tie solderless breadboard included Small PC board size 5 25 X 3 40 The MiniDragon board has the following features as options 22 23 4 X 4 keypad 16X2 LCD UO Pin Usage Many HO pins of the MC9S12DG256 on the MiniDragon board are used by on board peripherals but thanks for the large 112 pin LQFP package there are still many I O pins available for your circuits on the breadboard Also it s unlikely that all on board peripherals will be used by one application program So the I O pins on unused peripheral devices can still be used by your circuits on the breadboard For instance if you don t connect a keypad the entire port A will be available to your circuits If you don t use LCD the port K will be available as well Port B drives H Bridge but if you don t connect a motor the port B can drive any other I O devices on the breadboard Pin Name Pin I O Usage PAO output Pin 57 Col_0 of keypad PA1 output Pin 58 Col_1 of keypad output PA2 output Pin 59 Col_2 of keypad output PA3 output Pin 60 Col_3 of keypad output PA4 input Pin 61 Row_0 of keypad DAP input Pin 62 Row_1 of keypad input PA6 input Pin 63 Row_2 of keypad input PA7 input Pin 64 Row_3 of keypad input PBO Pin 24 not used PB1 Pin 25 not used PB2 Pin 26 not used PB3 Pin 27 not used PB4 Pin 28 not used PB5 Pin 29 not used PB6 Pin 30 not used PB7 Pin 31 not used PEO input Pin 56 Abort switch SW8 PE1 Pin
14. 55 not used PE2 Pin 54 not used PE3 Pin 53 not used PE4 Pin 39 not used PE5 Pin 38 not used PE6 Pin 37 not used PE7 Pin 36 not used PHO Pin 52 Segment A on display PH1 Pin 51 Segment B on display PH2 Pin 50 Segment C on display PH3 Pin 49 Segment D on display PH4 Pin 35 Segment E on display PH5 Pin 34 Segment F on display PH6 Pin 33 Segment G on display PH7 Pin 32 not used PJO Pin 22 not used PJ1 Pin 21 not used PJ6 Pin 99 not used PJ7 Pin 98 not used PKO Pin 8 not used PK1 Pin 7 not used PK2 Pin 6 not used PK3 Pin 5 not used PK4 Pin 20 not used PK5 Pin 19 not used PK7 Pin 108 not used Table 1 1 I O pin usage list 1 10 Pin Name Pin UO Usage PMO Pin 105 CANO PM1 Pin 104 CANO PM2 output Pin 103 EN of LCD module PM3 output Pin 102 RS of LCD module PM4 output Pin 101 DB4 of LCD module PM5 output Pin 100 DB5 of LCD module PM6 output Pin 88 DB6 of LCD module PM7 output Pin 87 DB7 of LCD module PPO Pin 4 not used PP1 Pin 3 not used PP2 Pin 2 not used PP3 Pin 1 not used PP4 Pin 112 RGB LED PP5 Pin 111 RGB LED PP6 Pin 110 RGB LED PP7 Pin 109 not used PSO Pin 89 SCIO for PC communication RECV RJ11 connector JK1 PS1 Pin 90 SCIO for PC communication XMIT RJ11 connector JK1 PS2 Pin 91 DCH for user applications RECV J2 PS3 Pin 92 DCH for user applications SMIT J2 PS4 Pin 93 not used PS5 Pin 94 not used PS6 Pin 95 not used PS7 Pin 96 not used PTO Pin 9 n
15. AsmIDE first then pull the USB cable out the USB jack on the UTA wait for a few seconds before re plug the USB cable into the UTA After cycling USB connection you can invoke the AsmIDE again and it may restore the USB communication If this does not work you need to reset your PC so in order to avoid it always close the AsmIDE before unplugging the USB cable The AsmIDE is simple and very easy to use You only need to use three commands from the AsmIDE for your HCS12 development work Use the File command to edit your source code the Build gt Assemble command to assemble your source code and the Build gt Download command to download an s19 file to the MiniDragon board 13 The COM port number that the AsmIDE uses must match the USB to Serial COM port number that is assigned by Windows O S Windows O S assigns the USB to Serial COM port number randomly and it does not know which COM port number that AsmIDE is going to use In order to find the USB to Serial COM port number you can click through control panel gt systems gt hardware gt device manager gt ports the USB to Serial COM port number will appear In Windows Vista you left click on Start right click on Computer left click on propriety then Device Manager and then Continue For setting the COM port of the AsmIDE to match that USB to Serial COM port number you can click through View gt Option gt Terminal Window Options menu then select the correct COM port fro
16. ER WUPIE B6 FFB4 FFB5 CANO errors l Bit CANORIER CSCIE OVRIE B4 FFB2 FFB3 CANO receive L t CANORIER RXFIE B2 FFBO FFB1 CANO transmit L t CANOTIER TXEIE2 TXEIEQ B0 SFFAE FFAF CANT wake up I Bit CAN1RIER WUPIE SAE CANT errors LB CAN1RIER CSCIE OVRIE AC EA gem Tou ees LIST CANIRIER RXFIE SAA CANT transmi SA8 CAN2 wake up CAN2RIER WUPIE A6 CAN2 errors CANZ2RIER CSCIE OVRIE A4 FFA2 FFA3 CAN2 receive CAN2RIER RXFIE A2 CAN2 transmit CAN2TIER TXEIE2 TXEIE0 A0 CAN3 wake up CAN3RIER WUPIE 9E FFOC FFOD CAN3 errors l Bit CAN3RIER TXEIE2 TXEIEO 9C CAN receive 1 Bit CANS3RIER RXFIE 9A CANS transmit l Bit CANSTIER TXEIE2 TXEIE0 98 Dages CANE wakeup Bt Cen WUPIE 96 era mee T nten Bit CANARIER CSCIE OVRIE CAN4 receive I Bit CAN4RIER RXFIE CAN4 transmit I Bit CAN4TIER TXEIE2 TXEIE0 rs eg PonPinterupt Bit _PTPIF PTPIE ra SFFBD PWM Emergency Shutdown Vi PWMSDN PWHIE 6 Reserved Fig 8 3 MC9S12DG256 Interrupt vector table 2 Secondary Secondary Interrupt Source Vector Interrupt Source Vector Address Address Reserved FF80 EF80 SEFCO ere SEFCS SEFOA SEFCC SEFCE SEFOO e er SEFDS SEFDB SEFOA SEFDC SEFDE SEFEO Sr SEFE ere SEFES SEFEA SEFEC SEFEE Real time interrupt EFFO MSCAN 0 receive EFB2 IRQ EFF2 SE Unimplemented instruction trap EFF8 SEFFA Clock monitor fail reset EFFC SEFFE Fig 8 4
17. EY14 KEY15 O O Q P64 PATE PA7 Row 3 KEYPAD Keypad connections PAO connects COLO of the keypad PA1 connects COL1 of the keypad PA2 connects COL2 of the keypad PA3 connects COL3 of the keypad PA4 connects ROWO of the keypad DAD connects ROW1 of the keypad PA6 connects ROW2 of the keypad PA7 connects ROW3 of the keypad Keypad scan routine sets PA3 low and PAO PA1 PA2 high then tests PA4 PA7 If no key is down PA4 PA7 remain high If PA7 low the key 15 is down If PA6 low the key 14 is down If PAS low the key 13 is down If PA4 low the key 12 is down Keypad scan routine sets PA2 low and PAO PA1 PAS high then tests PA4 PA7 If no key is down PA4 PA7 remain high If PA7 low the key 11 is down If PA6 low the key 10 is down If PA5 low the key 9 is down If PA4 low the key 8 is down Keypad scan routine sets DAT low and PAO PA2 PAS high then tests PA4 PA7 If no key is down PA4 PA7 remain high If PA7 low the key 7 is down If PA6 low the key 6 is down If PA5 low the key 5 is down If PA4 low the key 4 is down 27 Keypad scan routine sets PAO low and PA1 PA2 PAS 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 11 All jumpers All on board jumpers J1 J2 J14 J15 J16 J18 CAN port SCH 2 SCI interface TT
18. L logical level BDM input pin 1 is the upper left pin BDM output when the board is booted in POD mode pin 1 is the upper left pin VCC select from external DC input or USB port It connects RS of CANO U5 to VSS via a SMD pad on the solder side Connects trimmer pot VR1 to the ANO7 of ADC and it s a SMD pad on solder side but the trace between the pads can be cut if ANO7 must be used by target circuits Connects VR1 to the VRH and it s a SMD pad on solder side but the trace between the pads can be cut if a different voltage is needed Selects speaker driving source The speaker can be driven by PT5 OC3 or PP5 PWM CAN receiver connection to PMO of MC9S12DG256 Remove the solder bridge if CANDO is not enabled Connects a terminating resistor for CANO Place a solder bridge on it at the last node in a network If CANO is not used it will save power consumption of the board by removing the solder bridge Connects Common Cathode of the RGB LED to VSS LCD port Keypad header 132 right angle male header 13X2 female socket connector X Y X Accelerometer module interface or IR distance sensor GP2D12 interface 28 Chapter 5 EmbeddedGNU Eric Engler has published the EmbeddedGNU IDE that supports GNU C compiler and assembler for any 68HC11 HC12 HCS12 boards including our FOX11 EVBplus2 Dragon12 and MiniDragon boards It s free software under Open Source GNU GPL License It s not freeware nor shareware be aware tha
19. MiniDragon Trainer With USB interface for Freescale HCS12 microcontroller family User s Manual Revision 1 03 Table OF Contents Chapter 1 1 1 1 2 1 3 1 4 Chapter 2 2 1 2 2 2 3 Chapter 3 3 1 3 2 3 3 Chapter 4 4 1 4 2 4 3 4 4 4 5 4 6 4 7 4 8 deefe e VE 4 eltren eeh Eege EEN 4 MC9S12DG256 features and memory MAP sssseeseecesseeseeseesteneseenseenieenseseeeeneneneesnenees 5 On board hardware features cssssscssssscesssessseseeeesseeessenaeeneeseensseenesenaeanasseeaesenauaeseesenssenes 9 Kette e aa EE EE he satanic EE A E sasecacsstenceadstcodssnated AT 9 QUICK Stab r r ae ar ra aara arra a aa a aaa aaa pa aa aaaea Aa aE aaa Aa aAa dada Ao aaa aaea aa eaaa asiat ia 12 Install software from CD essssscsssceseeneseesseensseenseenaesensseeneeenaeaesaeaeesseeaesenauaensseeaeeeneeenenenan 12 Getting SAT ac ec ct ace acces ae races can aa er ra aaa rer a a En tet calis vectcuaeavcs ue 13 LG dE TN 15 Software Desript ons ies e a esoe eer EE 16 Bootloader and D BUG12 monitor scsecsssessessseesesseeeseeneenseseeeseeeesenaeenseseesnenaeenneeeeas 16 BAT EVB Ode iiss ct ciee EE cia acca ccesnces ches afc deca E E E 16 3 1 2 Jump to EEPROM Mode esscsscsssssseesssseesesseenssseeesseenseenaesensseeaseenavsnnsseeaeeenansenas 17 3 1 3 BDM POD MOG isisao oriana aeaaea aa daadaa aeaaea aaiae aa eaaa aaa asiaa daaa iaaa 17 3 1 4 Bootloader mode cccssssceccessneescessessees
20. MiniDragon board actually becomes a programmer You can then repeat above steps as many times as you want Just unplug the 6 pin BDM cable from the target board and then plug it into a new target board to program its flash memory with these two files You even don t have to turn off the power while doing this For your convenience we combined both the bootloader and D Bug12 monitor into a single s2 file named Boot DBug12v32_MDP_16MHz s29 In case you need to update both of them you can download this combined file The D Bug12 monitor is an application program runs from the bootloader If you program the D Bug12 portion of flash memory with your application program your program will run automatically in EVB mode after power up or reset When running your code instead of the D Bug12 monitor the bus speed is 8MHz one half of the crystal frequency by default The PLL function must be initialized by your code for a higher bus speed because the D 19 Bug12 monitor firmware was not in flash memory anymore For your convenience we include a PLL code template in chapter 7 If you need to auto start your code upon reset the procedure is available in the folder named flash_programming BOOTLOADER mode PAD1 1 PADO 1 This bootloader allows you to erase program flash memory and erase EEPROM It is mainly used to program the D Bug12 monitor into flash memory or download a user s fully debugged code into the D Bug12 portion of flash memory
21. PC to a development board while Upload means to transfer a file from a development board to PC Through out the manual left click means that you click the left button of the mouse and right click means that you click the right button of the mouse 2 1 Install software CD After download the CD from our web site the installation is automated by double clicking on the SETUP BAT It will create a folder c MiniDragon examples and copy all example program files from the CD to c MiniDragon examples If the filename is only shown as SETUP not SETUP BAT you should change a folder option of the Explorer to show file extension When a file s extension is hiding it is hard to know what it is To have your files to be shown with extensions click on the TOOL tab in Explorer menu then click on folder options then click on view tab finally un check the item named Hide extensions for knowing file types After the software is successfully installed you can make a shortcut to AsmIDE exe on the desktop It s important to make a shortcut so that its target location is C MiniDragon not c Windows desktop or other locations First right click the Start button then left click Explorer left click on C MiniDragon right click on AsmIDE exe an application program left click Send to and finally left click Desktop do not click COPY It will create an icon named shortcut to AsmIDE on the desktop and you can rename it
22. The latter allows the board to be operated in EVB mode and start your code every time the board is turned on or reset When you program your code into the D Bug12 portion of flash memory it wipes out the D Bug12 monitor You can restore it any time just as if you were downloading another application program since the bootloader is not erased You can erase and program the D Bug12 monitor portion of the flash memory of the MC9S12DG256 on its own board in bootloader mode but you cannot erase and program bootloader by itself The bootloader can only be erased by an external BDM via BDMin port After booting up in this mode you should see the bootloader menu on PC screen MC9S12DG256 bootloader menu a Erase Flash b Program Flash c Set Baud Rate d Erase EEPROM 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 Note Quite a few users would accidentally erase the D Bug12 monitor when entering this mode so it s important to know how to re program the D Bug12 monitor To program flas
23. aea Ea aae aeaea aaa a ea a aaao saaa aeaii aoui panei eaae 34 8 1 D Bug12 Utility LEE 34 8 2 Interrupt vector EI 35 8 3 Useful Web NKS tee 38 8 4 Troubleshooting ul CN 38 Note For users who will use Code Warrior IDE with serial monitor 1 This manual is written for the board that is pre installed with bootloader and D Bug12 monitor For some university students the board is pre installed with serial monitor and a factory test program The software installation on the page 12 is not needed Once the serial monitor is installed the board will not work with AsmIDE or other terminal programs The left DIP switch of S7 has been set in the up position as a factory default setting for running the test program When the board is turned on it will display a diagnostic code U 4 3 on the 7 segment LED before running the test program If it displays 5 4 3 then the left DIP switch of S7 is reset in the low position You have to set it in the up position and then press the reset button The functions of the test program are described in the test16 asm in the CDROM Code_Warrior examples The U stands for running User program After running through the test program you have to reset the left DIP switch of S7 in the low position for interfacing with Code Warrior IDE Oakland university students should follow their professor s instructions to operate the board When the left DIP switch of S7 is reset in the up
24. am the on chip flash memory is shown on page 17 The latest D Bug12 monitor and serial monitor can be downloaded from www EVBplus com download_hcs12 download_hcs12 html Some universities use Code Warrior IDE only In this case we pre load the on chip flash memory with serial monitor If your board is pre installed with D Bug12 monitor it will display the diagnostic code E 4 3 on the 7 segment LED and the speaker will chirp once when the board is turned on The code character E stands for EVB mode If you ordered the board with serial monitor for Code Warrior it would be pre installed with serial monitor and a factory test program The state of the left switch of the 2 position DIP switch S7 is tested by the serial monitor for selecting RUN or LOAD mode during power up or reset If the left switch is placed in LOAD mode in the low position the monitor will display the diagnostic code S 4 3 on the 7 segment LED and the speaker will chirp once and then wait for a command from PC If the left switch is placed in RUN mode in the up position the monitor will display the diagnostic code U 4 3 on the 7 segment LED and the speaker will chirp once to indicate that the program execution is diverted to the user code The code character U stands for running a User program and the code character S is displayed as the number 5 and stands for Serial monitor 31 Code Warrior communicates with serial monitor onl
25. common cathode All anodes are driven individually by an output port and all cathodes are internally connected together The MiniDragon board uses port H to drive 7 segment anodes We will explain how to flash the number 1234 on the display Before sending a number to a 7 segment LED the number must be converted to its corresponding 7 segment code depending how the 7 segment display is connected to an output port By convention the 7 segments are called segment A B C D E F and G Their locations in the display are shown below 24 4 4 4 5 The segment A B C D E F and G are driven by PHO PH1 PH2 PH3 DHA 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 DJ C B AJ Hex Value 1 0 0 0 0 0 1 1 0 06 2 O 1 0 1 1 10 1 l1 5B 3 0o 1 0 0 1 1 1 1 4F 4 O 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 Output 06 to port H Idaa 6 staa pth and the number 1 will be shown on the 7 segment Delay 250ms Output 5B to port H Idaa 5B staa pth and the number 2 will be shown on the 7 segment Delay 250ms Output 4F to port H daa 4F staa pth and the number 3 will be shown on the 7 segment Delay 250ms Output 66 to port H Idaa 66 staa pth and the number 4 will be shown on the 7 s
26. e PPI e PP2 mes PPS res PP4 PPS sep PPE es PPT PHO PHT PH2 PH PHS te PHS res PHG res PH Signals shown in Bold are not available on the 80 Pin Package DDR PTJ DDAP PTP DDRH PTH Fig 1 2 MC9S12DG256 MCU block diagram SS4 PWM3 KWP3 PP3 SCK1 PWM2 KWP2 PP2 MOSI1 PWM1 KWP1 PP1 MISO1 PWMO0 KWPO PPO XADDR17 PK3 XADDR16 PK2 XADDR15 PK1 XADDR14 PKO IOCO PTO IOC1 PT1 lOc2 PT2 IOCTIPT7 XADDR19 PK5 XADDR18 PK4 KWJ1 PJ1 KWJO PJO ADDR2 DATA2 PB2 C 26 ADDR3 DATA3 PB3 C 27 ADDR4 DATA4 PB4 C 28 AN Ob Gabi a Be ae EES e 22 So Ss 28x88 NN Se SSSSAq as 2o8s 222225 22 SERGE 53553533F SE Foor Q9mlOLlSZS oS SS o SS eR RELESS SC SSES ssebakeo aS an p o SS SE zZ FOSA ea s E e E e BS e en en S SE E eo OO OS ee e SCC OG EE EELER See Oe E S E E E E e E E LS oo BO a Oo se SS SS SG E moo o oo SE So D D DO D 0 D D O D DO D D GD D O D O 0 D m e Om ow O OW zt MONTH ei GD ot oi VO MC9S12DP256B MC9S12DT256 MC9S12DJ256 MC9S12DG256 BOCH RAWIPE2 C 54 IRQIPE 155 XIRQ PEO 156 ECLK PE4 T 39 VSSR VDOR VSSPLL C 45 SS1 KWH3 PH3 C 49 SCK1 KWH2 PH2 C 50 MOSIKWH1 PH1 Cla SCK2 KWH6 PH6 MOSI2 KWH5 PH5 MISO2 KWH4 PH4 SS2 KWH7 PH7 ADDRS DATAS PB5 ADDRG DATAG PBE ADDR7 DATA7 PB7 MODA IPIPEO PES C 38 MISO1 KWHO PHO 7152 LSTRB TAGLO PE3 C 53 VRH VDDA PAD15 AN15 ETRIG1 PADO7 ANO7 ETRIGO PAD14 AN14
27. e button to open a new file In assembly language you specify the starting address of your CODE by an ORG statement You can start the data RAM at address 1000 with the statement org 1000 followed by RAM variables as shown by org 1000 count rmb 1 reserve one byte of RAM for temp storage temp rmb 2 reserve two bytes of RAM for temp storage If your program is small say less than 4K you can start your program at address 2000 with the statement org 2000 followed by your program as shown by org 2000 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 For a good programming practice you should always place the Ids instruction in the first line of your code include reg9s12 h REGBLK equ 0000 STACK equ 2000 org 1000 counter rmb 1 org 2000 program code start Ids STACK Idx REGBLK daa SEI staa ddrh x make port H an output port clr pth x turn off 7 segment LED display begin das 1 start with segment A back staa pth x turn on display jsr d250ms delay 250ms rola go to next segment tab ando 80 if
28. e is completely debugged then re assemble or re compile it at 0400 and download the final s19 file into the EEPROM for the auto start feature Like the RAM based development your interrupt vectors are at 3E00 3E7F In the beginning of your program you must initialize the interrupt vectors at 3E00 3E7F 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 To run your code set the mode switch S7 to EVB mode then press the reset button It usually runs the D Bug12 monitor but now it runs your program The flash memory is non volatile like the EEPROM Your code will run every time the board is turned on or reset The bootloader redirects interrupts to EF80 EFFF The D BUG12 is not present and the interrupt vectors of your program are at EF80 EFFF The addresses EFFE and EFFF contains the starting address of your program In order to program the MC9S12DG256 flash memory you must program an even number of bytes and begin on an even address boundary for each s record If any one s record in the file contains an odd number of bytes or begins with an odd address
29. egment Delay 250ms Go back to step 1 Trimmer pot The VR1 is connected to the ANO7 input of ADC port via J13 but the trace at J13 can be cut if ANO7 must be used by target circuits Light sensor The Light sensor Q1 is connected to the ANO2 input of ADC port via J17 but the trace at J17 can be cut if ANO7 must be used by target circuits 25 4 6 4 7 48 4 9 RGB LED The RGB LED consists of 3 individual common cathode RED GREN and BLUE LEDs in one single package They are connected to PP4 PP5 and PP6 The common cathode is connected to ground via J19 Speaker The speaker is a 5V audio transducer and it can be driven by PT5 Output Comparator 5 or PP5 PWM 5 The jumper on J15 is preset for the PT5 at factory and all sample programs on the CD will drive the speaker via PT5 After reset the bootloader or the serial monitor will generate a chirp via the speaker If the jumper is not placed for the PT5 the chirp won t happen Dual RS232 communication ports Both P1 and P2 RJ11 connectors are configured as DCE devices and they can be directly connected to the PC s COM ports The jack JK1 is used by SCIO of the DG256 while the header J2 is used by SC1 of the DG256 The D Bug12 monitor or serial monitor works with SCIO so the JK1 should be connected to a PC s COM port during debugging sessions The SCI1 can be used by user s application programs The receiver of the SCI1 can receive signals from many diff
30. ength 68he1l1e20___ ioports ogo Check this box to have EmbeddedGNU run the eeprom D abjalloc utility in the make process data 1000 Target the E20 Click here to fill in the values to the left Map for 68he11e20 stack 2000 User Defined Entry optional text 2000 vectors To change the linker search directory search path for GNU C compiler toolset you click on options gt project options gt edit profile As it can be seen from above Linker Search Directory the GCC 3 3 6 is installed on C drive Some university web sites offer educational resource for the EmbeddedGNU The following web site provides A C sample program for the Dragon12 board using EmbeddedGNU and GCC 30 Chapter 6 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 Freescale has invested millions of dollar into Code Warrior and the current versions work very well What s more Freescale knows they will never sell enough copies of Code Warrior to make back what they have invested They did it to drive chip sales As a software developer the first th
31. enience we have included this sample program flash_7seg asm on the CD 22 3 3 Software development 3 3 1 3 3 2 3 3 3 Use on chip 12K RAM for software development in EVB mode You can download your s19 file into the RAM and debug it with the D Bug12 monitor in this mode You must place your interrupt vectors at 3E00 3E7F because real interrupt vector addresses are taken by the bootloader The bootloader and the D Bug12 monitor will redirect interrupts to the RAM interrupt vector addresses at 3E00 3E7F Because RAM will lose its contents after power off you have to load your program every time after power up In the beginning of your program you must initialize the interrupt vectors at 3E00 3E7F In all sample programs the user program code locations are at 2000 3FFF The user data RAM locations are at 1000 1FFF The 64 RAM interrupt vector addresses are at 3E00 3E7F The 64 RAM interrupt vector addresses 128 bytes of RAM are assigned by the D Bug12 monitor to different interrupt sources The listing of interrupt sources is show on chapter 8 Use on chip 3K EEPROM for testing your code in EVB mode If your program is small enough to fit into a 3K range then you can download your code into the EEPROM In this way your program can be auto started from 0400 upon reset You cannot set software breakpoints and single step in the EEPROM in EVB mode so it makes sense to do development work in the RAM When your cod
32. erent devices but only one device at a time or it will cause a signal collision The jumper J14 connects the receiver of the SCI1 to the J2 When a jumper is installed on J14 the receiver of the SCI1 PS2 pin 91 of the MCU cannot be used for any other device If you need to use PS2 for your circuits on breadboard remove the jumper on J14 LCD display optinal Port M is an 8 bit bi directional port It s used for the LCD display module If the port is not used for the LCD display it can be used as a general purpose I O port The pinouts of J21 are as follows Pin 1 GND Pin 2 VCC 5V Pin3 Via a 220 Ohm resistor to GND Pin 4 PM3 RS pin for LCD module Pin 5 GND Write only for LCD module Pin 6 PM2 EN pin for LCD module Pin 7 Not used Pin 8 Not used Pin 9 Not used Pin 10 Mot used Pin 11 PM4 DB4 pin for LCD module Pin 12 PM5 DB5 pin for LCD module Pin 13 PM6 DB6 pin for LCD module Pin 14 PM7 DB7 pin for LCD module 26 4 10 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 The schematic for the keypad connections is shown below PAO PA1 PA2 PA3 Col 0 Col_1 Col 3 Col 3 P57 PAX P62 _PAZ3X KEY1 KEY2 KEYS P61 PA4x PA4 Row_0 d O O q OC d O KEYS KEY6 KEY g O O g O q O O b P62 PASX PA5 Row_1 KEYS KEY1 KEY11 q O O q O d g d L A 4 1 P63 Pops PA6 Row_2 KEY13 K
33. h memory with the D Bug12 monitor 1 Enter the option a to erase D Bug12 portion of flash memory Wait until the bootloader menu re appears after flash memory is erased 2 Enter the option b the bootloader will wait for your file Do not type any thing on keyboard 3 Click the Build button select the Download option and select the file named DBug12v32_MDP_16MHz s29 located in the folder named D Bug12_Monitor for downloading You should see the following on the screen kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kk k k k k k k k kk k k k k k k k k kk k kk kk k k k k k kk k kk kk k kk k k kk kk k kkk kk k kkk kk kkk kkk kk kkk kk kkk k Akk k k k k k k k kk k k k k k k k k kk k kk kk k k k k k kk k kk kkk kk k k kk kk k kkk kk kk kk kk kkk kkk kk kkk kk kkk k Akk k k k k k k k kk k k k k k k k k k k k kk kk k k k k k kk k kk kk k kk k kkk kk k kkk kk kk kk kk kkk kkk kk kkk kk kkk k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 4 Bootloader menu appears again after the D Bug12 monitor is programmed into flash memory It would take a few minutes to program the D Bug12 monitor so be patient 20 3 2 Making a simple assembly program in RAM We are using AsmIDE as a terminal program and the following instructions to create your first assembly program If you are using a different terminal program the instructions may vary The steps to create your first program are as follows 1 Click the Fil
34. ick the Build button select the Download option and select the file named DBug12v32_MDP_16MHz located in the folder named D Bug12_Monitor You should see the following on the terminal window when programming is done when the prompt s gt appears S gt fload lt Enter gt kkk kk kkk k kk RE kk kk k kkk k kk kkk k ee kkk k kk kkk kk k kkk kkk kkk kk kkkk kk kk kk kk kkkkkkkkkkk Kk kk k k k k k k k k k k kk kk k k kk k kk kkk k kk kkk k kk kkk kk kk kk kkk kkk kk kkk kkk k kkk kk k kkk kkk ERE kkk kk kk kk kk kk kk kk k kkk k kk kkk k kk kkk k kk kkk kk k kkk kkk kkk kk kk kk kk kkkkkkkkkkkkkkkkk kkkkkk kkk kkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkk kk kk kk kk kk kk kk k kkk k kk kkk k kk kkk k kk kkk kk k kkk kkk kkk kk kk kk kk kkkkkkkkkkkkkkkkk kkk kk kk kk kk kk kk kk k kkk k kk kkk k kkk kkk kk kkk kk k kkk kkk kkk kk k kkk kk kkkkkkkkkkkkkkkkk kkk kkk kk kk kk kk kk kk k kkk k kkk kkk kkk kkk kk kkk kk k kkk kkk kkk kk kk kk kk kkkkkkkkkkkkkkkkk Kk kk k k k k k k k k k k kk kk k k kk k kk kkk k kk kkk k kk kkk kk k kkk kkk kkk kk kkk kkk kkk kkk k kkk kkk kkk k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkk kkk kkk kkk kkk kkk kk kkk kkk kkk kkkkkk kk kkkkkkkkkkkkkkkkkkkkkkkk S gt 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
35. ing you look at is available tools and what it will cost There are many companies making MCU chips these days and for the most part they all have about the same features at a similar price Special Edition Code Warrior sets Freescale apart from others Code Warrior IDE does not work with D Bug12 but it works with serial monitor Before Freescale created the serial monitor a BDM is needed as an interface between the PC and HCS12 Freescale created the serial monitor for working with Code Warrior to eliminate the cost of a BDM Now a student can use the serial monitor with Code Warrior to debug his program and in fact many universities have been using the serial monitor with Code Warrior without a BDM in their classrooms Without spending money on a BDM a student will be able to spend his savings on purchasing a more advanced trainer like the MiniDragon board with many on board peripherals Purchasing an EVB board that comes with a BDM at a reasonable price most likely leaves the student with an EVB of only limited functionality Some universities use D Bug12 monitor first then replace the D Bug12 monitor with serial monitor to be used with Code Warrior IDE In this case a school laboratory only needs to have one BDM or use one Dragon12 board as a BDM POD to program all students boards with serial monitor To replace bootloader and D Bug12 monitor with serial monitor you need a BDM or a BDM POD to perform the task The instructions to progr
36. ions are set correctly you should see the following prompt every time the reset button on the MiniDragon board is pressed If you do not see this the bottom window may be set for message window Sometime it s a little confusing when terminal window is disabled and the message window does not display what you have typed In order to enable terminal window you have to click the terminal button in the bottom window to enable the terminal window display then move the cursor to any location in the terminal window and click the left button on the mouse After seeing a solid block cursor flashes press the lt Enter gt key and it will enable the terminal window D Bug12 v4 0 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help gt 14 2 3 Test Hardware To help users get up and running the MiniDragon board comes with many fully debugged ready to run sample programs including source code The hardware test program test asm simultaneously scans the keypad plays a song 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 In order to run the test program in EVB mode the two DIP switches of S7 must be set in the low positions to match the picture for EVB mode The steps to run your first sample program are as follows 1 Click the File button to open the test asm from cA MiniDrago
37. 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 The math used to set the PLL frequency is PLLCLK CrystalFreq 2 initSYNR 1 initREFDV 1 CrystalFreq 16 MHz on MiniDragon board initSYNR 5 PLL multiplier will be 6 intREFDV 3 PLL divisor will be 4 PLLCLK 16 2 6 4 48MHz The bus speed PLLCLK 2 24 MHz PLL code for 24MHz bus speed from a 4 8 16 crystal sei Idx 0 belr clksel x 10000000 clear bit 7 clock derived from oscclk beet pllctl x 01000000 Turn PLL on bit 6 1 PLL on bit 6 0 PLL off aa 05 5 1 6 multiplier staa synr x aa 03 divisor 3 1 4 16 2 6 4 48MHz PLL freq for 16 MHz crystal d Idaa 01 divisor 1 1 2 8 2 6 2 48MHz PLL freq for 8 MHz crystal aa 00 divisor 0 1 1 4 2 6 1 48MHz PLL freq for 4 MHz crystal staa refdv x wait_b3 brclr crgflg x 00001000 wait_b3 Wait until bit 3 1 bset clksel x 10000000 33 Chapter 8 Appendix 8 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 The address for the printf is EE88 and addresses of other I O routines are listed below Function far main Start of D Bug12 SE getchar
38. it reaches decimal point 21 bne begin do it all over again anda fe force bitO to 0 jmp back d250ms pshx psha daa 250 delay 250 ms staa counter delay1 Idx 6000 6000 x 4 24 000 cycles 1ms delay dex this instruction takes 1 cycle bne delay this instruction takes 3 cycles dec counter bne delay1 not 250ms yet delay again pula pulx rts end 2 Click File button select Save option to save your assembly source file Save your file frequently while editing If you are creating a new file and giving the file a name to save enter the file name including file extension such as Flash_7seg asm not just Flash_7seg 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 Goto 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 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help gt 6 Type LOAD lt Enter gt 7 Click Build button select Download option and locate the file named Flash_7seg s19 for downloading After download is done type G 2000 and hit lt Enter gt key to run the program For your conv
39. le The default option is to associate prj with EmbeddedGNu This is the main project file type used by EmbeddedGNU You also should choose to associate c h and s files with EmbeddedGNU WARNING if you are on WinNT Win2K WinXp then you must be logged in as an administrator to use this option Press OK to continue 5 COM Port Selection It asks if you want to select your COM port Say Yes Select your port in the dropdown box It defaults to 9600 baud which is normally correct Now press OK 6 Select Option gt Environment Options gt AutoDownload then disable ALL automatic commands 7 The current egnu094 zip is properly set up with the newest release version 3 1 GCC 3 3 6 In the future when upgrading to a newer version you have to update the linker s search directory See help file related version upgrade issues 29 Hardware Profile Profile Settings Profle Name Dreg i tsti s C sS MEU type C 68hc11 68hc12 and Oe 2 SRecCyt for 9s12 MPU binload for 9312032 Serial Monitor Startup Code I Vibe baie eet deaminase This option lets you download 12 files using z Karl Lunt s binload program This will perform the COM Port for binload fi download when you press the Download Icon This only works with the 9s12C32 MPU Linker Script Options for Memory Map Linker Seach Directory Ic SusrSlib gcc lib m681 1 elf 3 3 6 m68he1 x 200601 22 mshort Enter Hex numbers here Origin L
40. m COM to COM8 Also set the COM port options at 9600 N 8 1 and check the enable the terminal window box After reset the D Bugi2 monitor defaults baud rate at 9600 and Hyperbaud function is disabled If Hyperbaud function is enabled the Hyperbaud toolbar button sends the BAUD 57600 command to the D Bug12 monitor and then it also changes the serial port to the 57600 baud rate IMPORTANT When you reset your board it will go back to 9600 baud and you will see characters aaaaaaaaaa on the screen You will need to press the Hyperbaud button once to return AsmIDE to 9600 baud and press it again to get 57600 baud To stay at the 57600 baud all the time you need to press the Hyperbaud button twice after every reset The Hyperbaud function is disabled by default and it should only be used by an experienced user not a beginner 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 gt Options gt Terminal Func Keys In the View gt Option gt 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 The screen is divided into two windows The top window is for editing your source code and the bottom window is shared by the message window and the terminal window If the terminal opt
41. n examples After the test asm is loaded into the top window you can view instructions of how to test all hardware on the MiniDragon board 2 Click the Build button to assemble code and generate the test s19 file This is how you normally generate an s19 file You can omit this step because the test s19 is already on your hard disk 3 Press the reset button on the board you will see D Bug12 v4 0 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help gt 4 Type LOAD lt Enter gt 5 Click the Build button Select Download option and locate the file test s19 for downloading If it prompts you with the save changes message you can ignore that message and click the No answer 6 After download is done type G 2000 lt Enter gt to run the test program All sample programs on the CD are developed in RAM You can try to run a different example program later after you have finished reading this manual You should always press the reset button before downloading a new program because the new program may not work if an interrupt was enabled by a previous program All example programs are fully debugged so the assembler won t generate an error If you have an error even a warning error in your program you must correct it before it can generate an s19 file 15 Chapter 3 Software descriptions 3 1 Bootloader and D Bug12 Monitor The MC9S12DG256 on the MiniDragon boa
42. on board 2 USBto TTL adapter 3 USB type B cable 4 110V AC adapter for North America customers If you miss any part of the kit please contact sales EVBplus com or call 630 894 1440 for help Sometime the kit includes two 6 pin IDC connectors at no charge if we have them in stock You may use them to make a BDM cable in the future Please carefully examine the default jumper settings before turning on the board 1 The J7 should have a jumper installed in the up positions so the board will be powered by an external AC adapter 2 TheJ15 should have a jumper in the up position so the speaker will be driven by PT5 The speaker can be driven by timer PT5 or PWM PP5 It defaults for PT5 Without a jumper installed on J15 the speaker won t sound The specification of the AC adapter is DC input 110V DC output 7 5V 9V Current rating 300mA 1A Type of plug 2 1mm female barrier plug center positive The AC adapter is only available to North American customers 1 2 MC9S12DG256 features and memory map The MiniDragon board may come with the MC9S12DP256CCPV 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
43. ot used PT1 Pin 10 not used PT2 Pin 11 not used PT3 Pin 12 not used PT4 Pin 15 not used PT5 output Pin 16 Speaker PT6 output Pin 17 BDMout reset used in POD mode only PT7 Pin 18 BDMout data line bi directional used in POD mode only PADO Pin 67 D bug12 mode select S7 PAD1 Pin 69 D bug12 mode select S7 PAD2 Pin 71 Light sensor PAD3 Pin 73 Pushbutton S2 PAD4 Pin 75 Pushbutton S1 PAD5 Pin 77 Jumper switch S3 PAD6 Pin 79 Jumper switch S4 PAD7 Pin 81 Trimmer pot VR1 PAD8 Pin 68 X axis input for Wytec accelerometer or ADC input for GP12D2 PAD9 Pin 70 Y axis input for Wytec accelerometer or ADC input for GP12D2 PAD10 Pin 72 Z axis input for Wytec accelerometer or ADC input for GP12D2 PAD11 Pin 74 not used PAD12 Pin 76 not used PAD13 Pin 78 not used PAD14 Pin 80 not used PAD15 Pin 82 not used Table 1 2 I O pin usage list 2 11 Chapter 2 Quick Start By default the MiniDragon 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 you prefer to use Code Warrior IDE for C program development and your board is pre installed per your request with the serial monitor Freescale AN2548 pdf skip the chapters 2 and 3 after installing software People often use different terminologies In our product manuals Download means to transfer a file from
44. position then if you press the reset button the small 7 segment LED should display a diagnostic code 5 4 3 momentarily The number 5 means letter S which stands for Serial monitor mode the number 4 stands for single chip mode and the number 3 means that 2 switches S3 S4 are open Here is the code explanation Second number 4 Single chip mode 6 Narrow expended mode 7 Wide expended mode Third number 0 S3 and S4 closed 1 S3 open and S4 closed 2 S3 closed and S4 open 3 S3 and S4 open Chapter 1 Introduction 1 1 Welcome Thank you very much for purchasing the MiniDragon trainer The MiniDragon trainer is a low cost feature packed 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 in universities around the world For engineers it is a convenient prototype system suitable for designers who want to rapidly develop and prototype new HCS12 applications For students it can not only to be used as a general trainer for freshman and sophomore students but also as a powerful platform for senior projects as well The compact size and new features of the MiniDragon board create a new potential for students at every level The MiniDragon trainer kit comes with the following items 1 MiniDrag
45. r the target speed After the correct speed is entered the master will try to communicate with the target board If its not successful enter choice 2 to reset the target board Can t Communicate With Target CPU Set Target Speed 16000 KHz Reset Target Reattempt Communication Erase amp Unsecure di zl VG GA r Enter Target Crystal Frequency kHz 16000 17 Can t Communicate With Target CPU Set Target Speed 16000 KHz Reset Target Reattempt Communication D 2 Erase amp Unsecure zl VG GA At When the communication is established you will see the following sign on message D Bug12 v4 0 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help S gt You will notice that the debug prompt is S gt in the POD mode not just a gt in the EVB mode The S gt tells that this is the POD mode and the MC9S12DG256 on target slave board is stopped Sometimes the prompt could be a R gt that means the target MCU is running If you see the R gt just type reset then lt Enter gt to reset the target and it will come back to the S gt prompt R gt Reset lt Enter gt g gt Note The initial communication in POD mode does not always work smoothly and sometimes the PC screen would only display an incomplete sign on message You need to re start it all over again by pressing reset buttons on both master board and target board then pres
46. rd is pre loaded with bootloader and D Bug12 monitor firmware and it will operate in 4 different modes depending on the setting of the 2 position DIP switch S7 After power up or reset the MC9S12DG256 will read the PADO 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 PDF are the most important documentation They can be found on the folder named C MiniDragon document after software installation The HCS12 instruction set register map and memory map can be found on page 26 65 and 120 of the data book respectively The new D Bug12 V4 x is much different and much larger about 60K than old D Bug12 V2 x The CO00 EFFF are just a part of the monitor In 16 bit S1 record they are COO0O EFFF In 24 bit S2 record they are FC000 FEFFF ppage 3F Since the ppage register deals with the 16K window 8000 BFFF the addresses CO00 FFFF are not affected by the ppage The other part of the monitor is at CO000 C87FF 16K window 8000 BFFF when ppage 30 31 and 32 See details on page 20 of the app note AN2153 or page 71 of the D Bug12 v4 reference guide on the CD 3 1 1 EVB mode PAD1 0 PADO 0 This is the standard debug environment running on the MC9S12DG256 for on chip RAM or EEPROM based code development Using an IDE program to view and modify registers and memory locations you may set breakpoints single step through programs and
47. rogramming BDM POD mode PAD1 1 PADO 0 In this BDM POD mode the D Bug12 firmware acts as a master to access all target MCU resources on the target board another MiniDragon board via the BDM port in a non intrusive manner It becomes a BDM that will have all the features that a standard BDM has in debugging the target MCU Also it gains all the features a programmer has for programming the flash memory of the MCU on the target board another MiniDragon board To use the master board as a programmer you need a 6 pin ribbon cable to connect from the BDM OUT of the master board to the BDM IN of the target board make sure that the orientation of the cable is correct You don t have to provide the power to both boards but only to one board The master board communicates to a PC COM port while the target board does not need to be connected to a PC COM port After booting up in this mode you should see the following message on PC screen Can t Communicate With Target CPU Set Target Speed 48000 KHz Reset Target Reattempt Communication Erase amp Unsecure zl BWN ER 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 fo
48. s the Enter key on PC keyboard You cannot go to the next step until PC screen shows the prompt s gt In order to program the flash memory you have to erase it by using the FBULK command S gt fbulk lt Enter gt S gt When the prompt s gt returns the FBULK command has already erased all of the flash memory contents of the target MC9S12DG256 including the bootloader If it returns with a message Flash or EEPROM Failed To Erase the MC9S12DG256 is defective 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 An s1 record file looks like this S123FFAOF 64CF650F 654F658F65CF660F 664F 668F 66CF670F674F678F67CF680F684F6883D S123FFCOF68CF690F694F 698F 6 9CF 6A0F 6A4F OA8F OACF 6BOF 6B4F 6B8F 6BCF 6COF 6C4F 6C81D S123FFEOF 6CCF 6D0F 6D4F 6D8F 6DCF 6EOF 6E4F 6E8F 6ECF 6F OF 6F AE 6F 8F 6FCF700F704F00009 S9030000FC An s2 record file looks like this S22 40FEFAODB70DB66DB5CDB52DB4 8DB3EDB3 4DB2ADB2 0DB1 6DBOCDB02DAF 8DAEEDAE4DADA41 S22 40FEFCODADODAC 6DABCDAB2DAA8DA9EDA9 4DA8ADA8 0DA7 6DA6CDDD0ODA62DA5 8DA4EDA4 4 94 S22 40FEFEODA02DA0ADA1 2DA1ADA22DA2ADA32DA3AD 9FAD 9F
49. seesneessnsneeessneseeeesessneseeensneneeneseesneneseeseenenneas 20 Making a simple assembly program in RAM sssececseseeeeesseeeenensenseeeenenseeeenenseeentens 21 Software development ssscscecscceesessseesseeceesscesenseseeessseensneeaeenseseeaeseeaseenaveeaeseeeeeenaesenaneas 23 Hardware De SCTriptiOns escsssceccecseeseeseeceeseneneeneeseeeneenueneeneeseeeaeenueneeseesneenaeseeneeseeeeeeeeas 24 Power ED eise seet ee ee 24 Jumper Switches and PUSNDUTHIONS c ceceeeeeeseeeeeenseeeenenseeeeeensenseeeenenseeeenenseeeenenseeneeees 24 Seven Segment LED display ssssscsscccessseseesseeenseseenseenseenseseeesseuaeeeseseeseneenssenanenaeseees 24 TimMer e E 25 Ligh SONSOM E 25 RGB FEEDS 26 SE 26 Dual RS232 COMMUNICATION ports sseseseeeeseeseeeteteneeseeseeeneseneeneneeeneeeeneneneeseeneeeeeanenes 26 A9 LCD display MOdUIe isisi no eoii sanean meinaem aaa eea aa aaae ea eaea pa Ea aa enean eotea aieiaiee 26 GD E 27 4 11 All jumper SETINGS eee eeeeseeeseeseeeeeenseeeeeenseeeeeenseeneeenseeeeeseeeeseeneeenseeeeeenseeeenenseesenensenenseeess 28 Chapter 5 EmbeddedGNu ccssssscssssseessesnensssesnensseeseeeesseuasseeneeaesnesaeeneeesaeeeensseeneenessenassneneeeeansaes 29 Chapter 6 Code Warrior and Serial MONitOl csscsccssesseeesseeeeessseneeneeeeneeseeenenesenseeeenseeeseenanenees 31 Chapter 7 PLL COG eseu EES 33 Chapter 8 Appendiks ro riran scenic cence aeaaea iea aa a
50. t some freeware are not free To download Eric s free tools including the GNU C compiler and assembler please visit his web site at http Avww geocities com englere_geo For your convenience we downloaded the egnu094 zip for you The following page shows the exact terms of the license Mozilla Public License http Awww geocities com englere_geo License txt The steps to set up the EmbeddedGNu are as follows 1 Download the GNU GCC compiler from http m68hc1 1 serveftp org m68hc11_ pkg zip php Select the release 3 1 to download It has the following components in it DC 3 3 6 Gdb 6 4 Binutils 2 15 Newlib 1 12 0 2 Run the file that you downloaded to install GNU 68HC11 68HC12 tools into the default directory of C usr 3 Install the EmbeddedGNU on your PC by double clicking on the egnu094 zip If the egnu094 zip is not on the CD you can download it from http Avww ericengler com EmbeddedGNU aspx Extract all files into a new directory that you need to create on any hard drive The name of the new directory can be like c egnu094 or d egnu094 The EmbeddedGNU exe and example programs will be located at egnu094 but your application programs can be located in any other directories 4 Filename Association When you first start EmbeddedGNU exe it will ask if you want to associate the filename extensions used by EmbeddedGNU with itself This lets you double click on a filename and the EmbeddedGNU will be launched to let you edit the fi
51. the flash memory cannot be programmed If your assembler or compiler cannot generate the even format you must use the Freescale s record conversion utility sreccvt exe to convert your odd format to the even format by using the following command line Sreccvt m c0000 fffff 32 of f0000 o test s29 test s19 23 It will create a new file named test s29 that has the even format and can be programmed into flash memory For your convenience the sreccvt exe is included in the folder named CDROM documeni Sreccvt GUI 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 2 Jumper switches and pushbuttons The two pushbuttons S1 and S2 are connected to AN04 and ANO3 The two jumper switches S3 and S4 are connected to ANO5 and ANO6 S1 gt ANO4 S2 gt ANO3 S3 gt ANOS S4 gt ANO6 That s the way the PC board was laid out the ANO3 and AN04 should be swapped Unfortunately we have to keep the way it is now 4 3 Seven Segment LED The type of the 7 segment LED on the MiniDragon board is called
52. y in LOAD mode and so in order to interface with Code Warrior you have to reset the left switch in the low position It will display the diagnostic code 5 4 3 on the 7 segment LED and the speaker will chirp once when the board is turned on If the serial monitor is not installed or erased by a BDM the LED indicators will not light up one at a time during power up or reset We will add setup procedures for Code Warrior in the future For the time being you can visit some university web sites for more information Instructions of how to download Code Warrior from Freescale s web site http web njit edu paterno ECET310 CodeWarrior pdf http web njit edu paterno ECET310 T3 CodeWarrior 20Simulator pdf CodeWarrior Familiarization amp Project Setup A Guide to Beginning Embedded Assembly and C Programming on the S12 http AWwww aet cup edu jsumey cet360 cwintro cwintro html The most resourceful Code Warrior for the Dragon12 trainer web site http Awww mecheng adelaide edu au roboticswpage php wpage_id 56 Following is the web site for downloading the free Code Warrior special edition http Awww freescale com webapp sps site overview isp nodeld 01272600610BF1 Following is the web site for downloading the Code Warrior full edition for a 30 day free evaluation http Awww freescale com webapp sps site overview isp nodeld 01272600612247 32 Chapter 7 PLL code The crystal frequency on the MiniDragon board
Download Pdf Manuals
Related Search
Related Contents
Fujitsu AMILO Pi 2515 User Guide Sistema HBI Split Inverter + Ahorros + confort + Bienestar ARCOPT-05D07 - Arcus Elektronika Albrecht_AE77H VHF-UHF Scanner_Manual Zanussi ZCG 8021 Owner's Manual プログラムバイク6ー ー4 警告・離主意事項 Télécharger - SNUipp Service manual: Washing machine Type: WM70 ACTIVA 500 Copyright © All rights reserved.
Failed to retrieve file