Home

Microcontroller board

image

Contents

1. 17 3 1 4 Bootloader mode eere 19 Making a simple assembly program in RAM rennen 20 Software development 22 Hardware Descriptions neuen eene 22 azsudhcugciBe 23 Dual SCI communication ports eere iei esses te natn tn annnm natant tn tnn 23 LIBI E 23 Embedded GNU me D 24 Code Warrior and serial 24 PLE COC DDR 25 Chapter 8 210 927174 26 81 012 utility 26 8 2 Interrupt vector 27 8 3 Useful web links aree eeenenenn nennen nnnm nnne tnam ttam tnn annann annman anaana 30 Chap
2. 2 OC gt 2 gt gt gt 85882000 SSTPWN3 KWP3 PP3 VRH SCKVPWM2IKWP2IPP2 O VDDA MOSIV PWMI KWP1 PP1 PADO7 ANO7 ETRIGO MISOTIPWMO KWPO PPO 6 IOCO PTO PADOS ANOS IOCT PTI PADO4 ANO4 IOC2 PT2 PADO3 ANO3 IOC3 PT3 PADO2 ANO2 VDD1 PADOT ANO1 VSS1 MC9S12D Family PADOO ANOO IOCA PTA 80 QFP VSS2 5 5 VDD2 IOCG PTG PATIADDR15 DATA15 14 14 PAS ADDR13 DATA13 ADDRO DATAO PBO PA4 ADDR12 DATA12 ADDR1 DATA1 PB1 PA3 ADDR11 DATA11 ADDR2 DATA2 PB2 PA2 ADDR10 DATA10 ADDR3 DATA3 PB3 PAT ADDR9IDATAQ ADDR4 DATA4 PB4 C 20 PAO ADDR8 DATA8 RARARSRRASSESBSSSESRBSSS BO o LJ LE MONK O oU 6 49 8 eles lt go i e cc lt lt lt 922 4 Fig 1 3 MC9S12DG256CFUE MCU pin assignments 1 3 On board hardware features e Four LED indicators connected to PBO PB3 e Dual SCI headers e Power On LED indicator e Reset switch e Abort switch for stopping program when program is hung in a dead loop Besides the on chip 256K flash 12K RAM and 4K EEPROM the 9512 MCU MC9S12DG256CFUE also includes the following on chip peripherals 3SPl
3. Reserved Fig 8 3 MC9S12DG256 Interrupt vector table 2 Secondary Secondary Interrupt Source Vector Interrupt Source Vector Address Address Reserved FF80 EF80 EFCO SEFOA SEFCC SEFOO SEFD2 SEFDS SEFDB SEFDA SEFDC SEFEO SEFE2 SEFE SEFES SEFEA SEFEC Real time interrupt EFFO MSCAN 0 receive EFB 8 Unimplemented instruction trap EFF8 SEFFA Clock monitor fail reset SEFFE Fig 8 4 MC9S12DG256 secondary interrupt vector table 28 8 3 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 Freescale forum http forums freescale com freescale and the HC12 user group http groups yahoo com group 68HC12 are good places 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 68 11 hc12 68hc12 9512 512 sites html to get links to many university web sites that offer course materials and lab assignments for the Dragon12 and ThunderBird12 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 BD
4. 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 File 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 make port B as a binary counter when it s running The RAM byte named counter is added for demonstrating how 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 lds instruction in the first line of your code 19 include reg9s12 h REGBLK equ 0000 STACK equ 2000 org 1000 count
5. VOD1 2 VSS1 2 PLL 2 5V VDDPLL VSSPLL E Voltage Regulator 5V 4 VO VODR VSSR E VRH A VRL i e VDDA PADO08 09 PAD10 4 PAD11 PAD12 4 PAD13 PAD14 PAD15 1 XADDR15 PK2 16 XADDR17 PK4 18 PKS 1 XADDR19 1 5 v xz mi D gt PT PT2 PT3 4 PTS PT6 PT7 PSO lt PS1 pS PS3 Enhanced Capture Timer PTT DORT PTS BDLC AXB 71850 RXCAN TXCAN PMO 1 PM2 PW PMS PMG PM 2 Module to Port Routing gt PJG e PPI PP2 PPS 4 PPS PPT PHO PHT 2 PHS PHS PH6 PH Signals shown in Bold are not available on the 80 Pin Package DDRJ PTJ DDRP PTP DORH PTH 11111131 111113111 1111 Fig 1 2 MC9S12DG256 MCU block diagram no ox 2 2 25 lt lt 8 55985 969 ssssaa 229 222228 EC 2052959555 gt lt gt lt 25 5 gt lt lt ELELESS 832235424 For Rm mum 0 5 2 2 52858
6. MHz bus speed via on chip Phase Lock Loop BDM for in circuit programming and debugging 80 pin LQFP package 0000 0400 1000 4000 8000 6000 FF00 VECTORS VECTORS SFFFF EXPANDED NORMAL SPECIAL SINGLE CHIP SINGLE CHIP Assuming that a 0 was driven onto port 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 ogi Module Clock and Reset Generation Module CPU12 System Integration Module SIM PTE 1111111 i 1111111 Multiplexed Address Data Bus 1111111 DDRA PTB 4 gt PBI ADDR15 ADDR14 PAG e ADDR 3 PAS e ADDR12 4 oe ADDR11 ADDR10 ADDRS PA ADDR8 PAO ADDR ADDR6 6 ADDR5 PBS ADDR4 PB4 ADDR3 PBS ADDR2 PB2 ADDRO ADDR1 DATA15 DATA14 DATA13 DATA12 DATA11 DATA10 DATAS DATAS VO Driver 5V VDDX VSSX Converter 5 4 Voltage Regulator Reference VSSA Intemal Logic 2 5V
7. a character from SCIO or SCI Send a character out SCIO SCI1 printf Formatted Output Tra 8 binary values to characters far GetCmdLine Obtain a line of input from user i Checks for membership in the set 0 9 a f A F Converts lower case characters to upper case Istrlen 0 Returns the length of a null terminated string strepy _ Copies a null terminated string gt EN Displays 8 bit number as 2 ASCII hex characters far out4hex Displays 16 bit number as 4 ASCII hex characters SetUserVector Setup user interrupt service routine _ s far WriteEEByte Write a data byte to on chip 0 0 far EraseEE _ far ReadMem data from the M68HC12 memory far WriteMem Write data to the M68HC12 memory Fig 8 1 D Bug12 utility routines 25 8 2 Interrupt vector table Table 5 1 Interrupt Vector Locations Vector Address Interrupt Source FFFE FFFF Reset FFFC FFFD Clock Monitor fail reset 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 channel 1 FFEA FFEB Enhanced Capture Timer channel 2 HPRIO Value Local Enable t
8. can rename it to ThunderBird12 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 Wytec ThunderBird12 If you want to make shortcut for AsmIDE on the Desktop this is the correct way to do it If you don t 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 ThunderBird12 board is created in a text file named cWytecThunderBird12VAsmIDE ini In the future if you get lost with all the changes you always can copy this file into the folder c Wytec ThunderBird12 11 2 2 Getting Started To operate the ThunderBird12 module follow steps1 through 5 below 1 The module does not have a built in 5V regulator so it must be supplied with a regulated 5V voltage source If you bought it with a RoadRunner module or a USB to TTL adapter UTA the ThunderBird12 module will be supplied with 5V from a USB port in your PC through these two devices If you supply your own 5V power supply for the module make sure that the Pin 60 is the VCC 5V and the pin 59 is the ground After power up the states of the 2 position DIP switch S2 are tested by the bootloader for selecting one of 4 operating modes during power up or reset and the four LED indicators will blink one at a time from left to right to indicate that the bootloader is functioning Then one of th
9. file from 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 from CD The installation is automated by double clicking on the SETUP BAT in the CD It will create a folder c Wytec ThunderBird12 examples and copy all example program files from the CD to c Wytec ThunderBird1 2 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 Wytec ThunderBird1 2 not c Windows desktop or other locations First right click the Start button then left click Explorer left click CA Wytec ThunderBird12 right click on AsmIDE exe an application program left click Send to and finally left click Desktop do not click It will create an icon named shortcut to AsmIDE on the desktop and you
10. software breakpoints and single step in the EEPROM in EVB mode so it makes sense to do development work in the RAM When your code 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 S2 for EVB mode and 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 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
11. 1 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 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 the original interrupt vector addresses are taken by bootloader the bootloader and D Bug12 monitor will map all 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 Bugl12 v4 0 0b32 Copyright 1996 2007 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 the EVB mode LED will go off after power up You can use bootloader to re program D Bug12 monitor into flash memory 15 3 1 2 3 1 3 Jump to EEPROM mode 1 0 PADO 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 The bus
12. 4 RESET 8 PP5 KWP5 PWM5 MOSI2 53 PJ6 KWJ6 RXCAN4 SDA 9 PP4 KWP4 PWM4 MISO2 52 PJ7 KWJ7 TXCAN4 SCL 10 PP3 KWP3 PWM3 SS1 51 11 PP2 KWP2 PWM2 SCK1 50 PADO7 AN7 12 PP1 KWP1 PWM1 MOSI1 49 PADO6 AN6 13 PPO KWPO PWMO MISO1 48 PADO5 AN5 14 PTO IOCO 47 04 4 15 PT1 IOC1 46 PADOS3 AN3 16 PT2 IOC2 45 PADO2 AN2 17 BKGD 44 XTAL or PEO XIRQ 18 43 19 4 4 42 20 PT5 IOC5 41 21 PT6 IOC6 40 PA4 22 PT7 IOC7 39 23 PB7 38 PA2 24 PB6 37 25 PB5 36 PAO 26 PB4 35 PE1 IRQ 27 PB3 34 PE2 28 PB2 33 29 1 32 PE4 Pin Name MCU Pin Usage PAO Pin 41 not used PA1 Pin 42 not used PA2 Pin 43 not used Pin 44 not used PA4 Pin 45 not used 46 not used PA6 Pin 47 not used 48 not used PBO Pin 16 LED indicator PB1 Pin 17 LED indicator PB2 Pin 18 LED indicator Pin 19 LED indicator PB4 Pin 20 not used PB5 Pin 21 not used PB6 Pin 22 not used PB7 Pin 23 not used PEO Pin 40 Abort switch S3 input PE1 Pin 39 not used PE2 Pin 38 not used PE3 Pin 37 not used PE4 Pin 27 not used PE5 Pin 26 not used PE6 Pin 25 not used PE7 Pin 24 not used PJ6 Pin 69 not used PJ7 Pin 68 not used Table 1 1 I O pin usage list 1 Pin Name MCU Pin Usage PMO Pin 75 not used PM1 Pin 74 not used PM2 Pin 73 not used PM3 Pin 72 not used PM4 Pin 71 not used PM5 Pin 70 not used PPO Pin 4 not us
13. M to debug a 12 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 29
14. T LOCKIE C6 FFC4 FFC5 CRG Self Clock Mode Hit CRGINT SCME C4 FFC2 FFC3 BDLC TIE ee C2 FFCO FFC1 1 Bus Bit IBCR IBIE CO SFFBE SFFBF SPICRT SPIE SPTIE FFBC FFBD I Bit SP2CR1 SPIE SPTIE BC FFBA FFBB EEPROM I Bit FFB8 FFB9 HBit FCTL CCIE CBEIE 88 FFB7 CANO wake up CANORIER WUPIE B6 FFB4 SFFB5 CANO errors I Bit CANORIER CSCIE OVRIE B4 FFB2 FFB3 CANO receive HBit CANORIER RXFIE B2 FFBO FFB1 CANO transmit HBit CANOTIER TXEIE2 TXEIEO BO FFAE FFAF wake up I Bit WUPIE SAE errors CANTRIER CSCIE OVRIE AC SFFAA SFFAB tet CANIRIER RXFIE SAA CANT transmi 2 CAN2RIER WUPIE A6 CAN2 errors 2 CSCIE OVRIE A4 FFA2 FFA3 2 receive CAN2RIER RXFIE A2 transmit 2 TXEIE2 TXEIEO A0 wake up CAN3RIER WUPIE 9E errors I Bit CAN3RIER TXEIE2 TXEIEO 9C receive Bit CANGRIER RXFIE 9A CANG transmit I Bit CAN3TIER TXEIE2 TXEIEO 98 8 95 5 7 CANE wakeup Bt CANARIER 96 4 CANieros CANARIER CSCIE OVRIE 94 receive I Bit CAN4RIER RXFIE transmit I Bit CAN4TIER TXEIE2 TXEIEO SFe PorPiMemup TBI PTPIF PTPIE strec SFFBD PWM Emergency Shutdown PWMSON
15. The test program must be run from RAM in EVB mode In order to run the test program in EVB mode both the DIP switches of S2 must be set in low positions The steps to run your first test program are as follows 1 6 Click the File button to open the Binary counter asm from c Wytec ThunderBird1 2 examples After the Binary counter asm is loaded into the top window click the Build button to assemble code and generate the Binary counts19 file This is how you normally generate an s19 file You can omit this step because the Binary counter s19 is already on your hard disk Press the reset button on the board you will see D Bugl12 v4 0 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help gt LOAD lt gt Click the Build button Select Download option and locate the file counter s19 for downloading If it prompts you with the save changes message you can ignore that message and click the No answer After download is done type G 2000 Enter to run the test program 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 The test program is 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 Note The startin
16. ThunderBird12 Module The Freescale MC9S12DG256 based microcontroller module User s Manual Revision 1 00 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 Chapter 5 Chapter 6 Chapter 7 Viet PEE DE Ctm 4 WOICOMG mMeD 4 MC9S12DG256 features and memory 5 On board hardware features 9 occ 9 Quick Starta TD 12 Install software from CD 12 Getting Started LIED 13 IL irr c 15 Software 16 Bootloader and D BUG12 16 3 11 EVB uidere dd deceat ases 16 3 1 2 Jump to EEPROM Mode eerie 17 3 1 3 BDM POD Mode tinae
17. 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 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 0000 32 of f0000 o test s29 test s19 It will create a new file named test s29 that has the even format and can be programmed into flash memory 21 Chapter 4 Hardware Descriptions The crystal frequency is 8 MHz and usually it will result in a 4MHz 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 41 LED indicators The power on indicator LED will always be lit when the 5V is present to the module 4 other LED indicators are connected to PBO PB3 4 2 Dual SCI communication ports Both SCI connectors are configured as DCE devices and they can be directly connected to the PC s COM ports The 4 pin male header J1 is connected to the SCIO of the DG256 while the J4 is connected to the SC1 of the DG256 The D Bug12 monitor or serial monitor works with SCIO so the UTA board should connect the SCIO to a PC s USB port during debugging sessions The can be us
18. arting address field An 1 file looks like this S123FFAOF 64CF650F 654F658F 65CF660F 664F 668F 66CF670F674F678F67CF680F 684F6883D S123FFCOF68CF690F 694F 6 98F 6 9CF 6A0F 6A4F OACF 6BOF 6B4F 6B8F 6BCF 6COF 6C4F 6C81D S123FFEOF 6CCF 6DO0F 6D4F 6D8F 6DCF 6EOF 6E4F 6ECF 6F OF OF 4F 6F 8F 6FCF 700 704 00009 S9030000FC An s2 record file looks like this S22 40FEFAODB70DB66DB5CDB52DB4 8DB3EDB3 4DB2ADB2 0DB1 6DBOCDB0 2DAF 8DAEEDAE4DADA41 S22 40FEFCODADODAC 6DABCDAB2DAA8DA9EDA9 4DA8ADA8 0DA7 6DA6CDDDODA62DA5 8DA4EDA4 4 94 S2240FEFEO0DAO2DA0ADA12DA1ADA22DA2ADA32DA3AD9FAD9F2D9AFD98AD9D5EFOOEFOOEF0039 S9030000FC 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 ThunderBird12 bootloader is modified from the Freescale 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 0000 fffff 32 of 0000 o Bo
19. ed PP1 Pin 3 not used PP2 Pin 2 not used PP3 Pin 1 not used PP4 Pin 80 not used PP5 Pin 79 not used PP7 Pin 78 not used PSO Pin 63 SCIO for PC communication RECV PS1 Pin 64 SCIO PC communication XMIT PS2 Pin 65 SCI1 for user applications not used PS3 Pin 66 for user applications XMIT not used PTO Pin 5 not used PT1 Pin 6 not used PT2 Pin 7 not used Pin 8 not used PT4 Pin 11 not used PT5 Pin 12 not used PT6 Pin 13 BDMout reset output used in POD mode only PT7 Pin 14 BDMout data line bi directional used in POD mode only PADO Pin 51 D bug12 mode select DIP switch S2 PAD1 Pin 52 D bug12 or Serial Monitor mode select DIP switch S2 PAD2 Pin 53 not used PAD3 Pin 54 not used PAD4 Pin 55 not used PAD5 Pin 56 not used PAD6 Pin 57 not used PAD7 Pin 58 not used Table 1 2 I O pin usage list 2 10 Chapter 2 Quick Start By default the ThunderBird12 board is pre installed with the bootloader Freescale AN2153 pdf and the D Bug12 monitor Freescale DB12RG4 pdf In chapters 2 and 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 from CD People often use different terminologies In our product manuals Download means to transfer a
20. ed by user s application programs 4 3 All jumpers All on board jumpers J1 TTL port for SCIO may be connected to a Wytec s UTA board J2 BDM in J3 BDM output in POD mode J4 TTL port for may be connected to a Wytec s UTA board J5 Selects Crystal Osc frequency output or PEO XIRQ for pin 44 located at the solder side J6 Selects 5V or 2 5V for VRH pin 51 defaults to 5V located at the solder side J7 RS of CANO U3 is connected to VSS located at the solder side J8 Connects PMO to RXD of CANO located at the solder side J9 Connection of the terminating resistor for CANO Place a jumper on this header on the last note in a network only if you use CANO It will save power consumption of the module without the jumper if CANO is not used Located at the solder side CAN 22 Chapter 5 EmbeddedGNU See installation instructions at http hes1 2text com links html Chapter 6 Code Warrior 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
21. ed is 4 MHz In order to set the bus speed high than 4 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 8 MHz on ThunderBird12 board intSYNR 5 PLL multiplier will be 6 intREFDV 1 PLL divisor will be 2 PLLCLK 8 2 6 2 48MHz The bus speed PLLCLK 2 24 MHz PLL code for 24MHz bus speed from a 4 8 16 crystal sei Idx belr bset Idaa staa Idaa staa wait b3 brclr bset 0 clksel x 10000000 clear bit 7 clock derived from oscclk plictl x 01000000 Turn PLL on bit 6 1 PLL on bit 6 0 PLL off 05 5 1 6 multiplier 03 divisor 3 1 4 16 2 6 4 48MHz PLL freq for 16 MHz crystal 01 divisor 1 1 2 8 2 6 2 48MHz PLL freq for 8 MHz crystal 00 divisor 0 1 1 4 2 6 1 48MHz PLL freq for 4 MHz crystal refdv x crgflg x 00001000 wait_b3 Wait until bit 3 1 clksel x 10000000 24 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 StartofD Bugl2 BE getchar 22 _ Get
22. eed 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 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 co
23. em will be lit to indicate the selected operating mode and other three will be turned off If you have a small speaker you can connect the positive terminal of the speaker to PT5 via a 2 2uf 10uf capacitor and the negative terminal to ground The speaker would chirp once during power up The 4 operating modes tested by the bootloader are EVB Jump to EE BDM POD and Bootloader If it does not occur check the Power On LED indicator It is lit when VCC 5V is present If the POWER LED is off check VCC and Ground connection and USB cable connection To invoke the AsmIDE you can right click the Start button then left click Explorer left click on CAWyteo ThunderBird12 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 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 19 file to the ThunderBird12 board 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
24. er rmb 1 org 2000 program code start 195 STACK Idx REGBLK staa ddrb x an output port clr portb x turn off all LEDs back inc portb x turn on LEDs jsr d250ms delay 250ms jmp back d250ms psha 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 Binary_counter asm not just Binary 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 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 Bugl12 v4 0 0b32 Copyright 1996 2007 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 Binary_coun
25. g address happens to be assigned at 2000 in the test program It can be at any location in RAM 14 Chapter 3 Software descriptions 3 1 Bootloader and D Bug12 Monitor The MC9S12DG256 on the ThunderBird12 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 2 position DIP switch S2 After power up or reset the MC9S12DG256 will test the states of PADO and 1 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 in the folder named C Wytec ThunderBird1 2 document after software installation The 12 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 000 are just a part of the monitor In 16 bit 51 record they are CO00 EFFF In 24 bit S2 record they are 00 ppage 3F Since the ppage register deals with the 16K window 8000 BFFF the addresses C000 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 PAD
26. 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 gt just type reset then Enter to reset the target and it will come back to the S gt prompt R Reset Enter S 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 host board and target board and then press 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 fbulk Enter S 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 16 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 s2 record uses 24 bit st
27. kkkkkkkkkkkkkkkkkkkkkkkkkk 17 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkk kkk kkk kkk kkk kk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 5 gt With the bootloader and the D Bug12 programmed the flash memory the target board now becomes a true development board That s how we program the board before we ship it Your ThunderBird12 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 ThunderBird 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 Bug12 monitor firmware was not in flash memory anymore For your convenience we include a PLL code template in chapter 7 If you n
28. nvert 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 18 Note Quite 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 flash 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_ThunderBird_8MHz s29 located the folder named D Bug12 Monitor for downloading You should see the following on the screen kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkk kk k kkk k k k k kk kk k kkk kk kk kk kk k kkk kk kk kk kkk kkk kk kk kk kkk kkk kkk kkk kkk kkk kkk kkk kkk kk k kkk kk k kkk kk kk kk kk k kkk kk kk kk kkk kkk kk kk kk kkk kkk kkk kkk kkk kkkkkkkkkkk kkk kkk kkk kkk kkk kk k kkk kk kk kk kk k kkk kk kk kk kkk kkk kk kk kk kkk kkk kkk kkk 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
29. o Elevate PLLCTL CME SCME COP rate select None CRGINT TIE 11 TIE TIE 41 pre pem E X Bit None s E8 FFE8 FFE9 Enhanced Capture Timer channel 3 I Bit FFE6 FFE7 Enhanced Capture Timer channel 4 I Bit SEFE SEFES Enhanced Capture Timer channel S TIE C5 5 2 SFFES Enhanced Capture Timer channel Bit TIE FFEO FFE1 Enhanced Capture Timer channel 7 FBit TIE C71 FFDF Enhanced Capture Timer overflow I Bit TSRC2 TOF FFDC FFDD Pulse accumulator A overflow Bit PACTL PAOVI 06 FFDB Pulse accumulator input edge HBit PACTL PAI DA FFD9 SPIO SPOCR1 SPIE SPTIE D8 SCOCR2 FFD6 FFD7 SCIO TIE TCIE RIE ILIE D6 FFD4 FFD5 sci TIE ILIE D4 ATDO I Bit ATDOCTL2 ASCIE D2 ATD1 ATD1CTL2 ASCIE 00 Port J Bit PTJIE CE Port H PTHIF PTHIE CC Modulus Down Counter underflow 1 MCCTL MCZI CA Fig 8 2 MC9S12DG256 Interrupt vector table 1 26 FFC8 FFC9 Pulse Accumulator B Overflow I Bit PBCTL PBOVI C8 FFC6 FFC7 CRGPLLiock CRGIN
30. ot ThunderBird s29 Boot ThunderBird s19 Now we type FLOAD Enter at the prompt Click the Build button select the Download option and select the file named Boot ThunderBird 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 fload Enter kkk kkk dede eek kk kkk ehe eee eek ede ee kkkkkkkkkkkkkkkkkkkkkkk S Now we are going to program the D Bug12 monitor into the flash memory We need to type FLOAD Enter at the prompt Click the Build button select the Download option and select the file named DBug12v32 DR12P 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 fload Enter kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkk kk kkk kkk kk kk kkk kk kk kk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
31. rminal 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 options are set correctly you should see the following prompt every time the reset button on the ThunderBird12 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 Enter key and it will enable the terminal window D Bugl12 v4 0 0b32 Copyright 1996 2007 Freescale Semiconductor For Commands type Help gt 13 2 3 Test Hardware To help users get up and running the ThunderBird12 board comes with a simple ready to run test program including source code
32. s 2SCls o 2CANs interface o 8 16 bit timers 7PWMs o 6 channel 10 bit A D converter e Super fast bus speed up to 25 MHz e The 80 Pins 9812 MCU MC9S12DG256CFUE is included 55 pins are available to user applications connector to be connected with a from multiple vendors for debugging BDM out connector for making this board as a HCS12 9812 or programmer No extra hardware needed Comes with AsmIDE under GPL general public license e Pre loaded with D Bug12 monitor for working with AsmIDE and EmbeddedGNU e Or pre loaded with serial monitor for working with Code Warrior e Supports source level debugging in C and Assembler without a e Mode switch for selecting 4 operating modes with LED indicators in D Bug12 monitor Jump to EEPROM POD and Bootloader e Auto start user programs with visual verification when the board is turned on e Combined with a RoadRunner stick for fast prototyping on a user provided solderless breadboard e Hardware is compatible to the Dragon12 Plus board e Provided with a sample program including assembly source code PC board size 3 05 X 0 88 1 4 Pin Usage Pinouts of the 60 DP module 1 PM5 TXCANO TXCAN4 SCKO 60 VCC 2 PM4 RXCANO RTXCAN4 MOSIO 59 GND 3 PM3 TXCAN1 TXCANO SSO 58 PS1 TXDO 4 PM2 RXCAN1 RXCANO MISOO 57 PSO RXDO 5 PM1 TXCANO TXB 56 PS3 TXD1 6 PMO RXCANO RXB 55 PS2 RXD1 7 PP7 KWP7 PWM7 SCK2 5
33. 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 from EEPROM the procedure is available in the folder named eeprom programming BDM POD mode PAD1 1 PADO 0 In this BDM POD mode the D Bug12 firmware acts as a host to access all target MCU resources on the target board another HCS12 9512 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 HCS12 9812 board To use the host board as a programmer you need a 6 pin ribbon cable to connect from the BDM OUT of the host 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 host 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 will see the following sign on message D Bugl12 4 0 0532 Copyright 1996 2007 Freescale Semiconductor For Commands type Help 5 gt You will notice that the debug prompt is S gt in the POD mode just a gt
34. ter 1 Introduction 1 1 1 2 Welcome Thank you very much for purchasing the ThunderBird12 module The ThunderBird12 module is a low cost full featured STAMP type microcontroller module based on the powerful 16 bit Freescale MC9S12DG256 microcontroller If you have any questions please contact sales EVBplus com or call 630 894 1440 for help MC9S12DG256 features and memory map The ThunderBird12 board comes with the MC9S12DG256CFUE 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 DP256 has 5 CAN ports and one BDLC port but the DG256 has only 2 CAN ports and BDLC port otherwise these two microcontrollers have the same features If you don t use more than 2 CAN ports and don t need the BDLC communication 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 MC9S12DG256CFUE 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 7 ch 8 bit or 3 ch 16 bit PWM 8 channel 10 bit A D converter Fast 25
35. ter s19 for downloading After download is done type G 2000 and hit Enter key to run the program For your convenience we have included this sample program Binary counter asm on the CD 20 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 the original interrupt vector addresses are taken by the bootloader The bootloader and D Bug12 monitor will map 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 in the 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
36. 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 See details at the following link http Awww evbplus com usb232 html 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 from COM1 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 Bug12 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 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 12 10 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 te
37. tudents 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 program 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 module is pre loaded with SM Serial Monitor When the module is installed with serial monitor the state of the left switch of the 2 position DIP switch S2 is tested by the serial monitor for selecting RUN or LOAD mode during power up or reset and the four LED indicators will blink one at a time from right to left to indicate that the serial monitor is functioning If the left switch is placed in LOAD mode the monitor will wait for a command from PC If the left switch is placed in RUN mode the LEDs will sweep back from left to right to indicate that the program execution is diverted to the user code If the PT5 is connected to a speaker the speaker will chirp once when the board is turned on The setup procedures for Code Warrior are available from some university web sites and their links are provided at web site http www evbplus com Code Warrior hcs12 html Chapter 7 PLL code start The crystal frequency on the ThunderBird12 board is 8 MHz so the default bus spe
38. 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 thing 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 Robot trainer board like the ThunderBird12 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 ThunderBird12 MODULE as a BDM POD to program all s

Download Pdf Manuals

image

Related Search

Related Contents

PSU-1300ATX-12N User`s Manual PSU-1300ATX  

Copyright © All rights reserved.
Failed to retrieve file