XC800 Family AP Application Note. Microcontrollers. Programming the BMI value in the XC82x and XC83x products V1.0,

Similar documents
XC800 Family AP Application Note. Microcontrollers. Capacitive-Touch Color Wheel Implementation V1.0,

Application Note, V1.0, Jul AP08049 XC886/888CLM. Migration of Flash to ROM Device: Memory Protection Configurations.

Application Note, V1.0, Aug AP08064 XC866/886/888. Safeguarding the Microcontroller under Out-of-Spec Noise Conditions.

XE166 Family AP Application Note. Microcontrollers. X E D r i v e C a r d H a r d w a r e D e s c r i p t i o n Board REV.

Application Note, V 1.1, Feb AP DAP Connector. Microcontrollers

XC2000 Family AP Application Note. Microcontrollers. XC2236N Drive Card Description V1.0,

Easy Kit Board Manual

Application Note, V 1.1, Apr AP08006 C868. Interfacing SPI/I2C Serial EEPROM with C868 Microcontroller. Microcontrollers. Never stop thinking.

XE166 Family AP Application Note. Microcontrollers. UConnect XE162N Hardware Description V1.0,

Application Note, V1.0, November AP XC2000/XE166 family. ADC Result Handling on XC2000/XE166 family of Microcontrollers.

XE164 UConnect Manual, V.1.1, February XE164 UConnect. Board REV. 2007/40. Microcontrollers. Never stop thinking.

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

AP16050 SAB C161V/K/O. Emulating an asynchronous serial interface (ASC) via software routines. Microcontrollers. Application Note, V 1.0, Feb.

Application Note, V1.3, September 2008 AP XC2000/XE166 Family. Microcontrollers

Infineon Flash Programmer Memtool for XMC1000 Family. XMC Microcontrollers January 2016

XC82x/XC83x. DMX512 Receiving Device with XC836. Application Note. Microcontrollers AP08131 V1.1,

NovalithIC H-Bridge Demo Board

Queued SSC V

Industrial PROFET. Universal Application Board User s Manual

XC2000 series Board Manual, V.1.0, June XC2000 Easy Kit. Board REV. V1.0. Microcontrollers. Never stop thinking.

XC866 Getting Started on EasyKit & Toolkits

Application Note, V3.0, June 2006 AP TC179x. TC179x Examples Collection. Microcontrollers

CRC Computation using PCP

XC2287M HOT. Solution ASC. Uses a timer triggered LED to toggle with ASC Interrupt

Scope: SW Installation: Start the Package PROG-KIT. Current. Page 1

Dual H-Bridge shield. Dual H-Bridge shield - board user manual. Shield for DC motor control with IFX9202. About this document.

Application Note No. 097

Application Note, V1.0, Feb AP LIN Application for XC164CM Using DAvE LIN Configuration tool. Microcontrollers

XMC LED current control explorer kit

XC2287M HOT. Solution GPT12. Uses a timer triggered LED s to toggle. Device: XC2287M-104F80 Compiler: Tasking Viper 2.4r1 Code Generator: DAvE 2.

AP XC2000 & XE166 Families. Design Guidelines for XC2000 & XE166 Microcontroller Board Layout. Microcontrollers

AP16051 SAB C161K/V/O. Emulating an asynchronous serial interface (ASC) via the on-chip synchronous serial interface (SSC) Microcontrollers

8-Bit AP Application Note. Microcontrollers. Microcontroller. XC878 Class B Software Library V

Application Note, V2.0, August 2007 AP08067 XC886/XC888

Application Note, V 1.0, April 2005 AP32086 EMC. Design Guideline for TC1796 Microcontroller Board Layout. Microcontrollers. Never stop thinking.

Data Logger Using XC82x/XC83x Emulated EEPROM ROM Library

Design Guideline for TC1791 Microcontroller Board Layout

AP XC16x. How to generate a successful ROM mask for XC16x microcontrollers. Microcontrollers. Application Note, V 0.1, Sep.

XC2287M HOT Getting Started Exercise 1 Get familiar with the tool chain and uses a timer triggered LED toggle

XE166 family Easy Kit

Design Guideline for TC1798 Microcontroller Board Layout

Smart High-Side Power Switch BSP742RI PG-DSO8. AEC qualified Green product (RoHS compliant)

Boot Loader for the Z51F6412 MCU

Documentation Addendum, V1.2, Aug TC Bit Single-Chip Microcontroller Delta BC-to-BE Step. Microcontrollers

Design Guideline for TC1782 Microcontroller Board Layout

Operating temperature T a

Nuvoton 4T 8051-based Microcontroller NuTiny-SDK-N78E715 User Manual

Chip Card & Security ICs SLE Intelligent 256-Byte EEPROM with Write Protection function and Programmable Security Code

SPI Protocol of the TLE941xy family

An introduction to MTV

Nuvoton 1T 8051-based Microcontroller NuTiny-SDK-N76E885 User Manual

Chip Card & Security ICs SLE Intelligent 1024 Byte EEPROM with Write Protection and Programmable Security Code

TLS202B1. Demonstration Board Manual. Automotive Power. Demonstration Board Manual. Rev. 1.0,

