“How to Implement ICP Using ELAN EM78PXXX General Purpose OTP MCUs”
Transcription
“How to Implement ICP Using ELAN EM78PXXX General Purpose OTP MCUs”
Application note AN-E005 “How to Implement ICP Using ELAN EM78PXXX General Purpose OTP MCUs” Technical Description, Release 1.0 © Copyright 2003 Elan Microelectronics Corporation, No. 12, innovation 1st. Rd. Science-Based Industrial Park, Hsinchu City, Taiwan. The use of this document is limited to: 1. Distribution within your organization. 2. Distribution to potential customers or partners. This authorization is given on condition that any extract of these documents made by you shall retain all proprietary notice, including this copyright notice. The contents of this specification are subject to change without notice. Elan Microelectronics assumes no responsibility for errors that may appear in this specification and makes no commitment to update, or to keep current, the information contained in this specification. The products described herein are not intended for use in life support appliances, devices, or systems. Use of Elan Microelectronics products in such applications is not supported and is prohibited. NO PART OF THIS SPECIFICATION MAY BE REPRODUCED OR TRANSMITTED IN ANY FORM OR BY ANY MEANS WITHOUT THE EXPRESS WRITTEN PERMISSION OF ELAN MICROELECTRONICS. Note that any product, process or technology described in the document may be subject of other intellectual property rights reserved by Elan Microelectronics Corporation or a third party. No right to use such Intellectual Property Right is granted hereunder. Trademarks Elan Microelectronics Corporation and the Elan logo are registered trademarks and service marks or trade names whether registered or not, which may attach to certain words or signs used herein. The absence of such mention, however, in no way implies that there is no protection. Elan Microelectronics Corporation may make improvements or changes in the products or the program described in this document at any time without notice. This page and all content enclosed are © Copyright Elan Microelectronics, Hsinchu City, Taiwan. REVISION HISTORY Version Date Author Description 1.0 24.06.2004 Mark Svoboda Released AN-E005-V1.0-page 2 Preliminary www.elan-europe.com TABLE OF CONTENTS 1.0 INTRODUCTION 4 2.0 “RE-PROGRAMMING” AN OTP MICROCONTROLLER 4 3.0 ABOUT ELAN’S EM78P156 4 4.0 HOW TO IMPLEMENT ICP WITH EM78P156 4 5.0 APPLICATION CIRCUIT 5 6.0 PROGRAMMER 5 7.0 PROGRAMMING ENVIRONMENT 5 8.0 REPROGRAMMING WITH ELAN OTP MCU EM78P156 6 9.0 CONCLUSION 6 APPENDIX A: PROGRAM EXAMPLE 7 APPENDIX B: EXAMPLE ICP CIRCUIT 8 AN-E005-V1.0-page 3 Preliminary www.elan-europe.com 1.0 INTRODUCTION In-circuit programming ICP is a technique that allows a programmable device, a microcontroller for example, to be programmed after the device has been placed or soldered in the circuit board. ICP is a great way to reduce the cost of field firmware upgrades as well as reduce time to market for your product. This solution also allows manufacturers to quickly match microcontroller firmware variations running on the same PCB with actual market demand via last-minute programming. This application note describes a simple way to program Elan’s family of 8-bit general purpose microcontrollers while the IC is mounted in the application PCB. For purposes of description, this application note describes ICP for Elan’s popular EM78P156 1K ROM OTP microcontroller while mounted in the PCB. The same technique may also be used for Elan’s EM78P153, EM78P156N, EM78P257, EM78P447(N), EM78P458, EM78P459, EM78P418N, EM78P419N, and EM78P809N microcontrollers, all of which have very similar OTP programming structures. 2.0 “RE-PROGRAMMING” AN OTP MICROCONTROLLER Although by definition OTP microcontrollers can only be programmed one time, this ICP application note also describes a method by which an OTP device can be re-programmed multiple times depending on the size of the firmware as compared to the microcontroller OTP ROM size. 3.0 ABOUT ELAN’S EM78P156 The EM78P156 is an 8-bit, high-speed RISC microcontroller with 57 instructions for general-purpose applications. It has 1K of OTP program ROM, 48 bytes RAM, and 12 I/O pins. Operating voltage is 2.3 – 5.5V. It comes in 4 package variations, DIP, SOP, and SSOP with 2 different pinning configurations: Figure 1: EM78P156 package variation The EM78P156 is pin and function compatible with Microchip PIC 16C54/55/56 (see Elan application note “Replacing Microchip’s PIC 16C54/55/56/57 with Elan Microelectronic’s EM78P156/P447”). 4.0 HOW TO IMPLEMENT ICP WITH EM78P156 There are three main components of an ICP system: application circuit, programmer, and programming environment. AN-E005-V1.0-page 4 Preliminary www.elan-europe.com 5.0 APPLICATION CIRCUIT See Appendix B: Example ICP circuit For OTP programming, 6 dual-function pins of the microcontroller are required for programming. They are: Table 1: PIN assignment of EM78P156ELP/ELM Pin Name Pin (programming mode # / operating mode) I/O Another important issue is supply voltage. The OTP programming specification states that the MCU should be programmed at 5V. If the application circuit’s operating voltage is not 5V, the VDD pin should be isolated, and a 5V supply applied to VDD. Function during programming mode 6.0 PROGRAMMER ACLK / OSCO 15 I DATAIN / P50 17 I/O DINCK / P51 18 I PGMB / OSCI 16 I OEB / P67 13 I VPP / RESET 4 I CLK for address increase ROM series Input/Output pin The second consideration is the OTP programmer and its drive capabilities. DWTR is ELAN’s standard OTP programmer which has been designed to program the MCU in a socket mounted on the programmer. It has not been designed to drive signals over long connectors. It is therefore recommended that the cable length between the programmer and application circuit should not be longer than 20 centimeters. If the cable length is too long, the programming might be fail due to signal attenuation. CLK for DATAIN pin Program enable control pin, active low. Output enable control for DATAIN, active low for output. 13 Volt for OTP programming. The application circuit must be designed to allow all the OTP programming signals to be connected directly to the EM78P156. Fig. 1 shows an example circuit for implementing ICP with the EM78P156. When designing an application circuit with ICP, several issues must be considered: Note: for manufacturers wanting to develop their own OTP programming hardware, Elan’s OTP programming specifications are available free of charge under NonDisclosure Agreement (NDA). 7.0 PROGRAMMING ENVIRONMENT Isolation of all the programming signal pins from the surrounding circuit. Minimum and maximum operating voltage for VDD. Different programming environments require different types of programmer, and programming interface. You may rd choose Elan’s DWTR OTP programmer, a 3 party gang writer, or develop your own ICP hardware. In a typical application circuit, each pin of the MCU might be connected to several other active and/or passive components. Any component still connected to programming pins during programming could cause an OTP programming error. For example, capacitive loading on a programming signal pin could negatively affect the programming signal’s required rise time. Resistive loading would reduce necessary programming signal voltages. Therefore, the first step to implement the ICP circuit is isolation of all the programming pins. ICP application circuits may need customised connectors to the programmer and to the application PCB, and the cable distance between programmer and application circuit may also affect the driver’s ability to provide the correct signals and required current. The cables also need to be shielded to prevent programming signals being corrupted by external noise. Fig. 1 shows the ICP circuit example. The critical factor in the ICP circuit is how to isolate the 6 programming-related pins without affecting the functionality of the application circuit. EM78P156 needs six pins for OTP programming. All these programming pins need to be isolated during programming. When the EM78P156 is programmed, the /RESET/VPP pin must be supplied with an external 13V DC level. The VPP pin of EM78P156 also functions as the reset pin during normal operation, and is normally connected to an external RC circuit. Therefore it is recommended to use a diode to isolate the VPP pin. After take into consideration the application circuit, the programmer, and the programmer environment, virtually anyone can make a workable, high quality ICP application circuit. The CD4066 is a low-cost bi-directional solid-state electronic switch. The circuit below is configured such that a high voltage (13V) applied to VPP during OTP programming will cause the CD4066, via a transistor inverter (2N3904), to disconnect the 6 other pins which are used for OTP programming. After programming, to insure that the application circuit functions normally, the resistor values must be chosen such that the 2N3904 is switched off during normal operation of the circuit. When designing your application, you should also consider the ON state resistance of the CD4066 switch, which can depend on the supply voltage. Note that electrical isolation of pins may also be achieved by mechanical jumpers, or mechanical switches. This method involves manual intervention before and after ICP programming. AN-E005-V1.0-page 5 Preliminary www.elan-europe.com 8.0 REPROGRAMMING WITH ELAN OTP MCU EM78P156 By definition, OTP microcontrollers are not normally reprogrammable. However, there is a method to reprogram Elan’s OTP MCU so long as it is not write protected after the first programming, and there is enough blank OTP memory remaining to accommodate your desired additional firmware. The EM78P156 has two vectors, reset and interrupt, at locations 0x00 and 0x08 respectively. When the EM78P156 encounters reset or an interrupt occurs, the code location in one of these two addresses is executed. Appendix A: Example 1 shows a sample of list files. The list on the left-hand side in example 1 is the code first programmed into EM78P156. The list on the right-hand side of example 1 is the additional code programmed for the second time. From example 1, if your OTP memory already has firmware programmed into it, and has free remaining space in the OTP memory, which is large enough to accommodate the additional desired code, you could program the remaining blank OTP memory with the new code, and replace the original code with NOPs. First consideration is that you must reserve enough free memory addresses after the rest/interrupt vectors because the location of the jmp commands programmed in the corresponding reset and 9.0 CONCLUSION Anyone can create a reliable ICP programming circuit by adopting the recommended circuit design and programming techniques previously mentioned. Multiple-time OTP programming can also be achieved with the software technique described in this application note. Elan’s technical support staff are available to answer any questions you have about the requirements for ICP based on Elan’s OTP microcontrollers. AN-E005-V1.0-page 6 Preliminary www.elan-europe.com APPENDIX A: PROGRAM EXAMPLE Example1: Firmware list files First Program Program Memory Opcode 00000 1410 00008 1409 00009 0000B 0000C 0000D 0000E 0000F 0080 004F 18FF 0046 0013 00010 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 0001A 0001B 0001B 184F 0002 0080 0005 0006 0046 1840 000E 1804 000F 0010 HERE: 141B Assembly Instruction ORG JMP ORG JMP ORG INTERRUPT: CLRA MOV MOV MOV RETI START: MOV CONTW CLRA IOW IOW MOV MOV IOW MOV IOW ENI JMP 0X00 START 0X08 INTERRUPT 0X0B RF,A A,@0XFF PORT6,A A,@0b01001111 PORT5 PORT6 PORT6,A A,@0b01000000 0X0E A,@0b00000100 0X0F HERE Second Program Program Memory Opcode 00000 0000 00001 1421 00008 0000 00009 141C 0000B 0000C 0000 0000 0000D 0000E 0000F 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 0001A 0001B 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001C AN-E005-V1.0-page 7 Assembly Instruction ORG NOP ORG JMP ORG NOP ORG JMP ORG NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP ORG INTERRUPT: 0X01 START 0X08 0X09 INTERRUPT 0X0B 0X1C 0001D 0001E 0001F 00020 00021 00021 00022 00023 00024 00025 004F 18FF 0046 0013 00026 0046 MOV PORT6,A 00027 1840 MOV A,@0b01000000 00028 00029 0002A 000E 1804 000F IOW MOV IOW 0X0E A,@0b00000100 0X0F 0002B 0010 ENI 184F 0002 0080 0005 0006 Preliminary MOV MOV MOV RETI START: MOV CONTW CLRA IOW IOW 0X00 RF,A A,@0XFF PORT6,A A,@0b01001111 PORT5 PORT6 www.elan-europe.com APPENDIX B: EXAMPLE ICP CIRCUIT VDD R C CD4066 EM78P156 P51 I/O1_A I/O1_B I/O2_A I/O2_B I/O3_A I/O3_B I/O4_A I/O4_B I/O5_A I/O5_B P50 D OSCI /RESET/VPP VSS OSCO VDD P67 To application circuit VDD Control Pin R R 2N3904 ICP ICPConnector connector AN-E005-V1.0-page 8 Preliminary www.elan-europe.com