Home
Open Source BDM Interface User Manual
Contents
1. BDC commands are sent serially from a host computer to the BKGD pin of the target HCS08 MCU All commands and data are sent MSB first using a custom BDC communications protocol Two groups of BDC commands are listed below A complete list of these commands is provided in the Development Tools chapter 1 Active Background Mode Commands These commands allow the CPU registers to be read or written Users can also trace one user instruction at a time or begin the user program in this mode 2 Non intrusive Commands These commands permit read or write of MCU memory locations or access status and control registers within the background debug controller Non intrusive commands can be executed at any time With a single wire background debug interface a relatively simple interface pod is used to translate commands from a host computer into commands for the BDC In the case of the Open Source BDM a Low speed LS universal serial bus USB interface is used to communicate Introduction to Open Source BDM between the host PC and the pod Functionality provided by the BDC and ICE DBG modules include Single pin for mode selection and background communications BDC registers not located in the memory map SYNC command to determine target communications rate Non intrusive commands for memory access Active background mode commands for CPU register access GO and TRACE1 commands BACKGROUND command can wake CPU from Stop or Wait modes One hardware a
2. 2 7kB s rate 2 2 3 AN2399 ICP Programming Jumpers The ICP programming setup procedures and operation details are provided in the JB16 USB BDM firmware section 2 3 Open Source BDM Layout and Guidelines The Open Source BDM is a two sided PCB roughly 3 in x 3 in larger illustrated in Figure 8 The gerber files are provided with the Open Source BDM in a later release The gerber files can be used to develop the design into another form factor if desired 12 Open Source BDM PCB Hardware and MC68HC908JB16 LAs IED o Top View Bottom View Figure 8 Open Source PCB Layout 2 4 Getting Open Source BDM Components A complete BOM is provided in Table 3 including all parts required for the Open Source BDM Each part is provided with order numbers from Digi Key Some of these components are available as free samples Free samples of Freescale s HC908JB16 are available from www freescale com Table 3 BOM Generic Part Description Package Component No Digi Key PartNo Qty MC68HC908JB16DW MCU 28 Pin SOIC U1 MC68HC908JB16DW ND 1 SN74LVC1T45DBVR Level Shifter 6 Pin SOT 23 U2 U13 296 16843 1 ND 2 Crystal 12 MHz Citizen HC49US12 000MABJB UB HC 49US Y1 300 8492 ND 1 Capcitator Electronic 4 7uF Panasonic ECE A1VKG4R7 Radial Lead C3 C7 C10 C18 P920 ND 4 Capcitator Ceramic 27pF EPCOS B37979N1270J054 Radial Lead C12 C13 495 1005 1 ND 2 Capcitator 0 1 uF Kemet C320C104K5
3. File 3 2 x Look in lo bin gt e ey Ea P amp E_FCS EfPeE_ICD abs File name PRE CD abs Files of type Executables abs elf Cancel A Figure 31 Load Executable Dialog Box 9 To close the Non Volatile Memory Control dialog box press the Unselect All 10 Then press the OK button 7 0 References 1 LIBUSB documentation http libusb sourceforge net 2 Data sheet to HC908JB16 MC68HC908JB16 PDF available from Freescale 3 Documentation to Generic Debugging Interface available from Tasking www tasking com 4 TBDML HCS12 project see either http forums freescale com or www freegeeks net 38
4. intended to be used as binaries by majority of users For those who would like to look deeper the source code of the JB16 firmware and the Open Source BDM interface DLL is provided in Table 1 Open Source BDM Interface Users Manual Table 1 Open Source BDM IP Components Component Description Interfaces Available Comments Open Source BDM GDI driver File OpenSourceBDM_gdi dll Software interfacing with the CW V5 0 debugger GDI interface providing function call to the Open Source BDM USB driver This software is available only as object code in the form of a DLL Open Source BDM USB driver File OpenSourceBDM dll Software interfacing with the Open Source BDM GDI driver providing function calls to the Windows USB drivers This file is also required for the PC when it detects the Open Source BDM PCB as a new USB device on the PC USB port This software is available as both object DLL and source code The DLL is provided in an Open Source BDM USB install package Point the PC Hardware Wizard to the USB install package when the PC detected the Open Source BDM PCB Windows USB drivers File libusb lib Software used by the Open Source BDM USB driver it interfaces to PC USB ports This USB library is compiled with the Open Source BDM USB driver and is also part of the Open Source BDM USB install package The source code for libusb can be found at http libusb sourceforge net JB16 USB BD
5. is configured with the correct path to the Open Source 26 Installation and Operation of the Open Source BDM BDM windows driver package select the Next button This will initiate the installation of the Open Source BDM USB required driver and DLL file ilustrated in Figure 18 Found New Hardware Wizard P Please wait while the wizard installs the software CN Sy lt Turbo BDM Light USB Driver v1 0 LibUSB wW32 libusbst sys To C WINDOWS System3A Drivers PTT TTT TTT Ty Cancel Figure 18 Driver Installation in Progress Once the installation procedure is completed the device will be ready to use illustrated in Figure 19 Select the Finish button at this point Because of the plug and play nature of USB a reboot of Windows is not required Found New Hardware Wizard Completing the Found New Hardware Wizard The wizard has finished installing the software for Q Turbe BDM Light USB Driver v1 0 LibUSB W32 Click Finish to cose the wizard os Cancel Figure 19 Finishing Installation Open Source BDM Windows USB Driver 27 Open Source BDM Interface Users Manual 6 3 Configuring the Hiwave Debugger for the Open Source BDM GDI DLL Plug in Once the Open Source BDM device is recognized by Windows the CodeWarrior version 5 0 hiwave debugger is one step closer to programming and debugging targets with the Open Source BDM development tool The initial release of the CodeWarrior version 5 0 and t
6. on to the JB16 6 1 1 Open Source BDM PCB HCS08 Configuration Table 4 details the Open Source BDM PCB jumper configuration settings for Programming and debugging targets for the HCSO8 Other types of target may required other settings Table 4 Open Source BDM PCB HCS08 Configuration Jumper Description Setting Short 1 2 Power target externally via J1 or target is self JP1 Target Power Selection powered Short 2 3 Power target using 5V USB power JP3 Flash Program Off JP4 Flash Program Off JP5 Flash Erase Off 6 2 Installing Windows Open Source BDM DLL and USB Drivers The following procedure specifies the installing of the Open Source BDM USB hardware drivers under the Windows operating system This procedure assumes Open Source BDM windows USB driver package is unpacked onto the development PC running the CodeWarrior Studio With the Open Source BDM PCB configured the Open Source BDM PCB can be connected to the development PC USB port When the configured Open Source BDM PCB is connected to the PC for the first time the Windows operating system recognizes a new USB device the Open Source BDM PCB This initial connection starts the Windows driver installation procedure Figure 16 illustrates the Windows New Hardware Wizard dialog box that opens 25 Open Source BDM Interface Users Manual Found New Hardware Wizard Welcome to the Found New Hardware Wizard This wizard helgs you install
7. software for USB Device If your hardware came with an installation CD lt gt or floppy disk insert it now What do you want the wizard to do Install from a list or specific location Advanced Click Next to continue Figure 16 Found New Hardware Dialog Box For this installation select the option to nstall from a Specific Location then click Next When the Next button is selected the Specify Location of the Drivers dialog box opens illustrated in Figure 17 Found New Hardware Wizard Please choose your search and installation options Se Seach for the best driver in these locations Use the check boxes below to limit or expand the default search which includes local paths and removable media The best diver found will be installed I Search removable media floppy CD ROM IV Include this location in the searck D Documents projects bmd_interface_light usb_di 7 Browse C Dor t search will choose the driver to nstall Choose this option to select the device driver from a list Windows does not guarantee that the driver you choose will be the best match for your hardware crs Figure 17 Specifying Location of Drivers Dialog Box In the Specify Location of the Drivers dialog box point the Hardware Wizard to the unzipped Open Source BDM windows driver package using the Browse button Once the Windows Specify Location of the Drivers dialog box
8. uploaded into the target system the target must be erased before it can be programmed In order to both erase and program the target a program must be loaded into RAM first Both are separate erase and program algorithms These programs provide a means to write to and erase flash Every part family and every derivative has a distinct erasing and programming algorithm file These files are not included in this version of the Open Source BDM but some erasing and programming algorithm file from within the CodeWarrior installation can be used Erasing and programming algorithm are not directly supported by CodeWarrior consquently they are not guaranteed Figure 15 illustrates the location of these files within the CodeWarrior installation in the fpp directory It is not necessary to access the files directly the Open Source BDM is configured to access the files during target erase and programming operations E 3 Program Files Freescale gt cwos v5 0 C CodeWarrior_Examples D Helper Apps C bin D Help B lib Lint D ProcessorExpert prog gt gdi B MEM O P8 gt REG C Release_Notes O Templates Figure 15 Path to FPP 24 Installation and Operation of the Open Source BDM 6 0 Installation and Operation of the Open Source BDM 6 1 Configuration of the Open Source BDM PCB This section assumes the Open Source BDM firmware is programmed
9. Introduction to Open Source BDM Open Source BDM Interface Users Manual 1 0 Introduction to Open Source BDM This document describes an Open Source programming and debugging development tool designed to work with Freescale HCS08 microcontrollers Called Open Source BDM it can be obtained from the 8 bit message board at http forums freescale com While there is no support for Open Source BDM from Freescale the Open Source BDM is provided with all required source code for both hardware and software components Because it is open source the source code can be used and or modified from its original design free of charge Figure 1 provides a pictorial overview of the typical connections required for programming and debugging using the Open Source BDM A PC connects to the Open Source BDM PCB in turn the PCB is connected to a Programming Debug target In this example the GB60 demonstration boards are being programmed and debugged i Open Source BDM PCB PCB BDM 6 pin Interface User Programming Debug Target Figure 1 Debugging with Open Source BDM Open Source BDM with its hardware and software components provides a transparent connection between a computer running CodeWarrior Development Studio for HCS08 version 5 0 to a Freescale HCS08 microcontroller via the microcontrollers BKGD pin With a connection to the BKGD pin the Open Source BDM enables debuggers and other software tools to communicate with the microcontroller inclu
10. M firmware File OpenSourceBDM s19 Software running on the JB16 that receives commands via USB from the PC and converts them into commands as defined by the BDC These command are serial outputted bit banged by the JB16 using port pins to drive the BKGD pin on the user s target This file is provide as a S recorded and need to be programmed the the JB16 on chip flash Open Source BDM PCB hardware PCB OpenSourceBDM Pod ver 1 0 This hardware contains the JB16 and circuitry clock and power to provide the interface to the program debug target All schematics and gerber files for the Open Source BDM PCB is provided along with a Bill of Materials BOM Also included is a complete HW description which enables you to build the interface 1 5 Open Source BDM Package This section describes the contents of the Open Source BDM package The package is distributed in zip file and includes both release and development folders The development files folder contains source files while the release files folder contains only binary release files A detailed discussion is provided for each of these items in the next sections An illustration of the unzipped Open Source BDM package directory structure is provided in Figure 4 Open Source BDM PCB Hardware and MC68HC908JB16 5 OpenSourceBDM Development_Files E O OpenSourceBDM_HWFiles C BOMwithDatasheets B Layout C Schematics E 3 Ope
11. Mc9s08GT60 Mc9soscTS04 HCSO8QG Family HCSO8R Family D E Device and Connection Add Additional Files 1 4 Processor Expert C C Options PC Lint H H Choose your default connection Connections Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCSO8 HCS06 Serial Monitor Connect to P amp E BDM Multilink USB and parallel or P amp E Cyclone Pro USB Serial and TCP IP lt Back Finish Cancel Figure 22 New Project Debugger Interface Connections Dialog Box Alternatively if the project was built with other connection using the New Project Debugger Interface Connections dialog box it can be easily changed in the CodeWarrior IDE project manager illustrated Figure 23 Also the set gdi command can still be used in the hiwave debugger testCW mcp xj Dre Mutinvcyconero PY By Full Chip Simulation P amp E Multilink Cyclone Pro SofTec HCSO8 Code Data W HCS08 Serial Monitor 0 0e y M main c 0 0 o af H Includes 0 oO 86 g H Libs D 0 o zj g H Project Settings D O zj v 9 files 0 0 i Figure 23 Project Manager Connection Options 30 Installation and Operation of the Open Source BDM 6 3 3 Hiwave Debugger Options with Open Source BDM Once the OpenSourceBDM GDI DLL is configured and the debugger is open the hiwave debugger and OpenSourceBDM GDI DLL provide full featured functionality provide
12. R5CA Radial Lead C4 C6 C17 C19 399 2054 ND 4 Resistor 10 1 4W 5 Axial Lead R2 R3 10QBK ND 2 Resistor 470K 1 4W 5 Axial Lead R18 R19 470KQBK ND 2 Resistor 10M 1 4W 5 Axial Lead R10 10MQBK ND 1 Resistor 470 1 4W 5 Axial Lead R11 470QBK ND 1 Resistor 47 1 4W 5 Axial Lead R22 R23 47QBK ND 2 Resistor 1 5K 1 4W 1 Axial Lead R20 1 5KXBK ND 1 Resistor 10K 1 4W 5 Axial Lead R21 R8 10KQBK ND 2 LED Green Round 5mm 7113 4 Fairchild HLMP3950A Radial Lead D3 HLMP3950AFS ND 1 USB Connector Type B PCB Tyco 292304 1 Through Hole PCB S1 A31725 ND 1 Power Connector 2 Pin Terminal Blk On Shore Tech ED555 2 Through Hole PCB J1 ED1514 ND 1 Dual Row Header 22 Pin Molex Waldom Electronics Corp Through Hole PCBJP2 J2 WM6822 ND 1 Single Row Header 9 Pin Molex Waldom Electronics Corp Through Hole PCB JP1 JP3 JP4 JP5 WM6509 ND 13 Open Source BDM Interface Users Manual 3 0 JB16 USB BDM Firmware The HC908JB16 firmware was developed with the 3 1 special edition version of the CodeWarrior Development Studio for HCSO8 The project also works with the 5 0 special edition version The special edition provides a free solution for developing and debugging the Open Source BDM project 3 1 Firmware Description The CodeWarrior Project Manger window for the HC908JB16 firmware project is illustrated in Figure 9 The source files are organized so the firmware is delineated into logical blocks including e
13. USB Block e Command Processing Block e BDM Block ixl xi bdm_light mcp bdm_light la N y B gt Files Link Order Targets AB MC68HC908JB16 h AB MC68HC908JB16 C AB StartO8 c AB usb c AB usb h AB bdm c AB bdm h AB led h AB cmd_processing c AB cmd_processing h AB commands h Ea Prim Libs AB ansiti lib 9 Debugger Project File 9 Debugger Cmd Files 23 files ee o o h H HS Hl ba ba ba ba ba ba ba be be be be be be be be be be be E Figure 9 Open Source BDM CodeWarrior Project Manager 14 main c h Command h cmd_processing c h bdm c h usb c h JB16 USB BDM Firmware Main program Provides command code use within the USB messages Decodes USB messages and commands into BDM commands conform to the BDC This source code calls functions from bdm c h Provides tx rx function to driver JB16 ports controlling the targets BKGD pin Time critical code uses assembly code Provides function for USB communication using endpoint 0 and endpoint 2 3 2 Programming Firmware into HC908JB16 Before a computer can recognize the Open Source BDM interface as a valid USB peripheral the Open Source BDM firmware requires downloading into the HC908JB16 microprocessor The following text describes programming of a blank HC908JB16 using the USB interface Programming the HC908JB16 using the USB interface use
14. ace SCI module System protection features Optional computer operating properly COP reset Optional Low voltage detection with reset IRQ interrupt pin with internal pull up and Schmidt trigger input Open Source BDM Interface Users Manual 2 1 2 MC68HC908JB16 USB Open Source BDM is designed to use USB as the means of talking to the computer because e USB provide plug and play functionality e USB can provide power to the Open Source BDM PCB and the target avoiding the requirement of an additional power supplies By routing the USB power to the BDM connector the Open Source BDM PCB can also provide 5 0V power to the target board The LS USB peripheral of the MC68HC908JB16 provides sufficient USB functionality to facilitate the Open Source BDM operations The MC68HC908JB16 USB features include e 1 5Mbps data rate e On chip 3 3V regulator e Three Endpoints Endpoint 0 with 8 byte transmit buffer and 8 byte receive buffer Endpoint 1 with 8 byte transmit buffer Endpoint 2 with 8 byte transmit buffer and 8 byte receive buffer 2 1 3 MC68HC908JB16 Development e The development environment and the hiwave debugger looks the same for both HC08 and HC S 08 e The development environment is available free of charge for the size of project 2 2 Open Source BDM PCB The schematics are provided for the Open Source BDM PCB in Figure 7 The schematics provide details of the power and clocking connections for the Open Sou
15. d below The folowing options are found in the OpenSourceBDM menu Show status dialog box Reset to normal command option Select derivative option Detection and indication of target frequency changes Auto derivative selection Otherwise operation for the hiwave debugger remains unchanged from other debugger interfaces Figure 24 illustrates the hiwave program opened and configured for the Open Source BDM debugger interface shown by the hiwave menu bar with menu entry call Open Source BDM 1 True Time Simulator amp Real Time Debugger File View Run Open Source BDM Component Command Window Help Command Files HCSO8 A EF HX BEEF SP BEEF ox Auto Sy o Ei xi OO PT fae os 2 in i 2 Link To Target As Figure 24 Hiwave Program Opened and Configured 31 Open Source BDM Interface Users Manual 6 4 Programming and Erasing Flash with Open Source BDM Using the Open Source BDM is no different than using other debugger development tools The basics steps for configuration and operation of the Open Source BDM for programming and debugging a target system are 1 2 Build or otherwise obtain the Open Source BDM PCB Configure the debugger hardware for the Open Source BDM PCB See Open Source BDM PCB HCS08 Configuration Section 6 1 1 Connect the debugger hardware as shown in Figure If necessary install the debugger hardware windows drivers See Installing Windows Open So
16. d command is executed the Load Executable File dialog box opens 34 Installation and Operation of the Open Source BDM Load Executable File a zi x Look in bin gt ef EB f P amp E_FCS abs E P amp E_ICD abs E SofTec abs File name Files of type Executables abs elf Cancel m Advanced Commands Load Code Load Symbols Verify Code r Open and Load Code Options 7 Automatically erase and program into FLASH and EEPROM Verify memory image after loading code Complete image First byte of each loaded black faster JV Run after successful load I Stop at Function Figure 28 Load Executable File Dialog Box 3 The user must navigate to the file that will be used to program the part and select it 4 Before pressing the Open Button the Automatically erase and program into FLASH and EEPROM checkbox must be checked To make the Automatically erase and program into FLASH and EEPROM option the default setting for a project the user must configure the debugger accordingly These steps are provide Select File gt Configuration from the menu 2 The Preference dialog box opens 3 Select the Load Tab 35 Open Source BDM Interface Users Manual LI i x Environment Load N aa a E AA A To specify affected memory block click here Advanced Verify memory image after loading code Complete image First byte of each load
17. d non zero on failure The register values are filed into user allocated structure of the following format typedef union struct unsigned int pc unsigned int sp unsigned int ix unsigned int iy unsigned int d unsigned int ccr hel2 struct unsigned int pc unsigned int sp unsigned int hx unsigned int a unsigned int ccr hes0O8 registers_t void OpenSourceBDM_write_reg_pc unsigned int value Writes a new value into the PC target register void OpenSourceBDM_write_reg_sp unsigned int value Writes a new value into the SP target register void OpenSourceBDM_write_reg_x unsigned int value Writes a new value into the H X S08 target register void OpenSourceBDM_write_reg_d unsigned int value Writes a new value into the A S08 target register void OpenSourceBDM_write_reg_ccr unsigned int value Writes a new value into the CCR target register LIBUSB The LIBUSB is Open Source software available under combination of GNU general and lesser general public licenses The Open Source BDM DLL functions utilize the following LIBUSB API functions 23 Open Source BDM Interface Users Manual e usb_find buses e usb_find_ devices e usb close e usb open e usb get_version e usb_init e usb_control_msg e usb _ bulk write e usb_bulk_read 5 0 Erasing and Programming Algorithms Other aspects of the development tool system are the erasing and programming algorithms Before a new program can be
18. ddress breakpoint built into BDC Oscillator runs in Stop mode when BDC is enabled COP watchdog disabled while in Active Background mode Features of the debug module DBG include Two trigger comparators Two address read write R W or One full address data R W Flexible 8 word by 16 bit first in first out FIFO buffer for capture information change of flow addresses or event only data Two types of breakpoints Tag breakpoints for instruction opcodes and force breakpoints for any address access Nine trigger modes 1 2 Scope of the User Manual This documentation describes the Open Source BDM solution The description provides sufficient detail enabling the Open Source community to update change and maintain the Open Source BDM This user manual describes the the organization and operation of the following Open Source BDM Generic Debug Instrument GDI DLL plug in for the CodeWarrior hiwave debugger Open Source BDM interface DLL and USB driver libusb lib HC908JB16 USB BDM firmware Open Source BDM PCB hardware 1 3 Open Source BDM Overview While using the Open Source BDM supplemental understanding of a debugger pod may be required with possibly more user maintenance to provide a low cost alternative for development tools The Open Source BDM software and hardware were developed to support existing and future HCS08 devices It is designed to provide maximum accuracy and performance for HCS08 devices Ope
19. ding downloading of user code into the Open Source BDM Interface Users Manual microcontroller s on chip flash Programming and debugger functionality is made possible by the HCS08 microcontrollers Background Debug Controller BDC and In Circuit Emulator ICE Debug DBG modules 1 1 About the HCS08 BDC ICE Debug Module HCS08 microcontrollers contain a single wire background debug interface supporting in circuit programming of on chip nonvolatile memory and sophisticated non intrusive debug capabilities The BKGD pin on HCS08 devices provides this single wire background debug interface to the on chip BDC and ICE Debug modules See the Development Tools chapter of any HCS08 data sheet for more information about both the BDC and ICE Debug modules While the interface is single wire typically a 6 pin connector a BDM port is used to interface with the target Figure 2 depicts the 6 pin BDM port BKGD 1 2 GND NO CONNECT 3 4 RESET NO CONNECT 5 6 voo Figure 2 Target 6 Pin Connector for BKGD Pin The primary function of this pin is for bidirectional serial communication of active background mode commands and data During reset this pin is used to select between starting in active background mode or starting the user s application program Additionally this pin requests a timed sync response pulse allowing a host development tool to determine the correct clock frequency for background debug serial communications
20. e Open Source BDM PCB to support other targets besides HCS08 devices e Double side PCB uses mostely through hole design for ease of assembly e PCB can optionally supply 5 0V power to the MCU target board e PCB has an optional 16 pin MONO8 header to program the JB16 Top Side Bottom Side Figure 5 Open Source BDM PCB 2 1 MC68HC908JB16 Overview The Open Source BDM is based on MC68HC908JB16 MCU from Freescale The MC68HC908JB 16 provides e Relatively low cost HC08 A low speed USB 2 0 compatible interface e Surface mount 28 pin SOIC package Figure 6 provides quick reference of the MC68HC908JB16 pinout Open Source BDM PCB Hardware and MC68HC908JB16 VSS V gt OSC1 PTAD KBAO OSC2 PTAIKBA1 VREG PTA2IKBA2 VDD PTAZ KBAS PTDD PTEO TCLK PTD1 PTE2 T2CH01 PTD2 PTA4IKBA4 PTD3 PTASIKBAS PTD4 PTABIKBAG PTE1 T1CH01 PTATIKBAT TE3 D PTDS PTE4 D PTC 1 RxD PTCOTxD C Ra Figure 6 MC68HC908JB16 Pin Out Other MC68HC908JB16 Features High performance M68HC08 architecture Low power design fully static with Stop and Wait modes 6MHz internal bus frequency 16 384 bytes of on chip FLASH memory with Security1 feature 384 bytes of on chip random access memory RAM Up to 21 general purpose input output I O pins Two 16 bit 2 channel timer interface modules TIM1 and TIM2 Universal Serial Bus specification 2 0 low speed functions In circuit programming capability using USB communication Serial communications interf
21. ed block faster V Run after successful load Stop at Function Cancel Help Figure 29 Preferences Dialog Box Check the Automatically erase and program into FLASH and EEPROM checkbox Close Preference dialog box by pressing the OK button Select File gt Save Configuration from the menu Next time auto erase and flash functions will be performed by default NDNA 6 4 2 2 Using the Flash Command 1 Select Open Source BDM gt Flash from the menu 2 The Non Volatile Memory Control dialog box opens 36 oo es OQO Non Yolatile Memory Control i 3 l Installation and Operation of the Open Source BDM x m Configuration I Save and restore work space content File C Program Files Freescale C W08 V 5 0 prog FPP mcul 020 fpp JV Auto select according to MCUID 01020 Browse MCU speed 3 99 MHz m Modules Start End 00001860 O0QOFFFF Name State ane Enable Disable Programmed Protect U nprotect Erase OK Help Cancel Figure 30 Non Volatile Memory Control Dialog Box Press the Select All button Press the Erase button Press the Load button When the load button is pressed the Load Executable File dialog box opens The user must navigate to the file that will be used to program the part and select it Pressing the Open button programs the part 37 Open Source BDM Interface Users Manual Load Executable
22. function succeeds there is no need to set the BDM communication speed as itis measured automatically unsigned char OpenSourceBDM_target_reset target_mode_e target_mode Resets the target MCU to normal or special mode target_mode can be either SPECIAL_MODE or NORMAL_MODE Returns 0 on success and non zero on failure reset pin stuck to ground etc unsigned char OpenSourceBDM_bdm_sts bdm_status_t bdm_status bdm_status is a pointer to allocated structure the function fills with current state of BDM communication Returns 0 on success and non zero on failure The structure has the following format typedef struct ackn_state_e ackn_state reset_state_e reset_state connection_state_e connection_state bdm_status_t ackn_state can be either ACKN target supports ACKN BDM feature or WAIT target does not support ACKN BDM feature reset_statecan be either RESET_INACTIVE no reset activity detected or RESET_DETECTED target was reset since the last call reset_state defaults to RESET_INACTIVE after each call connection_state can be NO_CONNECTION no target MCU detected SYNC target supports the SYNC BDM feature or MANUAL_SETUP BDM speed was set up by calling OpenSourceBDM_set_speed see below 21 Open Source BDM Interface Users Manual unsigned char OpenSourceBDM_target_go void Starts target code execution from current PC address Returns 0 on success and non zero on failure unsigned char OpenSourceBDM_tar
23. get_step void Steps over a single target instruction Returns 0 on success and non zero on failure unsigned char OpenSourceBDM_target_halt void Brings the target into active background mode i e debug mode with user code execution halted Returns 0 on success and non zero on failure unsigned char OpenSourceBDM_set_speed float crystal_ frequency Sets the BDM communication speed crystal_frequency is crystal or external source frequency in MHz Returns 0 on success and non zero on failure It is essential to provide frequency accurate at least to two decimal places in MHz float OpenSourceBDM_get_speed void Returns crystal or external source frequency of the target in MHz unsigned char OpenSourceBDM_read_byte unsigned int address Reads one byte from memory at the supplied address void OpenSourceBDM_write_byte unsigned int address unsigned char data Writes one byte to memory at the supplied address void OpenSourceBDM_read_block unsigned int address unsigned int count unsigned char data Reads count bytes from address address The data is written to a user supplied buffer void OpenSourceBDM_write_block unsigned int address unsigned int count unsigned char data Writes count bytes to address address The data is take from a user supplied buffer 22 Open Source BDM PC Software unsigned char OpenSourceBDM_read_regs registers_t registers Reads contents of target registers Returns 0 on success an
24. he hiwave debugger does not have obvious support for the Open Source BDM A patch is planned for the CodeWarrior version 5 0 Studio adding more visible Open Source BDM support This section describes configuration of the hiwave for the Open Source BDM with and without the patch to add Open Source BDM support The procedure detailed in this section explains how to configure the hiwave debugger to work with the Open Source BDM interface Please be certain to download the latest version of the tools from Metrowerks The debugger interface of older versions do not support the required features The Open Source BDM was tested with the minimum required debugger version 6 1 6 3 1 Operation Without the CW Service Patch Even without the Open Source BDM patch for the CodeWarrior HCS08 Studio the hiwave debugger can be configured to select the OpenSourceBDM GDI DLL using the set gdi command in the Debugger command window illustrated in Figure 20 True Time Simulator amp Real Time Debugger File view Run MultilinkCyclonePro Component Command Window Help osal sele kc Lcd eed a cad cad od ed ol Eomma E Error The debugger is currently not able to run due to loss of contact with hardware No Link To Target in gt set gdi Figure 20 set gdi Command 28 Installation and Operation of the Open Source BDM When the set gdi command is executed the GDI Setup DLL dialog box opens To use the Open Source BDM select the Browse b
25. ice 4 Open USBICP exe when prompted for an IMP file select jo16_icp_me imp 5 Select Erase Flash 6 If Problems persist with In Circuit Programming to update the firmware the best solution is to replace the JB16 unit with a blank part This will ensure that an update to the firmware can be completed The Firmware is now removed The steps outlined in programming the firmware into the JB16 can be used to update the firmware Note Remember to remove R20 Open Source BDM PC Software Note Firmware installed on Alpha Units Boards Pre Programmed with the firmware does not contain the ability to do this 4 0 Open Source BDM PC Software 4 1 Overview This section describes the Open Source BDM solution PC software components These components include e Open Source BDM Generic Debug Instrument GDI DLL plug in for the CodeWarrior hiwave debugger e Open Source BDM interface DLL e USB driver libusb lib Figure 14 illustrates these software components and a simplification of their interfaces Open Source BDM GDI driver DLL only object code available Open Source BDM USB driver DLL source code available LIBUSB onttp ibusb sourceforge net Figure 14 Open Source BDM Windows PC Software and Interfaces 4 2 Open Source BDM GDI DLL The Open Source BDM GDI DLL plug in for the CodeWarrior hiwave debugger is only available as a binary file No source code is provided The GDI DLL for the CodeWarrior hiwave debugger is c
26. n the Open Source BDM hardware uses low cost components and is very simple to assemble Unassembled PCB cost approximately under five U S dollars and the components can also be obtained for less than U S five dollars depending on volume Subsequent sections provide a detailed description of both the Open Source BDM hardware and software 1 4 Open Source BDM Block Diagram To better understand the implementation of the Open Source BDM Figure 3 delineates the Open Source BDM solution into its most basic components The diagram illustrates part of the Open Source BDM IP residing on the PC host for the debugging software and some resides on the Open Source BDM PCB At the time of release the Open Source BDM is supported by the version 5 0 release of CodeWarrior Development Studio for Freescale HC S 08 Microcontrollers The Studio provides both a software development IDE and a debugger Introduction to Open Source BDM Open Source BDM GDI driver DLL only object code available Open Source BDM USB driver DLL source code available LIBUSB onttp ipusb sourceforge net USB cable USB BDM Firmware source code available BDM 6 pin cable with optional 5V target power C Open Source BDM SW Drivers EE User Program Debug Target Interface E Open Source BDM PCB Figure 3 Block Diagram Figure 3 illustrates five primary components four software in nature and one hardware these are itemized below All of the software components are
27. n Source BDM is compatible with CodeWarrior Studio HCS08 version 5 0 and currently supports the following HCS08 families Open Source BDM Interface Users Manual e GB60 e AW6 e QG8 e RCx As other HCS08 families are developed and released the open source community may have to modify the Open Source BDM along with installation of CodeWarrior Studio HCS08 version 5 0 service packs Other features of the Open Source BDM are e Open source distribution e Low cost development tools e Designed for the modern and widely available USB interface e Firmware developed with the HCS08 CodeWarrior Special Edition version e Supports targets with operating voltages from 1 8 to 5 0V e Supports target bus speeds from 1 0 to 2OMHz e Double side PCB uses mostly though hole design for ease of assembly e PCB can optionally supply 5 0V power to the MCU target board e PCB has an optional 16 pin MONO8 header to program the JB16 e PC USB DLL drivers source code is provided in ANSI C e JB16 firmware source is mostly C with some assembly for time critical operations e Firmware can be flash programmed using USB and Freescale interface See AN2399 these procedures are documented within this document e Windows USB drivers included using Open Source LIBUSB USB drivers e Uses a JB16 MCU with 12MHz crystal clock source e Documented API for easy integration into debuggers As indicated all the Open Source BDM source code is provided without charge In additio
28. nSourceBDM_JB 16firmware bdm_light_Data bin C md 3 prm B Sources E Q OpenSourceBDM_PCsoftware B dll_bin O gdi_dll_bin O Release Files C OpenSourceBDM_GDI_DLL O OpenSourceBDM_508_WinDriver B OpenSourceBDMFirmware Figure 4 Unzipped Open Source BDM Package 1 6 Support and Licensing Open Source BDM is not supported by Freescale it is open source Any bugs enhancements or support questions should be addressed through the Open Source BDM forum Open Source BDM has been thoroughly tested but there are no guarantees about error free operation All of the work with exception of the GDI DLL is available to anyone under the GNU general public license The Open Source BDM is a deriviative project of the TBMDL project 2 0 Open Source BDM PCB Hardware and MC68HC908JB16 Photos of the Open Source BDM PCB top and bottom sides are provided in Figure 5 The bottom side shows the MC68HC908JB16 used to decode incoming USB messages into BDC commands and then bit bang the BDC commands to a target The Open Source BDM PCB is designed with many desirable features making it a robust development tool The following list is a summary of those features e Based on MC68HC908JB16 MCU from Freescale with a 12MHz crystal e Provides circuitry to facilitate Firmware upgrades of the MC68HC908JB16 e USB interface with a type B USB connector Open Source BDM Interface Users Manual e PCB provides optional circuitry used to update th
29. ote PCB is provided with footprint for the USB B connector This is actually in violation of the USB specification as low speed devices should have the cable hard wired to them but a detachable cable is very useful If violation of the specification is not desired solder the cable straight into the PCB 2 2 2 Response Time and Transfer Rate By the nature of the USB protocol the response time for low and full speed devices cannot be below 1ms Optimization of the communication protocol on the USB to achieve maximum throughput was tested However practical limitations caused by the Windows operating system cause additional delays Average execution times for different kinds of commands are detailed in Table 2 Table 2 Average Execution Command Times Command Type Description Average Execution Speed Short Commands which transfer up to 5 bytes of data into 3ms Open Source BDM and require no return values Commands which transfer up to 5 bytes of data into Normal Open Source BDM and request up to 8 bytes of return 4ms values Data transfer Commands which transfer large blocks of data 6 7 kB s When programming the flash of the target MCU there is additional overhead created by the flash programming routines The speed is also dependant on crystal frequency the higher the better The Metrowerks hiwave debugger with Open Source BDM interface connected to HCS08 target with 4 0MHz crystal typically programs the flash at
30. rce BDM PCB These schematics also show various jumpers settings The optional circuity is not discussed in this document Besides the HC908JB16 the schematic of the Open Source BDM interface shows several main parts e A USB interface with jumper options Options to program the HC908JB16 Options for standard Open Source BDM operation e BDM interface driver based on 74LVC1T45 buffer with tri state outputs Open Source BDM PCB Hardware and MC68HC908JB16 VCC_USB VCC_SHIFT C19 SNT4LVC1T45 zis 01u install these jumpers at the unused component locations VCC USB AA C BDC_RESET_VPP Re ON 10K This resistor may be stuffed in the R8 position and a jumper soldered from the end opposite the VCC_USB side to pin 1 on JP5 lt LED_GREEN lt VCC_SHIFT lt BDC_POWER MC68HC908JB16_28SOIC Noles 1 R20 must be disconnected to allow In Circuit Programming ICP Make provisions for removing this resistor when ICP is required A suggested method would be to use socket pins from an IC socket in at least one of the pads for this resistor Open Source S08 BDM Pod le A Date December 21 2005 Sheet 1 of 1 Figure 7 Open Source BDM Schematic 2 2 1 USB interface Details A 1 5 KQ 1 pull up resistor is provided on D USB signal A jumper is added to the pull up resistor in order to assist in the ICP programming of the JB16 using techniques from AN2399 11 Open Source BDM Interface Users Manual N
31. reated partially based on information not available in the public domain The license attached to these files does not allow disclosure of the file s source code The Open Source BDM takes advantage of the CodeWarrior version 5 0 Degugger s Generic Debug Instrument GDI protocol interface Tasking Incoporated provides more detailed information about the GDI Open Interface Specification see http www tasking com resources technologies debuggers gdikdi the Tasking specification is publicly available Open Source BDM Interface Users Manual 4 3 Open Source BDM DLL and LIBUSB The Open Source BDM DLL provides an interface between the Open Source BDM GDI DLL and the Open Source BDM firmware This section describes the API of the Open Source BDM DLL including a Windows Open Source USB drivers library LIBUSB The source code for the Open Source BDM DLL is available 4 3 1 Command h Command h provides command code use within the USB messages This file matches the command h file in the Open Source BDM firmware 4 3 2 OpenSourceBDM h c OpenSourceBDM c h provides the API functions for the Open Source BDM DLL These functions are called by the Open Source BDM GDI DLL The functions in turn call functions of LIBUSB These functions are encapsulated into the OpenSourceBDM dll OpenSourceBDM dll is a part of the Windows USB install package for the Open Source BDM The Open Source BDM DLL functions are listed and briefly described below un
32. s the techniques described in AN2399 A step by step guide is provided below 1 Unzip the USB_ICP_demo zip onto your computer Included in these files are the USB ICP drivers 3 2 1 Configuring the Open Source BDM PCB 2 Close Jumpers JP3 and JP4 Also make sure R20 is not placed This configures the JB16 for USB In Circuit Programming 3 Connect the Open Source BDM board to your computer through the USB cable 3 2 2 Installing USB ICP Drivers 4 Once the Open Source BDM board to the computer you should be prompted that a new device has been detected and the Hardware Wizard should appear Select Install from a list or specific location illustrated in Figure 10 Open Source BDM Interface Users Manual Hardware Update Wizard Tw Welcome to the Hardware Update Wizard This wizard helps you install software for Unknown Device If your hardware came with an installation CD lt 6 or floppy disk insert it now What do you want the wizard to do Install the software automatically Recommended Figure 10 Installation Wizard Screen 5 Direct the install to the folder where the USBICP files reside Your computer should now recognize a USBICP device is connected Note It may be necessary to attempt this install many times sometimes the computer will not recognize the board If this occurs try connecting reset to GND before plugging in the USB cable then releasie reset Reset and GND are acces
33. sible at the MONO8 header 3 2 3 Operation of AN2399 Flash Programming Application 6 Open USBICP exe see Figure 11 when prompted for an IMP file select jo16_icp_me imp JB16 USB BDM Firmware Select MCU eS D Profiles rlaald FSL De 4 freescale Setup Blank Check Memory Program Verify CheckSum Erase FLASH Figure 11 Flash Operation Screen Selection of the Flash operation in the above screen results in the following screen in Figure 12 Look in o PC Software x eE ff jb8icp_be imp jb16icp_me imp feo jb8icp_end imp Id64icp_be imp Ej jb12icp_be imp E jb12icp_me imp JB16ICP IMP E jb16icp_be imp File name jib1 Bicp_me imp Files of type Personal File imp hed Cancel V3 Figure 12 PC Software Section Screen Open Source BDM Interface Users Manual 7 Select File Navigate to the desired s19 file Look in bin ef File name Josbdm s1 9 Files of type sR ecord File s19 Cancel 7 Open as read only 4 Figure 13 Open Screen 8 Select Program The firmware is now installed 3 2 4 Updating the USB Firmware To update the firmware 1 Power down the board by removing the USB connection 2 Close jumper JP5 This tells the USB firmware to jump to the ICP routines upon power up 3 Connect the Open Source BDM board to your computer through the USB cable The computer should recognize the board as a USB ICP dev
34. signed char OpenSourceBDM_OpenSourceBDM_dlIl_version void Returns version of the DLL in BCD format major in upper nibble and minor in lower nibble unsigned char OpenSourceBDM_init void Initializes the USB interface returning the number of Open Source BDM devices found attached to the computer This function should be called before a device can be opened unsigned char OpenSourceBDM_open unsigned char device_no Opens communication with device number device_no First device has number 0 Returns 0 on success and non zero on failure A device must be open before any communication with the device can take place void OpenSourceBDM_close void Closes communication with currently opened device unsigned int OpenSourceBDM_get_version void Returns version of HW MSB and SW LSB of the Open Source BDM interface in BCD format 20 Open Source BDM PC Software unsigned char OpenSourceBDM_get_last_sts void Returns status of the last executed command 0 on success and non zero on failure unsigned char OpenSourceBDM_set_target_type target_type_e target_type This function sets target MCU type target_type can be either HC 72 or HCSO8 Returns 0 on success and non zero on failure unsigned char OpenSourceBDM_target_sync void Measures BDM frequency of the target using the SYNC BDM feature and connects to the target Returns 0 on success and non zero on failure no device connected or the SYNC feature not supported If this
35. tiate the programming of the target MCU flash memory This icon executes a command to open the hiwave program Metrowerks CodeWarrior File Edt View Search Project Debug Processor Expert Window Lr Dee 2 y g b NE64_OpenTCP mcp PICO ja Fies Link Order Targets i firme 3 iiaj Press DEBUG button be iiia to download application Te 2 ogia Into flash memory Figure 26 Code Warrior IDE Debug Icon 33 Open Source BDM Interface Users Manual Figure 27 illustrates the hiwave program again Selecting the Load or Flash command in the Open Source BDM menu initiates flash programming algorithms to erase and reprogram the target MCU The Load menu command will first allow a selected file to upload during the flash programming operation True Time Simulator amp Real Time Debugger File View Run OpenSource BDM Component Command Window Help HCS08 a EF E HX BEEF SP BEEF x ia1xi l i Auto Sy No Link To Target h Figure 27 Code Warrior Programmer Debugger Interface 6 4 2 Step by Step Instructions Flash Programming with the Hiwave Debugger This sections provides detailed step by step instructions for flash programming with the Hiware debugger From the Open Source BDM menu both the Flash and Load command can be used to flash program the target 6 4 2 1 Using the Load Command 1 Select Open Source BDM gt Load from the menu 2 When the loa
36. urce BDM DDL and USB Drivers Section 6 1 Develop a user application and select the desired debugger interface in the CodeWarrior IDE See Configuring the Hiwave Debugger for the Open Source BDM GDI DLL Plug in Section 6 3 Execute the command to open the hiwave debugger making certain the correct debugger interface is selected Open Source BDM See step five above The hiwave debugger opens and erases then programs the target system A manually selected file can also be used to upload into the target system See Step by step Instructions Flash Programming with the Hiwave Debugger Section 6 4 2 Debug the code using the hiwave debugger Users have access to all debugger functions including breakpoints trace program halt go program step step over step into and many other debugger command options Figure 25 illustrates the cable connections between the PC the Open Source BDM and the user target Detailed information is provided below about using the CodeWarrior IDE 32 Installation and Operation of the Open Source BDM i Open Source i BDM PCB N N N J PCB BDM 6G pin Interface User Programming Debug Target Figure 25 Cable Connections Between the PC and the Open Source BDM 6 4 1 Opening the Hiwave Debugger Once the main code is added the project code can be downloaded into the target MCU flash memory Figure 26 shows pressing the debug icon in the CodeWarrior IDE s program manger window will ini
37. utton to choose the required OpenSourceBDM_gdi dll file The GDI Setup DLL dialog box is illustrated in Figure 21 GDI DLL Setup i x Communication GDI Driver DLL Path and name of the GDI DLL Browse I Show Protocol cres Figure 21 GDI Setup DLL Dialog Box Sometimes the set gdi command does not force a change of the GDI DLL setup note the active GDI setup is shown in the debugger menu i e Open Source BDM menu option vs MultilinkCyclonePro vs MONITOR HCS08 vs Softec HCS08 This issue occurs when the Softec HCS08 debugger target is selected in the Code Warrior IDE The solutions is to NOT to select the Softec HCS08 debugger target select P amp E instead When a service patch for Code Warrior to add support for the Open Source BDM is avaiable the set gdi command is not necessary since the Open Source BDM target will be selectable from the Code Warrior IDE 6 3 2 Operation With the CW Service Patch In this case when a project is created it can be created based on the Open Source BDM connection Figure 22 illustrates the Connection Option dialog box CodeWarrior provides a Open Source BDM option in this dialog box 29 Open Source BDM Interface Users Manual HC S 08 New Project xi Wizard Map Select the derivative you would like to use Project Parameters Hos Hcso8 HCSO8AW Family E HCSO8G Family MC9S508GB32 MC9S08GB324 MC9S08GB60 Mc9S08GB604 MC9508G6T16 MC9S08GT32 MC9S08GT324
Download Pdf Manuals
Related Search
Related Contents
Samsung 简约慧洗系列 波轮洗衣机 7kg 白色 XQB70-C85W 用户手册 自然エネルギー(太陽光、風力、他) Catálogo de Sistemas y Accesorios de Amarre para Vehículos y Alen T500Air Purifier 取扱説明書(保証書付き) À 13 ans, ils siègent au Conseil général jeunes - SudOuest.fr Copyright © All rights reserved.
Failed to retrieve file