XC2287M HOT Solution CAN Serial Communication using the CAN. Device: XC2287M-104F80 Compiler: Tasking Viper 2.4r1 Code Generator: DAvE 2.

DC6388EMT User Manual

DC6688EMT User Manual

A Seamless Tool Access Architecture from ESL to End Product

Contents. Cortex M On-Chip Emulation. Technical Notes V

Programming in the MAXQ environment

AN5123 Application note

Implementing In-Application Programming on the ADuC702x

Security & Chip Card ICs SLE 55R04. Intelligent 770 Byte EEPROM with Contactless Interface complying to ISO/IEC Type A and Security Logic

ASCLIN Asynchronous Synchronous Interface

Release Notes for Device Access Server (DAS)

PMA71xx/ PMA51xx. Application Whitepaper. Wireless Control. SmartLEWIS TM MCU

How to use the CIC61508 Secure SPI Mode Applets Concept PRELIMINARY CIC61508, V0.9,

EEPROM Emulation with the ez80f91 MCU. Discussion

XMC1000 EEPROM emulation and data retention

Application Note TLE9252V. About this document. Application Note. Safety Recommendations Z8F

PROFET TM + Demoboard. Automotive Power. Smart High-Side Power Switch - Demoboard Description. Rev. 1.4,

3D Magnetic Sensor 2 Go - TLE493D-A2B6

AN2430 Application note

ZCRMZNICE01ZEMG Crimzon In-Circuit Emulator

ToolStick-EK TOOLSTICK USER S GUIDE. 1. Kit Contents. 2. ToolStick Overview. Green and Red LEDs. C8051F321 provides USB debug interface.

XC2287M HOT. Solution CAN_2 Serial Communication using the CAN with external CAN BUS

TLE987xQX BF-Step. BootROM User Manual. Rev. 1.4,

Smart High-Side Power Switch for Industrial Applications One channel: 1 x 1 Ω

AP Bit CMOS Microcontroller Product. Interrupt Response Time of the XC16x Family. Microcontrollers. Application Note, V 1.0, Aug.

TLx5012B 2go Evaluation Kit

XC164CS Prototype Board

Megawin 8051 OCD ICE

SPOC +2 User Manual Multichannel SPI High-Side Power Controller

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4465

Z8 Encore! XP F0822 Series

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

Keywords: maxq microcontrollers, data flash, in-application programming, in circuit programming, flash, microcontroller, MAXQ7663, MAXQ7664

78M6618 PDU1 Firmware Quick Start Guide

Application Note, V2.0, April 2010 AP16174 XE164

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

IP-48DAC channel 16-bit Digital/Analog Converter With memory Industry Pack Module PROGRAMMING MANUAL Version 1.

Flash Loader Utility for the Z8 Encore! XP MCU

Application Note No. 100

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

CEIBO FE-5131A Development System

Application Note AN V1.3 August Module with adapted driver electronics

ESD8V0L... ESD8V0L1B-02LRH. Type Package Configuration Marking ESD8V0L1B-02EL

8051 Microcontroller

Using the Z8051 MCU s USI Peripheral as an SPI Interface

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Kinetis Bootloader to Update Multiple Devices in a Field Bus Network

Transcription:

XC800 Family AP08108 Programming the BMI value in the XC82x and XC83x products Application Note V1.0, 2010-07 Microcontrollers

Edition 2010-07 Published by Infineon Technologies AG 81726 Munich, Germany 2010 Infineon Technologies AG All Rights Reserved. LEGAL DISCLAIMER THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE. Information For further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com). Warnings Due to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office. Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered.

XC82x,XC83x Revision History: V1.0 2010-07 Previous Version(s): Page Subjects (major changes since last revision) This is the first release We Listen to Your Comments Is there any information in this document that you feel is wrong, unclear or missing? Your feedback will help us to continuously improve the quality of this document. Please send your proposal (including a reference to this document) to: mcdocu.comments@infineon.com Application Note 3 V1.0, 2010-07

Table of Contents Table of Contents 1 Introduction..................................................................... 5 1.1 Overview........................................................................ 5 2 Boot Modes..................................................................... 6 2.1 Boot Mode Index.................................................................. 6 2.2 User Identification Number.......................................................... 8 2.3 Boot ROM Operating Mode......................................................... 9 2.3.1 UART Boot-Loader (BSL) Mode.................................................... 9 2.3.2 Alternate User Boot-Loader (BSL) Mode.............................................. 9 2.3.3 OCDS Mode................................................................... 9 2.3.4 User Mode (Diagnostic).......................................................... 10 2.3.5 User Mode (Productive).......................................................... 10 3 Programming the BMI value...................................................... 11 3.1 Hardware for BMI Programming..................................................... 11 3.1.1 Using a Target Board with DAP miniwiggler (JTAG/DAP/SPD V2.0)....................... 12 3.1.2 Using the Easy Kit Board......................................................... 13 3.2 Software Tools for BMI Programming................................................. 14 3.2.1 Using the DAvE-Bench s Flash loader (XC800_FLOAD) Tool............................ 14 3.2.2 Using the KEIL uvision 4 Tool..................................................... 16 3.3 Tool Links...................................................................... 17 4 Handling Tips.................................................................. 18 4.1 Program BMI via BR_UART_BSL................................................... 19 4.2 Program BMI via BR_PROG_USER_ID............................................... 20 5 Summary...................................................................... 22 Application Note 4 V1.0, 2010-07

