Home

Dragon12 manual - Sinclair Community College

image

Contents

1. Our Dragon12 Plus2 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 off0000 o Boot_DR12_8MHz s29 Boot_DR12_8MHz 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_DR12P_8MHz 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 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 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 Click the Build button select the Download option and select the file named DBug12v32_DR12P_8MHz 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 kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkk
2. 4 12 RS485 communication port U5 SN75176 converts the TTL signal from SCI1 to RS485 differential signals and vice versa PJO pin 22 of the MC9S12DG256 is used to control the direction of RS485 communication If PJO 0 the RS485 port U5 DS75176 is set as a receiver port If PJO 1 the RS485 port US DS75176 is set as a transmitter port 4 13 External SPI interface SPI port J10 pinouts are as follows SPI port J10 pinouts are as follows Pin 1 MISO PS4 Pin2 VCC 5V Pin 3 SPSLK PS6 Pin4 MOSI PS5 Pin 5 ISS PS7 Pin6 VSS GND 4 14 External UC interface I2C port J2 pinouts are as follows Pin 1 VCC 5V Pin2 IRQ Pin 3 PJ7 SCL Pin4 PJ6 SDA Pin 5 VSS GND 4 15 RGB LED Common Anode The anode is enabled by PM2 RED COMMON PP4 O O0 ANODE PM2 GREEN IO BO BLUE PP6 PPS The PP4 PPS and PP6 control Red Blue and Green LEDs respectively 4 16 All jumper settings All on board jumpers J1 J2 J13 J16 J20 J21 J23 J25 Enables LCD backlight IC interface Two channel 10 bit DAC outputs The output A is also available between PJ6 of H8 and PJ7 of H7 The output B is also available between GND of H1 and PT4 of H2 R W of LCD module It s hardwired for write only Located on solder side PP4 PWM output for a servo the servo connector must be installed horizontally PPS PWM output for a servo the servo connector must be installed horizontally PP6 PWM output for a servo the s
3. Dragon1 2 Plus2 Trainer For Freescale HCS12 microcontroller family User s Manual for Rev A board Version 1 01 A SFYC CITT Table OF Contents Chapter 1 Introduction andann nk na a nadi has gs 4 1 1 Welcome u saa 4 1 2 MC9S12DG256 features and memory map 5 1 3 On board hardware features I U U U U U uuu Q Q 8 14 HQ E uuu ua lassana ewaq waqasa aswaa EAEAN AAVA EA ARA o iE asas ws 9 Chapter 2 QUICK Start ics cic u A Naa etches au A Anna Aaaa 12 KA WWW EE 12 2 2 Getting Started rns asus sa SAREk 12 23 Test E TC 14 Chapter 3 Software Description I U u 15 3 1 Bootloader and D BUG12 monitor U U uu uuu 15 BAA EVB Mode EE 15 3 1 2 Jump to EEPROM mod e U L u 16 3 1 3 BDM POD Mode sr 16 3 1 4 Bootloader mode U U U u uu 20 3 2 Making a simple assembly program in RAN 1 u 21 33 Software d evelopment ul U U Isa sassa ss ssassassassas REENEN 23 Chapter 4 Hardware Descriptions Ill U u 24 li EDS GS hasa kassa ri anal a aus au A 24 42 DIP switch and pushbuttons 0000000eee sneru 24 43 7 Segment LED multiplexing
4. gt PPS VSSPLL Kb VSSA PPT PHO PHI Voltage Regulator 5V amp LO Be VDDR a S VSSR ime 4 K Lee PHS it PHS PH6 res PH Fig 1 2 MC9S12DG256 MCU block diagram RO 3 2 22 oO s GEES N Cl On s So a 272288 z Se E aa SSS5zFz Ss SES 2ESELESS ee Ste SS SC z 2 s a SSSSSSSSzeSsSsssas TEEPEE EFH EEP FREER O 2 Z Z Z S E 5 2 2 2 S E eee S 2 2 Z gt gt 2 2 2 2 LRR E 2 PO TU EEN SSTPWM3KWP3IPP3 8 FE 8 SS SE ss a VRH SCKIPNMAKWPIPP2 2 O VDDA MOSI1 PWM1 KWP1 PP1 C 3 PAD15 AN15 ETRIG1 MISO1 PWMO KWPO PPO C 4 PADO7 ANO7 ETRIGO XADDR17 PK3 L 5 PAD14JAN14 XADDR16 PK2 C 6 PADOG ANO6 XADDR15IPK1 C 7 PAD13 AN13 XADDR14 PKO C 8 PADOS AN05 IOC0 PT0 PAD12 AN12 lOC1 PT1 PADO4 ANO4 IOC2 PT2 PAD11 AN11 10C3 PT3 PADO3 ANO3 vod c PAD O AN10 vssi MC9S12DP256B MC9S12DT256 PADO2 ANO2 IOC4IPT4 IMC9S12DJ256 MC9S12DG256 PADO9 ANO9 IOC5IPT5 C PADO ANO1 jOC6 PT6 C PADO8 ANO8 JOCTIPTT C PADOO ANOO XADDR19 PK5 vss2 XADDR18 PK4 C 20 vo 2 KWJ4 PJ4 PA7 ADDR15 DATA15 KWJO PJO Co 22 PAB ADDR14 DATA14 MODC TAGHIIBKGD C 23 PAS ADDR13 DATA13 ADDRO DATAO PBO PA4 ADDR1 2 DATA12 ADDR1 DATA1 PB1 C 25 PA3 ADDR11 DATA11 ADDR2 DATA2 PB2 C 26 BOCH PAZ ADDR10 DATA10 ADDR3 DATA3 PB3 C 27 PA1 ADDR9 DATA9 ADDR4 DATA4 PB4 J 28 a eet ee PA0 ADDR8IDATA8 N CH et lt et O UU A YPP EI ZEE gnon z a a amp 2 2 5 x
5. 3 Reattempt Communication 4 Erase amp Unsecure 22 When the communication is established you will see the following 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 S 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 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 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 pro
6. 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 emulation programs The state of the left switch of the 2 position DIP switch SW7 is tested by the serial monitor for selecting RUN or LOAD mode during power up or reset and the 8 port B LED indicators will light up from right to left and the speaker will chirp once to indicate that the serial monitor is functioning If the left switch is placed in the LOAD mode the lower position the monitor will wait for a command from a PC If the left switch is placed in the RUN mode the upper position the port B LED indicators will light up again from left to right to indicate that the program execution is diverted to the user code the factory test program The left DIP switch of SW7 has been set in the up position as a factory default setting for running the test program The CodeWarrior communicates with Freescale serial monitor only in LOAD mode and so in order to interface with the CodeWarrior you have to place the left switch in the low position The port B LED indicators will light up from right to left and the speaker will chirp once when the board is powered up If your board does not communicate with CodeWarrior the first thing you should check is that if the left DIP switch of the SW7 is in the LOAD mode in the low position Chapter 1 Introduction 1 1 Welcom
7. PP6 output Pin 110 Servo motor 3 or RGB LED PP7 output Pin 109 Servo motor 4 Pin 89 SCI0 for PC communication RECH DB9 connector P1 Pin 90 SCI0 for PC communication SMIT DB9 connector P1 Pin 91 SCI1 for user applications RECH selected by J23 Pin 92 SCI1 for user applications SMIT Pin 93 MISO for LTC1661 MicroSD memory and external SPI J10 Pin 94 MOSI for LTC1661 MicroSD memory and external SPI J10 Pin 95 SCLK for LTC1661 MicroSD memory and external SPI J10 Pin 96 SS for external SPI J10 or nRF24L01 or Arduino header Pin 9 not used Pin 10 not used Pin 11 not used PT3 input Pin 12 IR detector PT4 output Pin 15 Capacitive touch switch PTS output Pin 16 Speaker output 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 SW7 PAD1 Pin 69 D bug12 mode select SW7 PAD2 Pin 71 not used PAD3 Pin 73 not used PAD4 Pin 75 Light sensor phototransistor Q1 PAD5 Pin 77 Temperature sensor U14 LM45 PAD6 Pin 79 not used PAD7 Pin 81 Trimmer pot VR2 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 u
8. 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 do not use 4000 org 1000 counter rmb 1 org 2000 program code start Ids STACK Idx REGBLK aa ff staa ddrj x make port J an output port staa ddrb x make port B an output port staa ddrp x make port P an output port staa ptp x turn off 7 segment LED display clr ptj x make PJ1 low to enable LEDs back clr portb x turn off PBO jsr d250ms delay 250ms inc portb x turn on PBO jsr d250ms delay 250ms jmp back d250ms daa 250 delay 250 ms staa counter delay1 Idy 6000 6000 x 4 24 000 cycles 1ms delay dey this instruction takes 1 cycle bne delay this instruction takes 3 cycles dec counter bne delay1 not 250ms yet delay again 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_PB0O asm not just Flash_PBO 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 assemble
9. be internally shorted by cutting this jumper the board may be able to work again without the H Bridge External 9V DC input Chapter 5 CodeWarrior and Serial monitor CodeWarrior is a very powerful and professional IDE The main feature of CodeWarrior IDE is the source level debugger in assembler and C CodeWarrior Special Edition is a wonderful gift from Freescale to all of us and it s free for educational use What s more by CodeWarrior supporting serial monitor they have made it very affordable to support CodeWarrior for the OEM Freescale has invested millions of dollar into CodeWarrior and the current versions work very well What s more Freescale knows they will never sell enough copies of CodeWarrior 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 CodeWarrior sets Freescale apart from others CodeWarrior 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 CodeWarrior to eliminate the cost of a BDM Now a student can use the serial monitor with CodeWarrior to debug his program and in fact many un
10. channel 2 Enhanced Capture Timer channel 3 Enhanced Capture Timer channel 4 FFEE FFEF Enhanced Capture Timer channel 0 Enhanced Capture Timer channel 5 TIE C5 E4 FFE2 FFE3 Enhanced Capture Timer channel 6 TIE C6l E2 FFEO FFE1 Enhanced Capture Timer channel 7 TIE C7 SE SFFDE SFFDF TSR 0O SE FFDC FFDD PACTL PAOVI DC PACT PA SDA FFD8 FFD9 SPOCR1 SPIE SPTIE D8 SCOCR2 SC1CR2 sEFD4 SEEDS sel TIE TCIE RIE ILIE 04 FFD2 FFD3 ATDO ATDOCTL2 ASCIE D2 FFDO SFFD1 ATD1 L I ATD1CTL2 ASCIE D0 Port J Bit PTJIF PTJIE CE Port H Bit PTHIF PTHIE SCC FFCA FFCB Modulus Down Counter underflow I Bit MCCTL MCZI Fig 8 2 MC9S12DG256 Interrupt vector table 1 FF96 FF97 CAN4 wake up PTPIF PTPIE PWMSDN PWMIE Reserved FF8E FF8F Port P Interrupt SFF8C FF8D PWM Emergency Shutdown SFF80 to FF8B FF92 FF93 CAN4 receive I Bit CAN4RIER RXFIE FF90 FF91 CAN4 transmit I Bit CAN4TIER TXEIE2 TXEIE0 8C FFC8 FFC9 Pulse Accumulator B Overflow I Bit PBCTL PBOVI C8 FFC6 FFC7 CRGPLLIock Bit CRGINT LOCKIE C6 FFC4 FFC5 CRG Self Clock Mode Bit CRGINT SCMIE C4 FFC2 FFC3 BDLC L n DLCBCR1 IE C2 FFCO
11. 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 Dragon12Plus2 not c Windows desktop or other locations First right click the Start button then left click Explorer left click on C Dragon12Plus2 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 to Dragon12 Plus2 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 Dragon12Plus2 If you want to make a shortcut for AsmIDE on the Desktop this is the correct way to do it If you don t follow this method your may have a problem running your program Never drag the AsmIDE exe to the desktop folder The default setting of AsmIDE for the Dragon12 Plus2 board is created in a text file named c Dragon12Plus2 AsmIDE ini In the future if you get lost with all the changes you always can copy this file into the folder named c Dragon12Plus2 2 2 Getting Started for the AsmIDE and D Bug12 monitor firmware only To operate the Dragon12 Plus2 board follow steps1 through 5 below 1 Make sure that the both DIP switches of S
12. of the J5 on solder side then solder a wire from the pin 5 of the LCD header J11 to the PK7 of the female header H8 to make it for both read and write operations 4 6 Logic probe An on board logic probe LED is connected to pin 47 of the header H4 and can be used to monitor high or low states of a circuit as a logic probe The pin 47 of the U10 MC9S12DG256 is not connected to the header H4 4 7 Trimmer pot The trimmer pot VR2 is connected to the ANO7 input of the ADC port 4 8 Dual Digital to Analog Converters DACs The on board 2 ch 10 bit DAC is installed for learning SPI communication It convers a digital binary code to an analog signal so a program can generate different waveforms from the DAC The DAC installed on the board is LTC1661 Its analog output OUTA is provided on the pin between the headers H7 and H8 The other analog output OUTB is provided on the pin between the headers H1 and H2 A good application is to connect a DAC output to an ADC input so a user can send a binary code to the DAC and read the code back from the ADC 4 9 Speaker The speaker is a 5V audio transducer and it can be driven by PT5 Output Comparator 3 or PPS PWM 5 or the output B of the DAC LTC1661 The jumper on J26 is preset for the PTS at factory and all sample programs on the CD will drive the speaker via PTS During reset the bootloader or the serial monitor will generate a chirp via the speaker If the jumper is not installed for th
13. 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 touch the 4x4 on board keypad the entire port A will be available to your circuits If you don t use the LCD or just unplug the LCD the port K will be available as well Port B drives LEDs but if you ignore the status of the LED the port B can drive any other I O devices on the breadboard Each pin in port H reads a switch but it still can be used as an input for reading a TTL or CMOS output from your circuits Pin Name Pin UO Usage PAO output PA1 output PA2 output PA3 output PA4 input PAS input PAG input PA input PBO output PB1 output PB2 output PB3 output PB4 output PBS output PB6 output PB7 output PEO input PE1 PE2 output PE3 output PHO input PH1 input PH2 input PH3 input PH4 input PHS input PH6 input PH7 input PJO output PJ1 output PJ6 PJ7 PKO output PK1 output PK2 PK3 PK4 PK5 PK7 output Pin 57 Pin 58 Pin 59 Pin 60 Pin 61 Pin 62 Pin 63 Pin 64 Pin 24 Pin 25 Pin 26 Pin 27 Pin 28 Pin 29 Pin 30 Pin 31 Pin 56 Pin 55 Pin 54 Pin 53 Pin 39 Pin 38 Pin 37 Pin 36 Pin 52 Pin 51 Pin 50 Pin 49 Pin 35 Pin 34 Pin 33 Pin 32 Pin 22 Pin 21 Pin 99 Pin 98 Pin 8 Pin 7 Pin 6 Pin 5 Pin 20 Pin 19 Pin 108 Col_0 of key
14. the key 10 is down If PAS low the key 9 is down If PA4 low the key 8 is down Keypad scan routine sets PA1 low and PAO PA2 PA3 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 PAS low the key 5 is down If PA4 low the key 4 is down Keypad scan routine sets PAO low and PA1 PA2 PA3 high then tests PA4 PA7 If no key is down PA4 PA7 remain high If PAZ low the key 3 is down If PA6 low the key 2 is down If PAS low the key 1 is down If PA4 low the key 0 is down 4 5 LCD display Port K 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 J11 and J12 are as follows Pin 1 GND Pin 2 VCC 5V Pin 3 Via a 220 Ohm resistor to GND Pin 4 PKO RS pin for LCD module Pin 5 PK7 R W pin for LCD module Pin 6 PK1 EN pin for LCD module Pin 7 Not used Pin 8 Not used Pin 9 Not used Pin 10 Mot used Pin 11 PK2 DB4 pin for LCD module Pin 12 PK3 DB5 pin for LCD module Pin 13 PK4 DB6 pin for LCD module Pin 14 PK5 DB7 pin for LCD module Pin 15 Via a 22 Ohm resistor to VCC LED backlight for LCD module Pin 16 GND Please notice that PK2 PK5 not PK4 PK7 are used to drive DB4 DB7 of the LCD module The LCD module is hardwired for write only operation Experienced user can cut the trace between two pads
15. 5 K uaaa S G x BOTN eo CH gt gt gt lu Q A E ee eech FPTETTTTTITT TTE xQ 2 EE H A SBSaeeeeSaau ZEEE AAVERE 2253 A ASS mao 8 ol 222 x o a SSC lt lt lt gt lt A 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 The Dragon12 Plus2 board includes the following features compatible to the previous versions 1 O 9 boah On board USB interface selectable for SCIO or SCI1 RGB color LED RS485 communication port DS1307 RTC with capacitor backup included for testing 1 C interface IC expansion port for interfacing external DC devices CAN port SPI expansion port for interfacing external SPI devices Dual 10 bit DAC for testing SPI interface and generating analog waveforms Four robot servo controllers with terminal block for external 5V Four digit 7 segment LED display for learning multiplexing technique Eight LEDs Eight position DIP switch Four push button switches 3 3V and SV regulators Speaker to be driven by timer or DAC or PWM signal for alarm or music applications Dual H Bridge motor driver controls two DC motors or one Stepper motor 3 3V and 5V Power On LED indicators IR detector 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 Logic probe with LED indic
16. EFFC St SEFBE SEFFE Fig 8 4 MC9S12DG256 secondary interrupt vector table
17. F 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 7 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 first 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 With the early versions of D Bug12 monitor an 19 file must be converted to an s29 file to program the EEPROM but it s not required in the current version 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 Program on chip flash memory in BOOTLOADER mode In this mode you download your program code 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 code will re
18. FFC1 IC Bus Bit IBCR IBIE SCH SFFBE SFFBF al SPTORT SPIE SPTE SBE FFBC FFBD Bit SP2CR1 SPIE SPTIE BC FFBA FFBB EEPROM SBA SFEB8 SFFB9 Fei FOTU CCIE GBEIE me FFB6 FFB7 CANO wake up I Bit CANORIER WUPIE B6 FFB4 FFB5 CANO errors LEI CANORIER CSCIE OVRIE B4 FFB2 FFB3 CANO receive Bit CANORIER RXFIE B2 FFBO FFB1 CANO transmit L t CANOTIER TXEIE2 TXEIE0 BO FFAE FFAF CANT wake up I Bit CAN RIER WUPIE SAE CANT errors CAN1RIER CSCIE OVRIE AC SFFAA SFFAB CANtrecsve Fit CANTRIER RXFIE SAA GANT transmit SA8 CAN2 wake up CAN2RIER WUPIE A6 CAN2 errors CAN2RIER CSCIE OVRIE A4 FFA2 FFA3 CAN2 receive CAN2RIER RXFIE A2 CAN2 transmit CAN2TIER TXEIE2 TXEIE0 A0 CAN3 wake up CAN3RIER WUPIE 9E FFOC FFOD CAN errors I Bit CANSRIER TXEIE2 TXEIEO 9C CANS receive CAN3RIER RXFIE 9A CANS transmit CAN3TIER TXEIE2 TXEIEO 98 CANARIER WUPIE 96 CANGRIER CSCIE OVRIE 94 SFF8C SFFED Fig 8 3 MC9S12DG256 Interrupt vector table 2 Secondary Secondary Interrupt Source Vector Interrupt Source Vector Address Address Reserved FF80 EF80 EFCO Reserved FF82 EF82 EFC2 WI erg SEFCE SEFGA SEFCC SEFCE SEFDO SEFD2 SEEDA SC eg SEFDA SEFOC SEFDE SEFE0 SEFE Ser SEFES SEFES SEFER SEFEC SEFEE SEFFO MSCAN 0 receive EFB2 RQ ere seg SEFFS SEFFA SPI2 EFBC Clock monitor fail reset
19. I U uu uuu 24 A4 Keypad BE 26 bk LCD disply u uu A ag ss ha E 27 d Logie probe ieaiaia sn aaa naaa aAa ia san a nn le 28 4 7 Timmer pot u u uu RS VER RA SNAR Pea Upuan 28 4 8 Dual Digital to Analog Converter DACS U uu Q 28 We 28 410 IR detector u ULLA lara iss nds hasla SEN saa ss ann 28 4 11 Dual SCI communication ports Ul uu u 29 412 RS485 interface UUUUUUUUUULLUUUILII Sau awawawawwswaawawwawaawawaakawawwwawaakkakanaakaqaqaqana 29 4 13 External SPI interface U sanna sa 29 4 44 External FC interface eege aero 29 415 RGB LED iaaa N u a au ua ss S 30 4 16 All jumper settings eer U U U u uuu uuu u 30 Chapter 5 CodeWarrior and serial monitor Ul U 33 Chapter 6 RE code u IS eege EES 34 Chapter 7 Appendix uu uuu uuu aaa RA nl EEEEEER ANEREN NEE 35 7 4 D Bug12 utility routines iss nn k a uuu 35 Zo Interrupt Vector tables UU uuu AR NNA ER AG GR A ER LR TGRRR EFNA 36 Note For users who will use CodeWarrior IDE with serial monitor This manual is written for the board that is pre installed with bootloader and D Bug12 monitor If you ordered the board with Freescale serial monitor for CodeWarrior the board would be pre installed with the serial monitor and a factory test program
20. W7 must be set in the LOW positions for EVB mode then Plug the USB cable to the USB jack P1 on the upper left corner of the Dragon12 Plus2 board Plug the other end of the USB cable into a USB port of your PC Make sure that the jumpers on the J41 and J42 are set correctly for USB interface for the SCIO The header J43 is the MC9S12DG256 s SCI1 port in TTL interface that can be used by a user s application program After power up the PB7 PBO LEDs should light up from left to right one at a time the speaker should chirp once If the chirp is too soft you can remove the sticker on the speaker to increase the volume and the LCD should display the following message DRAGON12 plus2 you can display your name on LCD and see details D Bug12 EVB MODE at CDROM examples name_display readme txt If it does not occur make sure that the Power On LED indicator is on The PWR LED is on when VCC 5V is present To invoke the AsmIDE you can right click the Start button then left click Explorer left click on C Dragon12Plus2 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 Warning note In order to establish a reliable USB communication always connect the Plus2 board to your PC s USB port first before invoking the IDE CodeWarrior or AsmlIDE otherwise the IDE will not be able to communicate with the Plus2 During a debugging sessi
21. ator 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 4 X 4 keypad Form C relay output rated at 3A 30V or 1A 125V Relay On LED indicator X Y Z accelerometer interface or GP2 D12 distance measuring sensor interface for distance measurement Potentiometer trimmer pot for analog input Temperature sensor Communication port for VGA camera Camera is optional Light sensor Female headers provide shortest distance great for high speed applications from bread board to every I O pin of the MC9S12DG256 PC board size is 8 4 X 5 3 The Dragon12 Plus2 board also includes the following new features Xbee sockets a 4X2 female header for Nordic nRF24L01 transceiver a 4x1 female header for Bluetooth transceiver SD memory card slot and VGA camera interface Arduino Shield Compatible headers Acapacitive touch switch The Dragon12 Plus2 board has the following features as options 40 41 42 43 44 Xbee wireless transceiver module Nordic nRF24L01 wireless transceiver Bluetooth transceiver VGA camera 3 axis accelerometer 1 4 UO Pin Usage Many UO pins of the MC9S12DG256 on the Dragon12 Plus2 board are used by on board peripherals and it seems that there are only a few of unused pins left for your circuits on the breadboard Fortunately it s unlikely that all on board
22. below Function far main _ sStartofD Bugl2 sis getchar _ I Get a character from SCIO or SCH nd a character out SCIO or SCI1 far GetCmdLine Obtain a line of input from the user far sscanhex _ Convert an ASCII hexadecimal string to a binary integer SEESE Checks for membership in the set 0 9 a f A F Converts lower case characters to upper case salpha strlen i Returns the length of a null terminated string strepy Be Copies a null terminated string 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 far WriteEEByte r EraseEE ReadMem _ Read data from the M68HC12 memory map WriteMem Write data to the M68HC12 memory map Fig 8 1 D Bug12 utility routines 7 2 Interrupt vector table Table 5 1 Interrupt Vector Locations HPRIO Value Local Enable to Elevate Vector Address Interrupt Source FFFE F FFF Reset Clock Monitor fail reset FFFA FFFB COP failure reset Unimplemented instruction trap FFF6 FFF7 SWI FFF2 FFF3 IRQ PLLCTL CME SCME COP rate select None None None IRQCR IRQEN F2 FFF0 FFF1 Real Time Interrupt CRGINT RTIE TIE C0D see TIE C1 EC TIE C21 SEA TIE C3 SES TIE C41 Enhanced Capture Timer channel 1 Enhanced Capture Timer
23. cement for the old 68HC811E2 microcontroller but it also gives you 3K EEPROM instead of 2K EEPROM with the 68HC811E2 The bus speed is 4MHz 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_programming After booting up in this mode the LCD should display the following message DRAGON12 plus2 JUMP TO EEPROM 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 Dragon12 Plus2 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 Dragon12 Plus2 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 b
24. ction 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 5 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 Dragon12 Plus2 board is pressed If you do not see this the bottom window may be set for message window Sometime it s a little co
25. e Thank you very much for purchasing our Dragon12 Plus2 trainer The Dragon12 Plus2 trainer is a low cost feature packed training board for the new Freescale HCS12 microcontroller family It is compatible with the Freescale 9512DP256EVB board and other similar development boards on the market today but it also incorporates many on board peripherals that make this board a popular trainer 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 versatile platform for senior projects as well The new features of the Dragon12 Plus2 board create a new potential for students at every level The Dragon12 Plus2 trainer kit comes with the following items 1 Dragon12 Plus2 board 2 Software downloadable from our web site a AsmIDE with HCS12 assembler b Sample programs with source code c Users manualFreescale application no 3 6 foot USB type B cable 4 9V 500mA switching power supply AC adapter for North America customers only If you miss any part of the kit please contact sales EVBplus com or call 630 894 1440 for help The new Dragon12 Plus2 board is fully backward compatible to the Dragon12 Plus USB board All software written for the Dragon12 Plus USB board will run on the new Dragon12 Plus2 board without modif
26. e PTS the chirp won t happen 4 10 IR detector The IR detector can be used for IR remote control applications If a 38 KHz signal from an IR transmitter is detected by the IR detector the output of the detector goes low The output of the IR detector ia connected to the PT3 4 11 Dual SCI communication ports The SCIO is used by D Bug12 or serial monitor for developing and debugging user programs The SCI1 can be used by user s application programs The receiver of the SCI1 can receive signals from many different devices but only from one device at a time or it will cause a signal collision The main header J51 and auxiliary header J23 are used to select which device the SC will receive The J51 selects a source from J23 VGA camera module and XBee module The J23 selects a source from USB interface via P1 USB jack Async serial communication in TTL logic level via J43 RS232 via P2 DB9 connector and RS485 via T2 2 postion terminal block 1 When a jumper is installed vertically on the two leftmost pins of the J51 the SCI1 will receive signal from one of four sources decided by the jumper on the J23 2 When a jumper is installed vertically on the two middle pins of the J51 the SCI1 will receive signal from VGA camera module and the jumper on the J23 has no effect 3 When a jumper is installed vertically on the two rightmost pins of the J51 the SCI1 will receive signal from XBee module and the jumper on the J23 has no effect
27. e math used to set the PLL frequency is PLLCLK CrystalFreq 2 initSYNR 1 initREFDV 1 CrystalFreq 8 MHz on Dragon12 Plus2 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 Assembly code start 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 bset plictl x 01000000 Turn PLL on bit 6 1 PLL on bit 6 0 PLL off daa 05 5 1 6 multiplier staa synr x daa 03 divisor 3 1 4 16 2 6 4 48MHz PLL freq for 16 MHz crystal daa 01 divisor 1 1 2 8 2 6 2 48MHz PLL freq for 8 MHz crystal daa 00 divisor 0 1 1 4 2 6 1 48MHz PLL freq for 4 MHz crystal staa refdv x wait b3 brelr crgflg x 00001000 wait bi Wait until bit 3 1 bset clksel x 10000000 C code void Set_Clock void CLKSEL amp 0x7F PLLCTL 0x40 SYNR 0x05 REFDV 0x01 REDDV 0x00 for 4 MHz REDDV 0x01 for 8 MHz REDDV 0x03 for 16 MHz while 1 0x08 amp CRGFLG CLKSEL 0x80 Chapter 7 Appendix 7 1 D Bug12 utility routines The AN1280 was written for OLD 68HC 12 family If you happen to use printf routine with your old 68HC12 board you should be aware that UO utility routines are moved to different addresses in D Bug12 V4 x The address for the printf is EE88 and addresses of other UO routines are listed
28. e turned off 4 Delay ims 5 Output 4F to port B set PP2 low and PPO PP1 and PP3 high The number 3 is shown on the digit 1 but other 3 digits are turned off 6 Delay ims 7 Output 66 to port B set PP3 low and PPO PP1 and PP2 high The number 4 is shown on the digit 0 the rightmost digit but other 3 digits are turned off 8 Delay ims 9 Go back to step 1 4 4 Keypad 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 UC The schematic for the keypad connections is shown below PAO PA1 PA2 PA3 Col 0 Col 1 Col 2 Col 3 P57 PAS PA4 Row_0 PAS Row 1 DAG Row 2 KEY12 KEY13 KEY14 KEY15 P64 PAT PA7 Row 3 KEYPAD Keypad connections PAO connects COLO of the keypad DAT connects COL1 of the keypad PA2 connects COL2 of the keypad PA3 connects COL3 of the keypad PA4 connects ROWO of the keypad PAS 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 PA3 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
29. ervo connector must be installed horizontally PP7 PWM output for a servo the servo connector must be installed horizontally SPI connector 6 pin On board LCD connector for a 16x2 LCD RS of CANO U2 is hard wired to VSS Located on solder side Connects SQW of the DS1307 to IRQ It s not connected Located on solder side BDM input BDM output when the board is booted in POD mode SCI receiver source select numbering from top to bottom It s only functioning if a jumper is installed vertically on the two leftmost pins of J51 1 SCI1 s PS2 receives signal from USB interface chip FT232RL 2 SCI1 s PS2 receives signal from J43 in TTL logic level 3 SCI1 s PS2 receives signal from P2 DB9 connector in RS232 logic level 4 SCI1 s PS2 receives signal from the terminal block T2 of RS485 port DC motor power select The jumper is installed on the two left pins if motors are powered by the on board unregulated 9V VIN The jumper is installed on the two right pins if motors are powered by external voltage source that is lass than 15V at the terminal block T3 J26 J34 J35 J36 J39 J40 J41 J42 J43 J49 J50 J51 Selects speaker driving source The speaker can be driven by PT5 OC3 PPS PWM and DAC B Connects PE2 to relay circuit It s hard wired Located on solder side Servo motor power select The jumper is installed on the two left pins if servos are powered by the on board VCC 5V The jumper i
30. g your code instead of the D Bug12 monitor the bus speed is 4MHz 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 need to auto start your code upon reset the procedure is available in the folder named flash_programming 3 1 4 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 BDM in port After booting up in this mode the LCD should display the following message DRAGON12 plus2 BOOT LOADER and you should see the following bootl
31. gram 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 S123FFA0F64CF650F654F658F65CF660F664F668F66CF670F674F678F67CF680F684F6883D S123FFC0F68CF690F694F698F69CF6A0F6A4F6A8F6ACF6BOF6B4F6B8F6BCF6C0F6C4F6C81D S123FFI EOF6CCF6D0F6D4F6D8F6DCF6FE0F6E4F6E8F6ECF6F0F6F4F6F8F6FCF700F704F00009 S9030000FC S2240FEFA0DB7ODB66DB5CDB52DB48DB3EDB34DB2ADB20DB16DB0CDB02DAF8DAEEDAE S2240FEFCODADODAC6DABCDAB2DAA8DA9FDA94DA8ADA80DA76DA6CDDD0DA62DA58DA4 An s2 record file looks like this D DADA41 DA4494 Gl S22 40FEFEQODA02DA0ADA1 2DA1ADA2 2DA2ADA32DA3AD9FAD9F2D9AFD98ADIDSEFOOEFOOEFO039 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
32. ications Please carefully examine the default jumper settings before turning on the board 1 The J1 should have a jumper for LCD backlight 2 The J26 should have a jumper installed on the two top pins labeled with PT5 so the speaker will be driven by PTS The speaker can be driven by timer PTS or PWM PPS or DAC It defaults for PTS Without a jumper installed on J26 the speaker won t sound 3 The J41 should have a jumper installed on the two lower pins so the SCIO receives signal from USB port 4 The J42 should have two jumpers installed vertically on the four upper pins so the USB interface is connected to SCIO The AsmIDE or CodeWarrior IDE only works with SCIO If these two jumpers are installed on the four lower pins and the jumper on J23 in the two top pins labeled with USB then the USB interface is connected to SCI1 The specification of the switching power supply AC adapter is DC input 110V 240V DC output 9V Current rating 500mA Type of plug 2 1mm female barrier plug center positive 1 2 MC9S12DG256 features and memory map The Dragon12 Plus2 board comes with the MC9S12DP256CCPV or the MC9S12DG256CVPE installed The MC9S12DG256 is a 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 micr
33. ing the number 1234 on the display By convention the 7segments are called segment A B C D E F and G Their locations in the display are shown below The segment A B C D E F G and Decimal Point are driven by PBO D I PB2 PB3 PB4 PBS PBS and PB7 respectively The hex value of the segment code is shown in the following table DEES oF E gt 8 afera HEG UN feel S The schematic for multiplexing 4 digits is shown below The two of the digits at the right are deliberately placed upside down and the hardware connections compensate for this configuration The reason for the upside down digits is to place two decimal pointers on the middle as a colon for a clock display COMMON CATHODE x RNG 158 X 4 The digit 3 2 1 and 0 are driven by PPO PP1 PP2 and PP3 respectively The 7 segment LED is turned on one at a time at 250 Hz refresh rate It s so fast that our eyes will perceive that all 4 digits are turned on at the same time To display the number 1234 on the 7 segment display the following steps should be taken 1 Output 06 to port B set PPO low and PP1 PP2 and PP3 high The number 1 is shown on the digit 3 the leftmost digit but other 3 digits are turned off 2 Delay ims 3 Output 5B to port B set PP1 low and PPO PP2 and PP3 high The number 2 is shown on the digit 2 but other 3 digits ar
34. iversities have been using the serial monitor with CodeWarrior 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 Dragon12 Plus2 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 CodeWarrior IDE later In this case a school laboratory only needs to have one BDM or use one Dragon12 Plus2 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 procedure to program the on chip flash memory is shown at http www evbplus com freescale_usbdm_osbdm usbdm_osbdm_bdm_multilink html Some universities use CodeWarrior IDE only In this case we pre load the on chip flash memory with serial monitor For more information on CodeWarrior please visit http Awww evbplus com Code_Warrior_hcs12 html Chapter 6 PLL code The crystal frequency on the Dragon12 Plus2 board is 8 MHz so the default bus speed 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 Th
35. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 4 It will take 3 minutes to program the D Bug12 at 9600 baud rate and the bootloader menu will reappear after the D Bug12 monitor is successfully programmed into flash memory 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 flash the PBO LED at 2Hz when it s running The RAM byte named counter is added for demonstrating how a
36. kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 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 Dragon12 Plus2 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 the D Bug12 monitor into a single s2 file named Boot DBug12v32_DR12P_8MHz 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 runnin
37. lows 1 Click the File button to open the test asm from c Dragon12Plus2 examples After the test asm is loaded into the AsmIDE window you can view instructions of how to test all hardware on the Dragon12 Plus2 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 then hit lt Enter gt key 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 and hit lt Enter gt key 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 Chapter 3 S
38. nfusing 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 Warning note If you see the above message but you cannot type in any character on keyboard then the jumper on J41 is probably installed on the two upper pins In order to use USB interface the jumper on J41 must be installed on the two lower pins 2 3 Test Hardware To help users get up and running the Dragon12 Plus2 board comes with many fully debugged and ready to run sample programs including source code The hardware test program test asm simultaneously scans the keypad plays a song multiplexes the 4 LED seven segment display changes display brightness by adjusting the trimmer pot and detects an IR signal All sample programs must be run from RAM in EVB mode In order to run the test program in EVB mode the both DIP switches of SW7 must be set in the low positions the picture above the SW7 shows the switch settings for 4 different modes The steps to run your first sample program are as fol
39. oader menu on PC screen MC9S12DG256 bootloader menu a Erase Flash b Program Flash c Set Baud Rate d Erase EEPROM 2 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 s2 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 Some users may accidentally erase the D Bug12 monitor when entering this mode so it is 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_DR12P_8MHz s29 located in the folder named D Bug12 Monitor for downloading You should see the following on the screen kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkkkkkk
40. ocontrollers have the same features 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 If your application that needs more than two CAN ports please contact us at sales evbplus com and we may be able to ship the board installed with the DP256 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 IC 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 8 IS 1000 4000 8000 FFOO VECTORS VECTORS SFFFF C000 EXTERN EXPANDED NORMAL SINGLE CHIP Assuming that a 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 i
41. oftware descriptions 3 1 Bootloader and D Bug12 Monitor The MC9S12DG256 on the Dragon12 Plus2 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 DIPswitch SW7 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 documentations They can be found on the folder named C Dragon12Plus2 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 C000 EFFF are just a part of the monitor In 16 bit S1 record they are C000 EFFF In 24 bit S2 record they are FCOO0 FEFFF 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 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 vie
42. on if you accidentally unplug the USB cable from the Plus2 you need to re establish the USB communication The IDE will not recognize the Plus2 again if you just simply plug the USB cable back in To re establish the USB communication you need to exit the IDE and disconnect the USB cable from the Plus2 board wait for a few seconds before re plugging in the USB cable then wait for a few more seconds and allow the USB communication to be re established with the Plus2 After re establishing the USB communication you can invoke the IDE again and the IDE will start to communicate with the Plus2 board If this does not work you need to restart your PC If restarting the PC does not solve the problem you may need to re install the USB driver The AsmIDE is simple and very easy to use You only need to use three commands from the AsmlIDE 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 Dragon12 Plus2 board In the View gt Option gt Terminal Window Options menu set the COM port as 1 or 2 to match the COM port number that is assigned to the USB port by Device Manager in control panel Also set the COM port options at 9600 N 8 1 and check the enable the terminal window After reset the D Bug12 monitor defaults baud rate at 9600 and and Hyperbaud function is disabled If Hyperbaud fun
43. ooting up in this mode the LCD should display one of the following two messages If the D Bug12 monitor is erased the LCD will display the following message after reset DRAGON12 plus POD Bug12 ERASED Otherwise it will display DRAGON12 plus2 BDM POD MODE and you should see the following message on PC screen Can t Communicate With Target CPU 1 Set Target Speed 48000 KHz 2 Reset Target 3 Reattempt Communication 4 Erase amp Unsecure 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 8000 for the target speed After the correct speed is entered the master will try to communicate with the target board If it s not successful enter choice 2 to reset the target board Note The newer D Bug12 monitor in POD mode may auto detect the crystal frequency of a target board so most likely the step 1 may not be needed Can t Communicate With Target CPU 1 Set Target Speed 8000 KHz 2 Reset Target 3 Reattempt Communication 4 Erase amp Unsecure 21 Enter Target Crystal Frequency kHz 8000 Can t Communicate With Target CPU 1 Set Target Speed 8000 KHz 2 Reset Target
44. pad Col_1 of keypad Col 2 of keypad Col_3 of keypad Row_0 of keypad Row_1 of keypad Row_2 of keypad Row_3 of keypad LEDO or H bridge LED1 or H bridge LED2 or H bridge LED3 or H bridge LED4 Abort switch SW8 not used Relay not used not used not used not used not used DIP switch 1 or pushbutton switch SW5 DIP switch 2 or pushbutton switch SW4 input DIP switch 3 or pushbutton switch SW3 input DIP switch 4 or pushbutton switch SW2 input DIP switch 5 input DIP switch 6 input DIP switch 7 input DIP switch 8 input DIR of RS485 LED enable SDA for DS1307 U11 or external DC J2 SCL for DS1307 U11 or external I2C J2 RS of LCD module EN of LCD module DB4 of LCD module bi directional DB5 of LCD module bi directional DB6 of LCD module bi directional DB7 of LCD module bi directional R W of LCD module Table 1 1 I O pin usage list 1 Pin Name UO Usage Pin 105 CANO Pin 104 CANO Pin 103 Write Enable for MicroSD memory Pin 102 Card detect for MicroSD memory Pin 101 CS of MicroSD memory Pin 100 CS of nRF24L01 Pin 88 CS of LTC1661 DAC Pin 87 Not used PPO output Pin 4 Digit 3 of 7 segment display or EN12 of H bridge PP1 output Pin 3 Digit 2 of 7 segment display or EN34 of H bridge PP2 output Pin 2 Digit 1 of 7 segment display PP3 output Pin 1 Digit 0 of 7 segment display PP4 output Pin 112 Servo motor 1 or RGB LED PP5 output Pin 111 Servo motor 2 or RGB LED
45. place 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 SW 7 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 the secondary interrupt vectors at 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 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 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 document Sreccvt GUI Chapter 4 Hardware Descriptions The crystal frequency is 8 MHz and usuall
46. r detects an error the error message will show the line numbers of your source code that caused the error You have to correct all errors in your program 4 Go to the line and correct the errors and go back to step 3 until there are no errors 5 Press the reset button on the board you will see D Bug12 v4 0 0b32 Copyright 1996 2005 Freescale Semiconductor For Commands type Help gt 6 Type LOAD and then hit lt Enter gt key 7 Click Build button select Download option and locate the file named Flash_PB0 s19 for downloading After download is done type G 2000 and hit lt Enter gt key to run the program For your convenience we have included this sample program in the folder named example 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 EVB 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 3FF
47. s 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 gt PK1 XADDR15 PK2 XADDR16 PK3 XADDR17 ox PK4 XADDR18 PKS XADDR19 Single wira Background ST Modula CPU12 COP Watchdog Clock Monitor Clock and Reset Generation Module PTO PT PT2 ge 2 S me E Be Module PTS PES sl SIM PT6 K geg PES we _ PT7 PET Le PSO PS TEST W 1114311111 1111111181 PSS te PS4 Multiplexed Address Data Bus jee PSS 11113111 1114112118 co DDRA DDRB BDLC RX8 RXCAN sr PMI t HI G 2 PERE RER HDH ANO TXCAN PM SS anaana CAN1 HXCAN PM3 wtaNr og Se SSS a TXCAN res o lee PM4 s SSSSSS 5 FES8085888 che moss SS GP i Basoasago aasan TXCAN PMS g lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt lt RXGAN eal PM z Keen eeh D Multiplexed z K X X XXX x lt lt lt Zx x lt AXCAN G Wide Bus EEEEEEEE EEEREEEEE 4 WideBus ASS Aasaa AA L OAN rxCAN 5 th EE waku saa iqu as PJO m Multiplexed 2222222 x p Pn s NarrowBuss lt lt lt lt lt lt lt a PJG Simmer mm KN PJ Intemal Logic 2 5V VO Driver 5V ee PPO VDD12 VDDX 4 Vss1 2 VSSX et F ec BE z z amp a ken PPS AID Converter SV A g E Lee PP4 PLL 2 5V Voltage Regulator Reference em PPS VDDPLL VDDA
48. s installed on the two right pins if servos are powered by an external 5V power supply at the terminal block T7 X Y X Accelerometer module interface Connects PMO to RXD of CAN interface U2 It s hard wired Located on solder side TTL logic level of the SCIO In order to use this header a jumper must be installed on the two upper pins of the J41 Selects SCIO interface A jumper is installed on the two lower pins for USB interface or on the two upper pins for TTL interface Both jumpers are installed vertically on the four upper pins for connecting SCIO to USB port Both jumpers are installed vertically on the four lower pins for connecting SCI1 to USB port When connecting SCI1 to USB port the jumper on J23 must be installed horizontally on the TOP position labeled with USB TTL logic level of the SCI1 for user application In order to use this header the jumper on the J23 must be horizontally installed on the second position from the top labeled with TTL Connects VRH to VDDA it s hard wired Located on solder side If a different voltage level is needed for the VRH cut this jumper and solder a wire from VRH pin to whatever voltage such as 2 5V from the VDD2 External 3V battery backup volatage for the Real Time Clock U11 DS1307 The RTC is backed up by a large capacitor without a battery If the capacitor is fully charged after the board being turned on for 12 hours it will normally keep the RTC running at leas
49. sage list 2 Chapter 2 Quick Start By default the Dragon12 Plus2 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 CodeWarrior IDE for 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 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 After downloading software from our web site the installation is automated by double clicking on the SETUP BAT It will create a folder named c Dragon12Plus2 examples and copy all example program files from the CD to c Dragon12Plus2 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
50. t two weeks when the power is turned off If that s not long enough an external 3V battery backup is recommended Main SCI1 select header When a jumper is installed vertically on the two leftmost pins of the J51 the SCI1 will receive signal from one of four sources decided by the jumper on the J23 When a jumper is installed vertically on the two middle pins of the J51 the SCI1 will receive signal from VGA camera module and the jumper on the J23 has no effect When a jumper is installed vertically on the two rightmost pins of the J51 the SCI1 will receive signal from XBee module and the jumper on the J23 has no effect Nordic nRF24L01 interface VGA camera interface Wi Fi enable of a Wi Fi module on XBEE footprint XBEE pin 1 to pin 10 breakout XBEE pin 11 to pin 20 breakout Analog sensor input 1 and can be used for an IR distance sensor such as GP2D12 or other ananlog or digital sensors J58 J60 J61 J62 Analog sensor input 2 and can be used for an IR distance sensor such as GP2D12 or other ananlog or digital sensors Connects capacitor backup to the RTC It s hard wired Located on solder side If an external battery backup is connected to the J50 cutting off this jumper will disconnect the capacitor from the RTC and prevent any leakage current caused by the capacitor Provides VCC to the H Bridge motor control IC U12 TB6612FNG It s hard wired Located on solder side In case the U12 is damaged VCC and VSS may
51. w 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 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 the LCD should display the following message DRAGON12 plus2 D Bug12 EVB MODE and 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 the LCD will display the following message after reset DRAGON12 plus2 D Bug12 ERASED You can use bootloader to re program D Bug12 monitor into flash memory Note Some user may accidentally erase D Bug12 monitor in bootloader mode so it is important to know how to re program D Bug12 monitor in bootloader mode Jump to EEPROM mode PAD1 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 repla
52. y it will result in a 4 MHz bus speed but on this board the MC9S12DG256 s internal PLL boosts the bus speed up to 24 MHz The circuit is designed in such way that the value of all resistors and capacitors are not critical 4 1 LEDs Each port B line is monitored by a LED In order to turn on port B LEDs the PJ1 pin 21 of MC9S12DG256 must be programmed as output and set for logic zero 4 2 DIP switch and pushbuttons Port H is connected to an 8 position DIP switch The DIP switch is connected to VCC via the RN4 four 2 7K resistors and RNS four 2 7K resistors Via RN8 four 47K resistors and RNY foru 47K resistors so it s not dead short to VCC or GND When port H is programmed as an output port the DIP switch setting is ignored but for the best result all 8 DIP switches should be open at the low positions 4 3 7 Segment LED multiplexing There are 4 digits of 7 segment LEDs on the Dragon12 Plus2 board The type of the 7 segment LED on board is called common cathode In an individual digit all anodes are driven individually by an output port and all cathodes are internally connected together 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 The Dragon12 Plus2 board uses port B to drive 7 segment anodes and uses PPO PP3 to drive common cathodes We will explain how to multiplex 7 segment by display

Download Pdf Manuals

image

Related Search

Related Contents

  Sony DSC-H2 Marketing Specifications    

Copyright © All rights reserved.
Failed to retrieve file