Introduction 1 Introduction This application note is for the XC82x/XC83x products and describes the boot options entry, usage and programming methodologies. For detailed descriptions of the XC82x/XC83x products, please refer to the XC82x/XC83x User s Manual. 1.1 Overview The boot configuration for XC82x/XC83x does not depend on pin status during reset. Instead, a Boot Mode Index (BMI) configuration determines the entry to various boot modes such as User Mode, Boot-Loader (BSL) Mode and On-chip Debug (OCDS) Mode. After reset, the BMI value is taken and the respective boot mode entry is executed. The advantage of using BMI configuration is that the port pins are not dedicated for boot-up and can be used for other purposes. The BMI is configured on-device, as described in the subsequent sections of this document. Figure 1 shows an overview of boot mode entry methodologies for the XC800 family of products. XC800 Family Overview on Boot Modes Entry XC82x, XC83x XC88x, XC878, XC86x, XC85x, XC84x Boot Mode Index (BMI) Configuration Pin Configuration Figure 1 Boot Mode entry of XC800 family Application Note 5 V1.0, 2010-07

Boot Modes 2 Boot Modes The BMI and BMI values are configured on-chip using a variety of methods (refer to Chapter 3). Upon power-up, the BMI and BMI values will be evaluated to determine the boot mode execution after reset. The supported boot modes are shown in Figure 2 and are described in Section 2.3. Wait for PC Host commands UART BSL Mode ALT USER BSL Mode* run user-defined BSL code (User BSL Flash Sector, 0xFF40) RESET BMI and / BMI Evaluation OCDS Mode User Mode (Diagnostic ) Wait for PC Host commands run user code (Flash Bank 0, 0x0000) (read/write Flash possible) User Mode (Productive ) run user code (Flash Bank 0, 0x0000) (no Floader/debugger access) * Available for XC 83x 8-Kbyte Flash variant only Figure 2 Boot ROM operating mode after power-on reset 2.1 Boot Mode Index The user needs to program the BMI and BMI values to enter the respective boot mode. Devices are typically delivered with the BMI configured by default to UART Boot-Loader (BSL) Mode. BMI is introduced to verify that the BMI value is valid; i.e. (BMI + BMI + 1 = 0). Table 1 and Table 2 show the BMI and BMI values relating to different boot modes on the XC82x and XC83x respectively. Table 1 Boot Mode Index for XC82x Boot Mode 1) BMI BMI Description UART Boot-Loader (BSL) Mode 2) 00 H FF H Supports programming and erasing of Flash and 00 H 00 H XRAM via UART (full and half duplex). User Mode (Productive) 3) 10 H EF H Execution of the user code in Flash memory, starting from address 0x0000. Debugging is not supported. User Mode (Diagnostic) with SPD pin SPD_0 50 H AF H Execution of the user code in Flash memory, User Mode (Diagnostic) with SPD pin SPD_1 52 starting from address 0x0000. Debugging is H AD H supported. Corresponding SPD pin is automatically configured to allow hot-attach. Application Note 6 V1.0, 2010-07

Boot Modes Table 1 Boot Mode Index for XC82x (cont d) Boot Mode 1) BMI BMI Description OCDS Mode with SPD pin SPD_0 60 H 9F H Support debugging of the user code in the Flash OCDS Mode with SPD pin SPD_1 62 memory via corresponding single-pin DAP H 9D H (SPD). Reserved Others Others BMI values not defined above are not supported. The user should not configure undefined BMI values. 1) SPD : Single Pin DAP; 2) UART BSL Mode can be entered when BMI is 00 and BMI is either 00 or FF. 3) This mode should be used with extra care. If there is a need to re-configure the BMI after entering this mode, it will be necessary to embed an update-code in with the user code to be able to enter other modes from User Mode (Productive). For more details, refer to Section 2.3.5 and Chapter 4. Table 2 Boot Mode Index for XC83x Boot Mode 1) BMI BMI Description UART Boot-Loader (BSL) Mode 2) 00 H FF H Supports programming and erasing of Flash 00 H 00 H and XRAM via UART (full and half duplex). Alternate User Boot-Loader (BSL) Mode 3) 01 H FE H Execution of the user s own customized BSL code, at address 0xFF40. BSL code is programmed at User BSL Flash sector (0xFF40-0xFF7F). User Mode (Productive) 4) 10 H EF H Execution of the user code in Flash memory, starting from address 0x0000. Debugging is not supported. User Mode (Diagnostic) with SPD pin SPD_0 50 H AF H Execution of the user code in Flash memory, User Mode (Diagnostic) with SPD pin SPD_1 52 starting from address 0x0000. Debugging is H AD H supported. Corresponding SPD pin is User Mode (Diagnostic) with SPD pin SPD_2 54 H AB H automatically configured to allow hot-attach. OCDS Mode with SPD pin SPD_0 60 H 9F H Support debugging of the user code in the OCDS Mode with SPD pin SPD_1 62 Flash memory via corresponding single-pin H 9D H DAP (SPD). OCDS Mode with SPD pin SPD_2 64 H 9B H Reserved Others Others BMI values not defined above are not supported. The user should not configure undefined BMI values. 1) SPD : Single Pin DAP; 2) UART BSL Mode can be entered when BMI is 00 and BMI is either 00 or FF. 3) Available only in the 8-Kbyte Flash variant. 4) This mode should be used with extra care. If there is a need to re-configure the BMI after entering this mode, it will be necessary to embed an update-code in with the user code to be able to enter other modes from User Mode (Productive). For more details, refer to Section 2.3.5 and Chapter 4. Note: When BMI is not valid (i.e. BMI + BMI + 1!= 0), the default mode is UART BSL Mode, provided that the BMI is not programmed as 0x10 or BMI is not programmed as 0xEF. Under those conditions, software protection is initiated and the device will enter a deadlock situation. Application Note 7 V1.0, 2010-07

Boot Modes 2.2 User Identification Number The BMI and BMI are part of the User Identification, USER_ID. The USER_ID consists of 4-bytes of data that contain the user specific information, as shown in Table 3. To update the BMI and BMI values, the user needs to program the whole 4 bytes of USER_ID. USER_ID, Byte 0 7 6 5 4 3 2 1 0 BMI USER_ID, Byte 1 15 14 13 12 11 10 9 8 BMI USER_ID, Byte 2 23 22 21 20 19 18 17 16 RES USER_ID, Byte 3 31 30 29 28 27 26 25 24 CLKMODE_S EL PERIPHERAL S_EN RES Table 3 USER_ID USER_ID Field Byte Bits Description BMI Byte 0 [7:0] Boot Mode Index The boot option to enter User Mode, UART BSL Mode and OCDS Mode as described in Section 2.1 BMI Byte 1 [15:8] Inverse of Boot Mode Index The inverse of BMI. BMI is checked for validity with BMI. BMI is valid when BMI + BMI + 1 = 0 RES Byte 2 [23:16] Reserved Application Note 8 V1.0, 2010-07

Boot Modes Table 3 USER_ID (cont d) USER_ID Field Byte Bits Description RES Byte 3 [29:24] Reserved PERIPHERALS_EN 30 Peripherals Enable Bit 0 B Disable all peripherals defined in register PMCON1 1 B Enable all peripherals defined in register PMCON1 CLKMODE_SEL 31 Clock Mode Selection 0 B 8 MHz active mode 1 B 24 MHz active mode 2.3 Boot ROM Operating Mode The respective Boot ROM operating modes are described in this section. 2.3.1 UART Boot-Loader (BSL) Mode If the Boot-loader (BSL) mode is selected, the BSL software routines are executed and waiting for BSL commands from the PC host. By sending UART_INIT_ID, the PC host can choose to communicate with the target device via UART full-duplex or UART half-duplex. In BSL mode, the PC host can download and execute code in XRAM/Flash, erase code in Flash, program 4-byte USER_ID (which contains the BMI and BMI value), and read the CHIP_ID and USER_ID information. The overview of port pin(s) used in UART BSL Mode is shown in Table 4. Table 4 Port Settings for UART BSL Mode Device UART_INIT_ID Full/Half Duplex RXD Pin TXD Pin XC82x 0xAA Half duplex P0.6 P0.6 0x55 Full duplex P0.6 P0.5 XC83x 0xAA Half duplex P3.2 P3.2 0x55 Full duplex P3.2 P0.7 2.3.2 Alternate User Boot-Loader (BSL) Mode If the Alternate User Boot-loader (BSL) mode is selected, the user-customized BSL code in the User BSL Flash Sector will be executed. This code has to be first programmed into the 64 bytes User BSL Flash Sector, located in the program memory address range 0xFF40 to 0xFF7F, before the Alternate User BSL Mode is selected. Note: This mode is only available in the XC83x 8-Kbyte Flash variant. 2.3.3 OCDS Mode If the OCDS mode is selected, the OCDS hardware is initialized and jump to program memory address 0x0000. The device then waits for SPD commands from PC host. The user can access to full debug functionality using SPD pin. This is the recommended mode when a user starts to develop and debug their own application code. Table 5 gives an overview of the port pin(s) used in OCDS Mode. Table 5 Port Settings for OCDS Mode Device SPD Pin used XC82x SPD_0 P0.6 SPD_1 P1.0 Application Note 9 V1.0, 2010-07

Boot Modes Table 5 Port Settings for OCDS Mode (cont d) Device SPD Pin used XC83x SPD_0 P3.2 SPD_1 P0.6 SPD_2 P1.0 2.3.4 User Mode (Diagnostic) If the User Mode (Diagnostic) is selected, the Boot ROM will jump to the program memory address 0x0000 to execute the user code in the Flash memory, and the specified SPD port is automatically configured to allow debugger access. The user can stop the code and read/write to Flash using the SPD pin. This is the recommended mode when the user has completed code debugging and wants to test the code in a real application environment. The user can also update their working code using the Flash loader or debugger. Table 6 gives an overview of the port pin(s) used in OCDS Mode. Changing the BMI value to enter another boot mode should be taken into consideration, especially under scenarios, where the user code: enters Idle Mode periodically or enters Power Down Mode periodically or enables WatchDog Timer See Chapter 4 for code details. Table 6 Port Settings for User Mode (Diagnostic) Device SPD Pin used XC82x SPD_0 P0.6 SPD_1 P1.0 XC83x SPD_0 P3.2 SPD_1 P0.6 SPD_2 P1.0 2.3.5 User Mode (Productive) When User mode (Productive) is selected, the Boot ROM jumps to the program memory address 0x0000 to execute the user code in the Flash memory. The difference between User Mode (Diagnostic) and User Mode (Productive) is that User Mode (Productive) provides Flash memory protection from external access (read/write) from debugger and Flash loader. User Mode (Productive) should be used when the user has fully tested their code and no further code modification is allowed. Once the device is in User Mode (Productive), changing the BMI value to enter another boot mode could be achieved by programming a specific code embedded in the user code. This specific code is called under userdefined conditions; via an interrupt for example, or via GPIO pin values. In this specific code, the user can use one of the following instructions to change the BMI value: LJMP to BR_UART_BSL Boot ROM user routine (0xDFEA) to re-enter UART BSL Mode (Mode 6) or LCALL of BR_PROG_USER_ID Boot ROM user routine (0xDFE4) to re-program USER_ID to enter other mode Please refer to the User s Manual for the input settings for these Boot ROM user routines. For code protection purposes, the user may want to erase all the important code or data in the flash memory before executing that specific routine. See Chapter 4 for more code details. Application Note 10 V1.0, 2010-07

Programming the BMI value 3 Programming the BMI value The default Boot mode for XC82x or XC83x is UART BSL Mode. The BMI value needs to be programmed to allow the devices to work in OCDS Mode for debugging. The BMI also needs to be programmed to User Mode for running the final working application code. The following points should be considered when programming the BMI value: The VDDP of the target device should keep stable at 3V or 5V when programming the BMI value. A software reset is executed after the BMI value has been updated. Switching off the supply voltage before the software reset has occurred may cause the BMI to be updated incorrectly. No additional reset is necessary for the system to use the new BMI value. The Watchdog Timer (WDT) should be disabled before programming the BMI value, because if a WDT reset occurs when programming the value, it may cause the BMI to be updated incorrectly. Four bytes of USER_ID are to be programmed together in order to write the BMI value. Note: Great care must be taken when programming the BMI value, because a wrong or invalid BMI could cause the device to enter a deadlock situation. Software tools are available to facilitate programming the BMI value, such as the DAvE-Bench (XC800_FLOAD) tool from Infineon and the uvision 4 from KEIL. Both software tools require the following components for BMI programming: DAS DLL: a DLL driver for the software tool to call the DAS API to send SPD/UART signals through a hardware device, DAP miniwiggler. DAP miniwiggler: a USB powered device controlled by the DAS API to produce SPD/UART signals. P0.6 of XC82x and P3.2 of XC83x can function both as a UART BSL (half-duplex) pin and a SPD pin, as shown previously in Table 4 and Table 5 respectively. Therefore the DAS API supports both UART communication and SPD communication on the same pin. This feature enables the user to use the same pin to perform the following actions: Enter UART BSL Mode (default) Program the BMI value (via UART BSL Mode 6) from UART BSL Mode to OCDS Mode 1) Debug user application code in OCDS Mode via SPD interface directly The hardware setups and the software tools for programming the BMI value are described in Section 3.1 and Section 3.2 respectively. The links of the board and tools are listed in Section 3.3. 3.1 Hardware for BMI Programming This section will describe the two hardware setups that work with the Infineon DAvE-Bench (XC800_FLOAD) and KEIL uvision 4. When the user is using their own target board for BMI programming, a DAP miniwiggler setup as described in Section 3.1.1 would be needed. The XC822-TSSOP16 board (a XC822 Easy Kit board) and XC836-TSSOP board (a XC836 Easy Kit board) have the SPD wiggler integrated on-board, as shown in Section 3.1.2. Hence, the user could use the DAvE-Bench(XC800_FLOAD) or KEIL uvision 4 to change the BMI value directly on the Easy Kit board. 1) After the BMI value is changed, the device will automatically perform a software reset and boot up in OCDS Mode Application Note 11 V1.0, 2010-07

Programming the BMI value 3.1.1 Using a Target Board with DAP miniwiggler (JTAG/DAP/SPD V2.0) With the miniwiggler, a user can program the XC82x or XC83x device on the target application board by setting up the 3 pins as shown in Figure 3 and Figure 4 respectively. The DAP miniwiggler requires the VDDP (5V or 3.3V) from the target board to power the SPD signal on the DAP miniwiggler. FLOADER V5.x/ KEIL uvision 4, DAS v2.9.2 and above USB 2.0 Port miniwiggler Jtag/DAP/SPD V2.0 Pin 1 to VDDP of XC82x Pin 2 to P0.6 (SPD pin) of XC82x Pin 3 to GND of XC82x VDDP P0.6 GND XC82x device User XC82x Target board Samtec FTSH FTSH-105-01-L-DV-K, connector on target board to match the 10 pins ribbon cable connector from miniwiggler Figure 3 Hardware Setup of DAP miniwiggler with the User s XC82x Target Board FLOADER V5.x/ KEIL uvision 4, DAS v2.9.2 and above USB 2.0 Port miniwiggler Jtag/DAP/SPD V2.0 Pin 1 to VDDP of XC83x Pin 2 to P3.2 (SPD pin) of XC83x Pin 3 to GND of XC83x VDDP P3.2 GND XC83x device User XC83x Target board Samtec FTSH FTSH-105-01-L-DV-K, connector on target board to match the 10 pins ribbon cable connector from miniwiggler Figure 4 Hardware Setup of DAP miniwiggler with the User s XC83x Target Board Application Note 12 V1.0, 2010-07

Programming the BMI value 3.1.2 Using the Easy Kit Board The SPD wiggler is integrated on the XC822/XC836 Easy Kit board. The SPD pin of the on-board wiggler is connected to P0.6 of XC822 Easy Kit board and P3.2 of the XC836 Easy Kit board, by using the jumper setting at the COM_SEL, as shown in Figure 5 and Figure 6 respectively. Connect to SPD pin of target board Connect to GND pin of target board FLOADER V5.x/ KEIL uvision 4, DAS v2.9.2 and above USB 2.0 Port Custom 5V 3.3V USB Supply select SPD UART Easy Kit XC822-TSSOP16 P0.6 SPD GND SPD/ UART/ UART- BSL select reset COM_SEL VDDP XC822MT P0.6 / SPD P0.5 / TxD P1.0 / TxD&RxD Figure 5 Hardware Setup using the XC822 Easy Kit Board Connect to SPD pin of target board Connect to GND pin of target board FLOADER V5.x/ KEIL uvision 4, DAS v2.9.2 and above Custom 5V 3.3V Supply select P3.2 GND SPD reset VDDP USB 2.0 Port USB SPD UART Easy Kit XC836-TSSOP SPD/ UART- BSL select COM_SEL XC836MT P3.2 / SPD /RXD P0.7 / TxD Figure 6 Hardware Setup using the XC836 Easy Kit Board Note: The XC822/XC836 Easy Kit board can also act as SPD wiggler for connection to the user target board, enabling SPD debug functions and/or single-pin half-duplex UART BSL functions. By acting as SPD wiggler, the Easy Kit board can be used to program the BMI value of the XC82x/XC83x device on the user target board; i.e. there is no need to purchase a separate wiggler. When using it as SPD wiggler, the XC822/XC836 device on the Easy Kit board has to be removed. Application Note 13 V1.0, 2010-07

Programming the BMI value 3.2 Software Tools for BMI Programming Software tools are available for BMI programming. The DAvE-Bench (XC800_FLOAD) tool from Infineon for example, and uvision 4 from KEIL, are described in Section 3.2.1 and Section 3.2.2 respectively. 3.2.1 Using the DAvE-Bench s Flash loader (XC800_FLOAD) Tool The section describes using the DAvE-Bench (XC800_FLOAD) tool from Infineon to program the BMI value, depending on the current XC82x/XC83x boot mode. Please refer to the Hardware manual in XC82x/XC83x Easy Kit CD Content of the XC82x/XC83x Easy Kit website for the COM_SEL jumper setting. First, run the DAvE-Bench Application and click on the XC800_FLOAD icon as shown in Figure 7. The XC800_FLOAD application will be executed and the user should follow the procedures shown below for BMI value programming. DAvE-Bench (XC800_FLOAD) procedure to program BMI in UART BSL Mode: Select XC800_FLOAD Select Protocol -> UART or JTAG/SPD Select Physical Interface: For UART protocol, select between Full Duplex and Half Duplex/Ignore Echo 1) For JTAG/SPD protocol, UDAS/JTAG over USB is the only option available 2) Select Target Device -> XC83x-2F (for example) Enter COM port number if UART protocol is selected Click Write User ID button Select Boot Mode, Peripherals Enable/Disable and Clock Mode once a connection is established successfully Click OK after selection is made -> Wait for BMI switched Message DAvE-Bench (XC800_FLOAD) procedure to program BMI in User Mode (Diagnostic) or OCDS Mode: Select XC800_FLOAD Select Protocol -> JTAG/SPD 2) Select Physical Interface -> UDAS/JTAG over USB Select Target Device -> XC83x-2F (for example) Click Write User ID button Select Boot Mode, Peripherals Enable/Disable and Clock Mode once a connection is established successfully Click OK after selection is made -> Wait for BMI switched Message Note: If the XC82x/XC83x is in UART BSL Mode and the selected physical interface is JTAG/SPD, a message box appears asking the user for permission to switch the device to OCDS mode SPD_0. Select Yes. The DAvE-Bench (XC800_FLOAD) GUI for programming of the BMI value is shown in Figure 7. 1) This selection works with the Figure 5 and Figure 6 setup but COM_SEL on the Easy Kit board must be set to UART BSL Mode. 2) This selection works with the Figure 3, Figure 4, Figure 5 and Figure 6 setup, but COM_SEL on Figure 5 and Figure 6 must be set to SPD mode. Application Note 14 V1.0, 2010-07

Programming the BMI value 1. 2. 3. 4. Figure 7 DAvE-Bench (XC800_FLOAD) GUI for Programming the BMI Value Application Note 15 V1.0, 2010-07

Programming the BMI value 3.2.2 Using the KEIL uvision 4 Tool This section describes using the KEIL uvision 4 tool to program the BMI value. KEIL uvision 4 works with Figure 3, Figure 4, Figure 5, and Figure 6 setup, but COM_SEL for Figure 5 and Figure 6 setup must be set to SPD mode. Please refer to the Hardware manual in the XC82x/XC83x Easy Kit CD Content of the XC82x/XC83x Easy Kit website for the COM_SEL jumper setting. The GUI of KEIL uvision 4 of programming of the BMI value is shown in Figure 8. uvision 4 procedure to program BMI: Click on Debug Tab. Select Use: -> Infineon DAS Client for XC800 Click Setting button -> Infineon XC800 DAS Driver Setup GUI Select DAS Server -> UDAS Select Device: -> XC800-Family Click BMI (XC82x/XC83x only) Tab -> Choose BMI selection for desired boot mode Click Set BMI now button 1. 2. 3. Figure 8 KEIL uvision 4 GUI for Programming the BMI Value Application Note 16 V1.0, 2010-07

Programming the BMI value 3.3 Tool Links For more information on using the software tools, miniwiggler, boards and driver, please refer to the links shown in Table 7. Table 7 BMI Programming Tools Tool Version Link DAvE-Bench V1.0.2 and above www.infineon.com/davebench (Flash loader XC800_FLOAD) KEIL uvision 4 V9.01 and above www.keil.com/demo/eval/c51.htm DAP miniwiggler V2.0 www.infineon.com/miniwiggler Easy Kit XC82x V1.0 and above www.infineon.com/xc82x-easykit Easy Kit XC83x V1.0 and above www.infineon.com/xc83x-easykit DAS DLL V2.9.2 and above www.infineon.com/das Application Note 17 V1.0, 2010-07

Handling Tips 4 Handling Tips In UART BSL Mode, the BMI can be easily programmed via UART BSL Mode 6 (using the XC800_FLOAD tool). In OCDS Mode or User Mode (Diagnostic), the BMI can be updated through software tools (XC800_FLOAD and Keil uvision 4, for example) as described in Chapter 3. However, to program the BMI in User Mode (Productive), an update-code needs to be embedded in the user code. The update-code, whether in User Mode (Productive) or User Mode (Diagnostic), must take into account those cases where the user code: enters Idle Mode periodically enters Power Down Mode periodically enables WatchDog Timer (WDT) In User Mode (Diagnostic), trigger of the SPD pin is not effective when the device is in Idle Mode or Power Down Mode. An interrupt, for example, can be triggered to exit Idle Mode or Power Down Mode permanently, or to disable the WDT before programming the BMI value. The flow is: Include the update-code in the user code with user-defined condition Compile and get hex file Program the user code in Flash Program BMI to User Mode (Productive) No external access on XRAM/Flash is allowed once BMI is programmed to User Mode (Productive) To update the BMI or the user code for upgrading process, trigger the user-defined condition Depending on the update-code, BMI will be programmed or UART BSL Mode will be entered for updating the user code or the BMI value The user-defined condition could be interrupt or polling based, or can use any other method that the user deems applicable to their application. The update-code is either: LJMP to BR_UART_BSL Boot ROM user routine (0xDFEA) to re-enter BSL Mode (Mode 6) or LCALL of BR_PROG_USER_ID Boot ROM user routine (0xDFE4) to re-program USER_ID to enter other mode An comparison of update-code methods is shown in Table 8. The safer approach, LJMP to BR_UART_BSL is recommended. This method also allows the user to update the user code without changing the BMI value. Note: The BMI value should be changed on entering UART BSL Mode, instead of updating the user code, especially when downloading untested code. This is to prevent the download of the user code that does not include the update-code necessary to re-program BMI or re-enter UART BSL Mode. Table 8 Comparison of Update-Code Methods BR_UART_BSL The user can access device via UART BSL mode immediately after the LJMP without changing the BMI value. External access only via UART pin. Refer to Table 4. Unintentional execution will not affect the BMI value. If BMI is unchanged, User Mode (Productive) is reentered after a reset. BR_PROG_USER_ID BMI value is changed accordingly. External access depends on BMI setting. Refer to Section 2.3. Unintentional execution will affect the BMI value. Device can only boot up properly with valid BMI configured. There must be a user-defined condition to ensure this LCALL cannot be unintentionally executed. Application Note 18 V1.0, 2010-07

Handling Tips 4.1 Program BMI via BR_UART_BSL This section includes example code which uses an interrupt to enter UART BSL Mode via the BootROM user routine BR_UART_BSL. The code uses P2.0 to emulate as a Reset pin (falling edge) to trigger the external interrupt 0 where a softreset will be executed. P2.0 and P2.1 are checked when the device restarts. When the condition is met, the BR_UART_BSL user routine is called and UART BSL Mode is entered. The user can program the BMI or update the user code in Flash via XC800_FLOAD. Note: For code protection purpose, the user may want to erase all the important code or data in the flash memory before re-entering UART BSL Mode. Therefore, this code must be located at a different Flash sector so that other important code or data can be erased, while this code remains. This code ENTER_UART_BSL() can be located at the smallest Flash sector. Note: This BR_UART_BSL user routine does not return back to the user code. unsigned int idata j=0x1800; void ENTER_UART_BSL (void) { // This code located at different flash sector // Erase important code or data if needed before entering UART BSL Mode... // Enter UART BSL Mode to program BMI or update user code in Flash EA = 0; // disable interrupts NMICON = 0x00; // disable NMIs SP = 0xE0; // Configured SP BR_UART_BSL(); // start UART BSL } void main(void) { if( (!(P2_DATAIN & 0x02)) && (P2_DATAIN & 0x01) ) { while (--j); // impose delay for system to be ready if(!(p2_datain & 0x02) ) //Only enter BSL when P2.1 is low { ENTER_UART_BSL(); } } MAIN_vInit(); //user code begins } void INT_vInit(void) { NMICON = 0x00; //NMI Control Register IEN0 = 0x01; // interrupt enable register 0 IEN1 = 0x00; // interrupt enable register 1 EXICON0 = 0xF3; // External interrupt Control Register 0 SFR_PAGE(_su3, nosst); // switch to page 3 without saving MODPISEL1 = 0x18; // peripheral input select register 1 SFR_PAGE(_su0, nosst); // switch to page 0 without saving }// End of function INT_vInit Application Note 19 V1.0, 2010-07

Handling Tips void INT_viExt0(void) interrupt EXT0INT { // USER CODE BEGIN (IR_IsrExt0,2) // emulate Reset pin an falling edge SFR_PAGE(_su1, nosst); while (!(P2_DATAIN & 0x01) ); MAIN_vSoftReset(); // USER CODE END... } // End of function INT_viExt0 4.2 Program BMI via BR_PROG_USER_ID This section includes example code which uses an interrupt to program the BMI value directly via the BootROM user routine BR_PROG_USER_ID. The code uses P2.0 to trigger the external interrupt 0, which calls this routine. In this example, the BMI value is programmed to enter OCDS Mode. Unintentional execution of the BR_PROG_USER_ID user routine will affect the BMI value and the device may not be able to boot up properly because of an invalid BMI. Therefore a user-defined condition must be included to prevent an unintentional jump to this routine. An extra password (PASSWORD_BMI) is included in this example. Note: For code protection purposes, the user may want to erase all the important code or data in the flash memory before re-entering UART BSL Mode. Therefore, this code must be located at a different Flash sector so that other important code or data can be erased, while this code remains. This code PROGRAM_BMI() can be located at the smallest Flash sector. Note: The user should take care of the WatchDog service routine and to disable the WDT before calling this user routine, as it does not return back to the user code. A soft reset will be triggered by this user routine and the device will boot up based on the programmed BMI value. unsigned char xdata PASSWORD_BMI _at_ 0xF0A0; //define a password for programming BMI unsigned char idata USER_ID[4] _at_ 0x30; void PROGRAM_BMI(void) { bit bbmistat; if( PASSWORD_BMI == 0xAA ) { // Erase important code or data if needed before programming BMI value //... // Prepare USER_ID (for OCDS Mode SPD_0) USER_ID[0] = 0x00; // USER_ID_3 USER_ID[1] = 0x00; // USER_ID_2 USER_ID[2] = 0x9F; // USER_ID_1 (!BMI) USER_ID[3] = 0x60; // USER_ID_0 (BMI) // Program BMI value to OCDS Mode (SPD_0) SP = 0x50; // define stack pointer bbmistat = BR_FEATURE_SETTING(0x01, 0x30);// Option = 0x01. USER_ID add = 0x30 // Check the status for BMI programming // If BMI programming is successful, no return data. Automatically soft-reset if (bbmistat!= 0 ) { // Failure in correct option selection or NMISR!= 0x00 Application Note 20 V1.0, 2010-07

Handling Tips }}} void INT_vInit(void) { NMICON = 0x00; //NMI Control Register IEN0 = 0x01; // interrupt enable register 0 IEN1 = 0x00; // interrupt enable register 1 EXICON0 = 0xF3; // External interrupt Control Register 0 SFR_PAGE(_su3, nosst); // switch to page 3 without saving MODPISEL1 = 0x18; // peripheral input select register 1 SFR_PAGE(_su0, nosst); // switch to page 0 without saving }// End of function INT_vInit void INT_viExt0(void) interrupt EXT0INT { // emulate Reset pin an falling edge SFR_PAGE(_su1, nosst); PASSWORD_BMI = 0xAA; // User-defined password while (!(P2_DATAIN & 0x01) ); PROGRAM_BMI();... } // End of function INT_viExt0 Application Note 21 V1.0, 2010-07

Summary 5 Summary The Infineon XC82x/XC83x microcontrollers do not use any pins to enter different boot modes. The BMI configuration boot-up methodology is extremely useful in situations where port pins are very limited. This application note demonstrates how the user can program and update the BMI value under various operating conditions, with ease. Application Note 22 V1.0, 2010-07

www.infineon.com Published by Infineon Technologies AG