Home

ISP/IAP User Manual

image

Contents

1. Format Command r L R1 L SADDR L EADDR Return Byte stream ST Item Description R1 Reserved Always 0 Parameter SADDR Start address Range 0x0 EADDR EADDR End address Range SADDR maximum address of chip Result Return ST O Read operation successful F Failed read operation security lock is enabled or address out of range Descriptions Host Device Example Read main Flash ri OL JOx0 _ Ox1 fff Byte stream O Read option bytes r JO Ox1ff00000 0x1ff00030 Byte stream O Rev 1 00 38 of 49 July 14 2011 SJEMUJIA dYI Pue ds 24 Bush 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Using the ISP Bootloader Rev 1 00 The ISP bootloader is a preloaded program that uses a UART interface to communicate with the HT32 Flash Programmer through the HT32 Flash Command Protocol To start the ISP bootloader the following items must be noted Ensure that the boot setting on the target board is set as Bootloader It should be BOOTO 0 BOOT 0 or BOOTO 0 BOOTI 1 according to the device Refer to the user manual for each device for more information El Connect the target board to the COM port of the PC with an RS232 cable El Start a COM port program such as HyperTerminal or HT32 Flash Programmer Ensure that the UART is setup as follows e Baud rate 115200 bps Data 8 bits Parit
2. D ae Command Parameter _ _Return S c S S INFOs ST INFO1 L INFO2 Get Information i TYPE INFOn ST TYPE __ SADDR Erase e EADDR ST Blank Check b SADDR L EADDR ST c TYPE __ SADDR Program or Verify W EADDR ST CRC Check C SADDR EADDR CRC ST Execution Exit or Reset g TYPE None R1 L SADDR Read Memory r EADDR Byte stream ST L Space 0x20 Note that the commands SADDR and EADDR must be in lowercase letters Rev 1 00 34 of 49 July 14 2011 aJeMUI dYI PUL dSI 24 Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK 7 www holtek com Command Descriptions B Get Information i Table 20 Get Information Command i Descriptions Get information from device according to the parameter TYPE Command i _ TYPE CE Format Return INFO ST Item Description Parameter TYPE Information type See Table 21 for more information INFO Returned information See Table 21 for more information Return Result ST O Get information is successful F TYPE is not supported Descriptions Host Device Example Get chip name iLO HT32F 12530 Get flash size 111 317440 Table 21 TYPE Definition of Get Information Command TYPE Description Return Examples Unit HT32F 12530 0
3. ISP_ErasePage 0xc00 Oxfff Erase from Oxc00 to Oxfff E SP_EraseMass Table 7 ISP_EraseMass Function API INT ISP_EraseMass VOID Descriptions Apply mass erase on Flash memory Parameter None ISP_CMD_OK Successful operation ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected Return ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_CMD_EXECUTE_FAILED Failed operation Example ISP_EraseMass Start Mass Erase Rev 1 00 25 of 49 July 14 2011 Jauweiboi1g yse 4 ZELH 24 Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com E ISP_BlankCheck Table 8 ISP_BlankCheck Function API INT ISP_BlankCheck DWORD dwStartAddr DWORD dwEndAddr Execute blank check in specific range according to the parameter dwStartAddr and Descriptions dwEndAddr dwStartAddr Flash memory start address Parameter dwEndAddr Flash memory end address ISP_CMD_OK Successful operation ISP_INVALID_PARAMETER Invalid parameter ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected Return ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_CMD_EXECUTE_FAILED Failed operation Example ISP_BlankCheck 0xc00 Oxfff Apply blank check on Oxc00 Oxfff E ISP_WriteProgramB Table 9 ISP_WriteProgramB
4. Project uvmpw MDK ARM multi project file iap_startup_ht32fxxxx s MDK ARM IAP startup file startup_ht32fxxxx s MDK ARM application startup file IAP_Text MDK_ARM iap s ASM file that includes IAP application binary iap lin MDK ARM link script file iap ini Debug initialisation file Rev 1 00 43 of 49 July 14 2011 aJeMUI dYI Pue dS 24 Bursp 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com This example uses a multi project to manage both the IAP program and the user s application A multi project helps to build download debug both the IAP and application at the same time The following steps show how to build download debug using a multi project setup E For Keil uVision Build Double click on MDK_ ARM Project uvmpw to open the multi project file Select the Batch Build icon on the toolbar or tick Project Batch Build to open the Batch Build window Select the Build or Rebuild button to build both the IAP and the application The output file for the programming tools are as follows MDK_ARM HT32Fxxxx_xxx Obj IAP_AP hex HEX file for both IAP and application MDK_ARM HT32Fxxxx_xxx Obj IAP_AP axf bin AP Binary file for application Download Right click on the project name Project AP in Project window and click Set as Active Project Press the LOAD icon to download the IAP and application into the Flash memory Debug
5. to enter the debug mode Only the application program can be traced due to the current project settings In a similar way to the IAP text mode the boot settings can be changed to start an application or the IAP mode The IAP UI mode is designed to connect to the HT32 Flash Programmer or a customer Flash Programmer that is compatible with the HT32 Flash Command Protocol Refer to the relevant chapter for how to use the HT32 Flash Programmer 47 of 49 July 14 2011 SJeMUJIA dv pue dS ayy Bursn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Updating the IAP Firmware For the embedded Flash memory system erase or programming operations must not be applied on a page where the program is executing Since the IAP example code is located at the beginning of the main Flash it is not possible to update the IAP itself via a general IAP downloading procedural In such cases the IAP firmware will disappear if it tries to erase or re program itself To program or update the IAP Firmware another programming method such as the ISP the USB debugger or Flash Writer is required For more information about the USB debugger or Flash Writer refer to the documents below E Quick Start Guide Keil MDK ARM Quick Start for Holtek s HT32 Series Microcontrollers B Quick Start Guide LAR EWARM Quick Start for Holtek s HT32 Series Microcontrollers Holtek Programming Environment HOPE3000 for 32 Bit MCU User Manual Additionally
6. Holtek MCU Development Tools m Holtek HT32 IAR Support Package 1 00 Y Rae H732 Flash Programmer m Holtek HT32 Keil Support Package Y1 00 E IG Uninstall Figure 7 Start HT32 Flash Programmer Step 4 Tick Project New Project to restore the default value settings Change the COM port if required and confirm that the Baud Rate is set to 115200 E Holtek HT32 Flash Programmer 1 0 0 G E G Project Help H Programming Chip Status Memory Code Memory Data About Port Name COM BaudRate 115200 v Auto Connect Image Selection M Code C Program FilestHoltek HT32 SeriestHT32 Flash Programmeridatalimage bin la File Date File Size cRCO File Date File Size eci Protection Setting update Protection Setting Page Protection f Security Option Byte Write Protection Security Protection Flash Operations 6 Necessary pages All pages Vv Erase Blank Program i Holtek HT32 Series Flash Programmer COM1 115200 settingini Auto Comnect Off Auto Programming Off N A Figure 8 HT32 Flash Programmer Main Screen Rev 1 00 11 of 49 July 14 2011 J9UIWWe 1bBO0Id USB A ZE LH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Step 5 Turn on the device power and press the Connect button to connect If the connection is successful a
7. ISP_IsConnectedToDevice Check the connection Status ISP_GetTransProgress Obtain progress rate of program or verify ISP_GetInformation Obtain device information Rev 1 00 22 of 49 July 14 2011 Jauweiboig yse 4 ZELH 24 Buisn 32 bit ARM Cortex M3 MCU HT32 Series Rev 1 00 Table 3 Return Code of API HOUTEK 7 www holtek com Return Code Values ISP_CMD_SUCCESS 0x00 ISP_CMD_EXECUTE_FAILED 0x01 ISP_CMD_EXECUTE_BADCMD 0x02 ISP_ECHO_ERROR 0x03 ISP BAD FW REPLY DATA 0x04 ISP_SECURITY_LOCK 0x05 ISP_WRITE_PROTECT 0x06 ISP_BAD_PROGRAMMING 0x07 ISP_BAD_PROGRAMMING_NO_FIND_ACK 0x08 ISP_BAD_PROGRAMMING_TIMEOUT 0x09 ISP_BAD_PROGRAMMING_OPEN_FILE_NG Ox0a ISP_BAD_UNABLE_EXITXMODEM Ox0b ISP_SERIAL_PORT_OPEN_FAILED Ox0c ISP_SERIAL_PORT_NOT_CONNECTED Ox0d ISP_SERIAL_PORT_UNABLE_WRITE Ox0e ISP_SERIAL_PORT_UNABLE_READ OxOf ISP_DEVICE_NOT_FOUND 0x10 ISP RESET ERROR 0x11 ISP_INVALID_PARAMETER 0x12 ISP_FUNCTION_NOT_SUPPORTED 0x13 ISP_SYSTEM_ERROR_CODE 0x14 ISP_UNKNOWN_ERR Oxff 23 of 49 July 14 2011 Jawuweiboi1g USB A ZE LH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series Windows DLL API Descriptions R ISP_SetupSerialPortConnection Table 4 ISP_SetupSerialPortConnection Function INT ISP_SetupSerialPortConnection INT nPort DWORD baud_rate API HOUTEK S www holtek com Descriptions Open a specified serial port to connect to
8. Programming Chip Status Memory Code Memory Data About Address 0x0000 Length 1024 gt Bytes T Holtek HT32 Series Flash Programmer HA HOLTEK COM 1 115200 setting ini Auto Comect Off Auto Programming Off HT32F1253 ISP Figure 19 Read Flash Memory Rev 1 00 20 of 49 July 14 2011 Jauweiboi1g yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Project Operations 39 cc 39 66 The following figure shows the project operations Use these functions to create open save and save as the HT32 Flash Programmer settings Once the Flash Programmer is running the file setting ini will be loaded as a default file to reduce the setting time When any settings have been changed Save Project will save the value to the setting ini file All the controls are reset to the default value if New Project in the Project menu is selected This default values are saved in the default ini file that is located in the HT32 Flash Programmer installation path Save Project As will save the settings to another specific file while Open Project will open the selected file as the current setting Refer to the figure below for the details RL E Flash __ a New Project Programmer ini 2 Open Project Ctri O Start Save Project Ctri S j A Save Project As _ Save
9. Connected status message will appear The device name will also appear as shown below Press the Programming button to start the download operation Flash Operations 2 Necessary pages All pages Erase Blank Program verity cre Run C Auto Programming A o Holtek HT32 Series Flash Programmer HA HOLTEK COM1 115200 settingini Auto Connect Off Auto Programming Off HT32F1253 ISP Figure 9 Connection Status Step 6 If the operation succeeds an Operations success message will appear as shown below Holtek HT32 Series Flash Programmer HA HOLTEK COM 1 115200 stingini Auto Comect Off Auto Programming Off N A Figure 10 Operation Success Screen Rev 1 00 12 of 49 July 14 2011 Jawuweiboig USB A ZE LH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Step 7 Press the Connect button to re connect the device and change the tab to the Memory Code page Press the Read button to read the data from the flash Since the default setting has been chosen a dummy data image bin will have been programmed into the Flash memory as shown below for testing E Holtek HT32 Flash Programmer 1 0 0 Project Help H Programming Chip Status Memory Code Memory Data About Address 0x0000 _ Length 1024 gt Bytes Save as JA 12 13 14 15 16 17 9 1A 1B 1C 1D 1E Figure 11 Read Flash
10. Function INT ISP_WriteProgramB DWORD dwStartAddress DWORD dwEndAddress BYTE mode ole BYTE pbValue Descriptions Start Xmodem protocol for program or verify operation dwStartAddr Flash memory start address dwEndAddr Flash memory end address Parameter mode 1 for Program 0 for verify pbValue Buffer pointer to which data will be written ISP_CMD_OK Successful operation ISP_INVALID_PARAMETER Invalid parameter ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_SERIAL_PORT_UNABLE_READ COM port can not be read Return ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_BAD_PROGRAMMING_NO_FIND_ACK Unable to find the acknowledge ISP_BAD_PROGRAMMING_TIMEOUT Programming operation timeout ISP_BAD_UNABLE_EXITXMODEM Xmodem protocol error ISP_BAD_PROGRAMMING Programming error Byte buffer 16 buffer 0 0x55 Example ee ISP_WriteProgramB 0xc00 OxcOf 1 buffer write 16 bytes to Main Flash address Oxc00 Rev 1 00 26 of 49 July 14 2011 J9UIWe1bBO0Id yse 4 ZE LH aui Buisn 32 bit ARM Cortex M3 MCU nor A HT32 Series www holtek com E ISP_CRCCheck Table 10 ISP_CRCCheck Function API INT ISP_CRCCheck DWORD dwStartAddr DWORD dwEndAddr BYTE pbValue Descriptions CRC check of Flash memory Parameter dwStartAddr Flash memory start address dwEndAddr Flash memory end address pbValue Buffe
11. The example program user interface will appear as shown below de ISPCmdSimpleDemo Read Data Erase Data Figure 21 VC 6 0 ISPCmd dll Example Code Step 4 Select Setting to configure the COM port and the baud rate as shown below Port Name coma Baud Rate 115200 Cancel Figure 22 Configure the COM Port and Baud Rate Step 5 Press the buttons on the screen to test the corresponding functions Rev 1 00 31 of 49 July 14 2011 Jawuweiboi1g yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com This example code is created using Microsoft Visual C 6 0 To develop a Flash Programmer start with the example code or follow the steps below to create a new project Step 1 Start Microsoft Visual C 6 0 and create a new project using the MFC AppWizard Step 2 Copy Common h ISPCmd dll ISPCmd lib and ISPCmdExport h from ISPCmdSimpleDemo zip to the project folder Step 3 Include ISPCmd lib and ISPCmdExport h into the project Step 4 To use all the functions in the DLL refer to the API descriptions in other sections Rev 1 00 32 of 49 July 14 2011 J9UIWe1bBO0Ig yse 4 ZE LH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Sores HOUTEK f 7 www holtek com 3 Using the ISP and IAP Firmware The following section describes the protocol details and the command format of the HT32 Flash Command Protoc
12. UI Mode Example Code The IAP UI mode is connected with a user interface to download the user s image into the main Flash via the UART The interface can be the windows based HT32 Flash Programmer or any user application as long as it meets with the HT32 Flash Command Protocol Refer to Section 3 1 for more information about the HT32 Flash Command Protocol The IAP UI mode example source files are listed in the table below Table 29 IAP UI mod Source Files Path Filename Description IAP_UI Src_AP main c Application main program ht32fxxxx_it c ht32fxxxx_it h Application Interrupt handlers ht32fxxxx_conf h Firmware library configuration file system_ht32fxxxx C System configuration file IAP_UI Srce_lAP iap_main c IAP main program iap_handler c iap_handler h IAP handler which controls the image update procedural iap_xmodem c iap_xmodem h Xmodem transmission protocol iap_buffer c iap_buffer h UART buffer function iap_crc16 c iap_crc16 h CRC algorithm for Xmodem and Flash checksum iap_ht32fxxxx_it c iap_ht32fxxxx_it h IAP Interrupt handlers ht32fxxxx_conf h IAP firmware library configuration file iap_system_ht32fxxxx c IAP system configuration file IAP_UI EWARMv5 4 Project eww EWARM project file iap_startup_ht32fxxxx s EWARM IAP startup startup_ht32fxxxx s EWARM application startup file iap_ht32fxxx
13. the programmer nPort Specify the serial port Parameter Baud_rate Specify the baud rate ISP_CMD_OK Successful operation Return ISP_SERIAL_PORT_OPEN_FAILED Can not open COM port If ISP_SetupSerialPortConnection 1 115200 Example Unable to connect the serial port ISP_CloseSerialPortConnect ISP_CloseSerialPortConnect Table 5 ISP_CloseSerialPortConnect Function API VOID ISP_CloseSerialPortConnect VOID Descriptions Close the serial port Parameter None Return None If ISP_SetupSerialPortConnection 1 115200 Example Unable to connect the serial port ISP_CloseSerialPortConnect Rev 1 00 24 of 49 July 14 2011 Jawweiboig yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU nor A HT32 Series www holtek com E ISP_ErasePage Table 6 ISP_ErasePage Function API INT ISP_ErasePage DWORD dwStartAddr DWORD dwEndAdar Descriptions Erase page according to the parameter dwStartAddr and dwEndAdar Parameter dwStartAddr Flash memory start address dwEndAddr Flash memory end address Return ISP_CMD_OK Successful operation ISP_INVALID_PARAMETER Invalid parameter ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_CMD_EXECUTE_FAILED Failed operation Example
14. to receive the next command The host will check the ST character to confirm if the operation was successful The format of each notation is shown in the figure below Command Parameter e Process Return Ready Host Device Host Device Device AA 1Byte 1 Byte Variable 2 Byte 1 Byte 2 Byte 4 Bytes A A A p al y i be A S Y i i Y c s P1 ACK ST ACK Prompt i i j Probing i 1 W r n ISP gt 1 l 1 l 1 Get Information i l 1 i i 1 r Mn O UW ISP gt l T Program Verify 1 1 1 w 0 Oxc00 Ox7bff r r n Xmodem O Mn ISP gt 1 1 i L C Command Pn Parametern r 0x0D Required Condition CE Command End ST Result n 0x0A k S Space INFOs Return Value ACK Acknowledge Figure 23 Holtek Flash Programmer Protocol Rev 1 00 33 of 49 July 14 2011 aJeMUI dYI PUL dS 24 Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Command Format The following table shows the supported command sets for the HT32 Flash Command Protocol Detailed information behind each command will be discussed in the following section Table 19 Command Description
15. Cortex M3 MCU HT32 Series HOUTEK e www holtek com IAP Text Mode Example Code The IAP Text mode provides a text menu to download the user s image into the main Flash via the UART This example runs on the HT32 series development board The IAP text mode example code source files are shown in the table below Table 28 Text Mode Source Files Path Filename Descriptions main c Main application program ht32fxxxx_it c ht32fxxxx_it h Application Interrupt handlers IAP_Text Src_AP ht32fxxxx_conf h Firmware library configuration file system_ht32fxxxx c System configuration file iap_main c IAP main program iap_handler c iap_handler h IAP handler which controls the image update procedural iap_xmodem c iap_xmodem h Xmodem transmission protocol IAP Text Src IAP iap_buffer c iap_buffer h UART buffer function iap_crc16 c iap_crc16 h Xmodem and Flash checksum CRC algorithm iap_ht32fxxxx_it c iap_ht32fxxxx_it h IAP Interrupt handlers ht32fxxxx_conf h Firmware library configuration file of IAP iap_system_ht32fxxxx c IAP system configuration file Project eww EWARM project file iap_startup_ht32fxxxx s EWARM IAP startup file IAP_Text EWARMv5 4 _ startup_ht32fxxxx s EWARM application startup file iap_ht32fxxxx_flash icf EWARM IAP link script file ht32fxxxx_flash icf EWARM application link script file
16. Default Value eee Current ae New l Setting Open A Open a i defaultini N Save As C J r ON a o o product1 ini product2 ini ini Figure 20 Project File Operations Rev 1 00 21 of 49 July 14 2011 Jawuweiboi1g USB A ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK 7 www holtek com Developing Flash Programmers for the HT32 Series MCU Introduction Holtek provides a dynamic link library ISPCmd dl for Flash programming operations that implements the HT32 Flash Command Protocol and the communication APIs to communicate with ISP or IAP firmware Software programmers can add the DLL library into their own projects and use the API functions to program devices in the same way as the HT32 Flash Programmer The following two tables are the API function list and the return codes of the ISPCmd dll Detailed information for each function will be discussed in following sections Table 2 Windows DLL API Type API Name Description ISP_SetupSerialPortConnection Connect to the programmer Connect ISP_CloseSerialPortConnect Close the programmer connection ISP_ErasePage Erase page ISP_EraseMass Mass erase ISP_BlankCheck Blank check ISP_WriteProgramB Program or verify Control ISP_CRCCheck Flash memory CRC check ISP_ReadData Read memory from device ISP_Execute Execute user program ISP_Exit Exit command mode ISP_Reset Reset the programmer
17. Get chip name INFO ST HT32F12510 Text ASCII 317440 1 Get Flash size INFO ST 81920 In bytes ASCII 2 Get Option size INFO ST 10240 In bytes ASCII 3 Get OB_PP bit count INFO ST S Bit Count ASCII f ISPV1 0 00 4 Get firmware version INFO ST IAPV1 0 00 Text ASCII 5 Get firmware date INFO ST 2011 03 11 0 Text ASCII 00 6 Get ISP IAP start address INFO ST 40960 In bytes ASCII 81920 Others Not support ST F State Rev 1 00 35 of 49 July 14 2011 SJeMUJIA dYI Pue dSI 24 Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK S www holtek com R Mass Page Erase e Table 22 Mass Page Erase Command e Descriptions Apply mass page erase according to the parameter TYPE Format Command e L TYPE L SADDR L EADDR Return ST Item Description BER ieee era SADDR Start address Note2 Range 0x0 EADDR EADDR End address Note2 Range SADDR maximum address of chip Result Bon ST S e o PE ee out of range or erase type not supported Descriptions Host Device Example Mass erase elo O Page erase e _ 1 _ 0x0 _ 0x17ff O NOTES 1 The IAP mode only supports the page erase command The IAP Firmware returns ST F when it receives a mass erase command 2 SADDR and EADDR are only valid under the page erase mode TYPE 1 Blank Check b Table 23 Blank Check Comma
18. HOLTEK f 7 HT32 Series In System In Application Programmer User Manual Revision V1 00 Date July 14 2011 wW U wW holtek com 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Table of Contents TINTO e TTL ON basis ces scelesssscesestesscesasecsescstceseeseseseeseseceveccessesccesecenstessvenceescecccsesswescpeseseces 5 PNoXey Ui fl A OA 5 EIT RlashiProgrammenOvenvicwrresincsc etc ee E HT T 5 SR AIA ba 6 2 Using the AT32 Flash Programmen omar TT ET EEE 7 Installingithe Tea Ta TET paT A sees eeeeeee steers eee eee 7 HT32 Flash Programmer Quick Star A A eee seen aye eeenre 11 EIC ake Sien T GT 14 CN aa aaa 14 Image er aia 15 Protection Set as 15 HashOperations a a a A E E setet sae 16 RIOCESSINGES tatlSranGiRESUITS Message ma A 17 AUto Comnectand Auto Aro A 18 Doo eper treater 19 a aras 20 O IGE 21 Developing Flash Programmers for the HT32 Series MCU sss sees ee sees e eoor n nenen nne 22 lntrod ction ne a e Serr ere CR rr ae 22 Windows DELAPRIDesScriptions na n a a tere 24 Gettingistantediwithithe Exerm ple tRn ec T ce ceenesee te A Sil 3 Using the ISP and IAP Firmware oia 33 SE SETS COM MA a 33 Ar DO Ss sos 33 co O RC 34 CM A IN aS 35 Usingthe SP oa Taa A aa E E A 39 IAPJExample Code ann aeae a E E ARE A E LA ae E E A AAAA E E aE A ore 40 Ona os 40 IAP TextMode Example Code tea 43 IAP WIsModerExample Od Gi me ori crew aa 46 UpdatingthelAPR Firmware edita iria 48 Rev 1 00 2 o
19. Len ISP_GetInformation 0 buffer amp nLen Get chip name 29 of 49 July 14 2011 Jauweiboi1g yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK 7 www holtek com Table 18 nCode definition of ISP_GetInformation Function nCode Description Examples HT32F12530 0 Get chip name HT32F12510 t 317440 1 Get Flash size 81920 2 Get Option size 10240 310 3 Get OB_PP bit count 80 A ISPV1 0 00 4 Get firmware version IAPV1 0 00 5 Get firmware date 2011 03 110 00 6 Get ISP IAP start address 40960 81920 Others Not supported F Rev 1 00 30 of 49 July 14 2011 Jawuweiboig yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Getting Started with the Example Project A Visual C 6 0 example code named ISPCmdSimpleDemo zip is provided as example code to use the ISPCmd dll The example code can be found in the HT32 Flash Programmer installed path For example C Program Files Holtek HT32 Series HT32 Flash Programmer VC 6 0_ Example This example code shows the DLL functions such as obtaining information write data read data erase data and etc The following steps show how to start the example program Step 1 Unzip ISPCmdSimpleDemo zip Step 2 Power up the programmer and connect the cable to PC Make sure the programmer is ready for connection Step 3 Double click on Output ISPCmdSimpleDemo exe
20. Make sure the active project is Project _AP Press Ctrl F5 to enter the debug mode The debug symbol of the IAP will be loaded by iap ini Since both images of the IAP and the application have been loaded into uVision trace the program switching behavior between the IAP and the application E For IAR EWARM Build Double click on EWARMVS 4 Project eww to open the multi project file Press F8 or tick Project Batch Build to open the Batch Build window Select the Make or Rebuild All button to build both the IAP and the application The output file for the programming tools are as follows EWARMVS 4 HT32Fxxxx_xxx Exe IAP_AP bin Binary file for both IAP and application EWARMv5 4 HT32Fxxxx_xxx Exe AP bin Binary file for application Download Ensure that the active project is Project_IAP HT32Fxxxx_xxx by ticking the drop down list in the Workspace window Select Project Download Download active application to download the IAP and application into the Flash memory Debug Ensure that the active project is Project_AP HT32Fxxxx_xxx Press Ctrl D to enter the debug mode Only the application program can be traced due to the current project settings Rev 1 00 44 of 49 July 14 2011 aJeMUI dYI Pue ds 24 Busy 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com After the example code has been downloaded into the target board open
21. Memory Now the HT32 Flash Programmer is ready for use For more information regarding each function refer to the following sections Rev 1 00 13 of 49 July 14 2011 Jauweiboi1g yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK Functional Description This section describes the HT32 Flash programmer operations with a detailed description of each function Connection The HT32 Flash Programmer communicates with the target device via an RS232 interface The related programmer settings are shown below After ensuring that the COM port and baud rate are set correctly select the Connect button to make the required connection How to use the Auto Connect function will be discussed in a later chapter www holtek com SE Holtek HT32 Flash Programmer Y 1 0 0 Project Help H Programming Chip Status Memory Code Memory Data About image Selection File Date File Size Data C Program FilestHoltek HT File Date File Size Protection Setting Update Protection Setting Port Name COM v Baud Rate 115200 v C Auto Connect Code C Program FilesiHoltek HT32 Series HT32 Flash Programmeridatalimage bin cerco Flash Operations 2 Necessary pages O All pages Erase Blamk Program verity cre C Run Page Protection p FFFFFFFF p FFFFFFFF OXFFFFFFFF OXFFRFFFFF Security Option Byte Write Protection Security Protection C Auto Programming LJ Co
22. Size 31744 Bytes Data Option Size 1024 Bytes Fl 1024 Bytes File Data File Size CRCI Connect Mode ISP 2010 09 28 944 Bytes OxFOOA Protection Page Erase Program Protection Option Byte Value Pages cada OB_PPO OxFFFFOOOO Bit 15 00 Bit 31 16 Bit 47 32 Bit 63 48 Bit 79 64 Bit 95 80 Bit 111 96 Bit 128 112 OB_PP1 OxFFFFFFFF OB_PP2 OxFFFFFFFF OB_PP3 OxFFFFFFFF OB_CP OxFFFFFFFF Option Byte Write Protection Security Protection CCC Connecta Holtek HT32 Series Flash Programmer COM1 115200 settingini Auto Connect Off Auto Programming Off HT32F1253 ISP Figure 18 Chip Status Rev 1 00 19 of 49 July 14 2011 Jauweiboi1g YSEA ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Read Flash Memory The Memory Code and Memory Data tabs provide memory display and save as functions for debugging purposes After the programmer has been connected enter the start address length and select the Read button to execute a read operation The HT32 Flash Programmer UI will receive the memory data and display it on the screen Right click on the memory window to change the display width to byte half word or word as shown below Click the Save as button to save the specific contents to a file in binary format for later use Holtek HT32 Flash Programmer 1 0 0 Project F Help H
23. TEK COM 1 115200 setting ini Auto Comect On Auto Programming Off HT32F1253 ISP Figure 16 Processing Status and Results Message Table 1 Processing Status and Results Message Processing Status Result Message Descriptions Bigeonnect _ Programmer is in the idle mode COM port is closed Connecting Programmer trying to connect to the device Connected Device is connected Erasing Erase operation in progress Blank Checking Blank check operation in progress Programming Programming operation in progress Verifying Verify operation in progress CRC Checking CRC check in progress Operation success All operations successful Erase Failed Erase operation failed Disconnect Connected or Connecting Blank Check Failed Blank check operation failed According to the setting of Auto Connect and Run Program Failed Program operation failed Verify Failed Verify operation failed CRC Check Failed CRC check failed Rev 1 00 17 of 49 July 14 2011 Jauweiboi1g USB A ZELH aui Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Auto Connect and Auto Programming The HT32 Flash Programmer provides Auto Connect an Auto Programming functions The following figure shows how these two functions are used When the Auto Connect function is enabled the HT32 Flash Programmer is connected automatically when launched or re connect when any pre
24. a COM port application such as HyperTerminal in the PC Change the UART settings as shown below Baud rate 115200 bps Data 8 bits Parity check None E Stop bit 1 bit Flow control None Connect the target board to the PC using an RS232 cable and reset the target board If both BOOTO and BOOT are set to 1 the user application will be initiated and display a text menu via the UART as shown below Select a 1 3 key to execute the corresponding function Application 1 Start IAP mode 2 Hello World 3 Enable Write Protection Figure 27 Application Text Menu If BOOT1 1 and BOOTO 0 or if Key 1 is selected from the above application menu then the IAP mode will be initiated and a text menu will be displayed as shown below From the screen choose the desired function For example select 2 to download an image to Flash This example follows the Xmodem protocol and sends numerous C characters to indicate that it is ready to receive data from PC Start the Xmodem transmission and choose a binary file to program into the application target board Holtek Semiconductor Inc IAP Example Code 1 Execute The New Program 2 Download Image to Flash 3 Disable The Write Protection Figure 28 IAP Text Mode Text Menu Rev 1 00 45 of 49 July 14 2011 SJEMUJIA dYI Pue dS ayy Bursn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK 7 www holtek com IAP
25. eation Rd Il Science Park Hsinchu Taiwan Tel 886 3 563 1999 Fax 886 3 563 1189 http www holtek com tw Holtek Semiconductor Inc Taipei Sales Office 4F 2 No 3 2 YuanQu St Nankang Software Park Taipei 115 Taiwan Tel 886 2 2655 7070 Fax 886 2 2655 7373 Fax 886 2 2655 7383 International sales hotline Holtek Semiconductor Inc Shenzhen Sales Office 5F Unit A Productivity Building No 5 Gaoxin M 2nd Road Nanshan District Shenzhen China 518057 Tel 86 755 8616 9908 86 755 8616 9308 Fax 86 755 8616 9722 Holtek Semiconductor USA Inc North America Sales Office 46729 Fremont Blvd Fremont CA 94538 USA Tel 1 510 252 9880 Fax 1 510 252 9885 http www holtek com Copyright 2011 by HOLTEK SEMICONDUCTOR INC The information appearing in this document is believed to be accurate at the time of publication However Holtek assumes no responsibility arising from the use of the specifications described The applications mentioned herein are used solely for the purpose of illustration and Holtek makes no warranty or representation that such applications will be suitable without further modification nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise Holtek s products are not authorized for use as critical components in life support devices or systems Holtek reserves the right to alter its products without prior notification For the
26. f 49 July 14 2011 U9 U0D jo jqeL 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com List of Figures Figures teal SPAR Programming mools SystemArchitect re m a 5 Riquier2 Memo organizationoa Sa A 6 Figure 3 HT32 Flash Programmer Installation Welcome Rage maaa a a 7 Figure 4 HT32 Flash Programmer Installation Select Installation Path sese ee sees seer ereer ee ereer eee 8 Figure 5 HT32 Flash Programmer Installation Ready tollnstal Page m a a m 9 Figure 6 HT32 Flash Programmer Installation Completion a a a 10 Fig re T Stan HT32FlashProgrammen n n ne gor radeecdoa crnconecdocucacoceagarcenpedodbnorocnarccoodcareucoqarsy id oui Sh Imi ZAHashietrogrammenMain ce 11 Figure OS Connection o 12 FIGure Oee ne AAEE 12 Aore Read ET ea reneee 13 FES 12 GTS TGT Tee ete SYS H E coc cecnecececcndnesenconancedeccacnncaencacencoececcAnneueceadancoorcenenecosncanancenee 14 AN o east 15 Figures 14 ProtectOmes CUtliGS 15 Figure om STET Related Settings seer see see een ee ee 16 Figures 162 Processing Statusandi Results Message m 117 Figures tifarAuto Connect andi Auto Programmino e O 18 Figure 1822S Nip Statuses recs seo ccereseccreescev sea nccey ayer eure che trens saceren ste bean soccer ener velo agnot teem aes tects reighasevenere sass 19 Figurent9 Ra IM es 20 Eliguies20 Projecti File Operations n ee a a raro ias 21 Figure 21 VC 60NSECE mad Ea co 31 Eiquies224GConigure the COMP ontancsB auicl ra 31 Figures2sean
27. f O B CRC Check c Table 25 CRC check c Start CRC check operation according to the parameters SADDR and EADDR Descriptions Format Command c _ SADDR _ EADDR Return CRC ST Item Description SADDR Start address for CRC calculation Range 0x0 EADDR Parameter End address for CRC calculation Range SADDR maximum address EADDR R of chip CRC 16 bit CRC value Return Result ST O CRC calculation successful Descriptions Host Device Example CRC check c 10x0 _ 0x1 fff ByteLByteH O Rev 1 00 37 of 49 July 14 2011 aJeMUI dYI Pue dS 24 Bush 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK e 7 www holtek com Execution Exit Reset g Table 26 Execution Exit and Reset Command g Descriptions Start user application execution exit ISP IAP firmware command mode or reset the device Format Command g LI TYPE Return ST Optional Item Description Execution Exit or Reset Parameter TYPE E a 2 Reset Result for Execution Return ST F User application does not exist when TYPE 0 Descriptions Host Device Execution go F if failed Example Exit g1 None Reset g 2 None R Read Memory r Table 27 Read Memory Command r Descriptions Read Flash memory content from chip
28. ice Function API BOOL ISP_IsConnectedToDevice VOID Descriptions Check the device connection status Parameter None TRUE 1 Device is connected Return FALSE 0 Device is not connected if ISP_IsConnectedToDevice Example Find the device gt else J Not find the device ISP_GetTransProgress Table 16 ISP_GetTransProgress Function API DWORD ISP_GetTransProgress VOID Descriptions Return the progress percentage of a programming or verify operation Parameter None Return Percentage Progress percentage from 0 to 100 DOWRD dwCurrProgress Example dwCurrProgress ISP_GetTransProgress E SP_Getinformation Table 17 ISP_Getlnformation Function API INT ISP_GetInformation DWORD nCode BYTE pbValue int pLen Descriptions Obtain information from device according to the parameter nCode Parameter nCode Information selector See Table 18 for details pbValue Buffer pointer for result saving pLen Return the information length in bytes Return ISP_CMD_OK The operation is successful ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_DEVICE_NOT_FOUND Device not found ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_CMD_EXECUTE_FAILED Failed operation Example Rev 1 00 BYTE buffer 255 INT n
29. itionally the CRC16 module calculates the CRC value for the Xmodem protocol and Flash checksum USART Rx TX Program PMC os ee E ne eae l UART Rx Buffer Xmodem CRC16 wm AHH KA Tx 7 IAP Handler Read _ Erase gt Booting NVIC Main Routine FLow IAP Example Code exc lT Firmware Library Peripheral Function Call AFIO GPIO Firmware Lib HW Function T AP SW Architecture of IAP Example Code Figure 24 IAP Example Code Architecture Rev 1 00 40 of 49 July 14 2011 aJeMUI dYI Pue dS 24 Busy 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com The Main Routine manages system initialisation such as Clock I O and interrupts It also uses BOOTO to decide if the user application or the IAP mode should be initiated The following figure shows the boot flow of the IAP example code B Enter the IAP mode when IO BOOTO is set to 0 B Enter the IAP mode when the application triggers Application set SBVTO to OxSSAAFAF5 and triggers a reset m Enter the IAP mode when the application image does not exist check the application vector format S Otherwise start application execution N BOOTO 0 BOOTO 1 Application trigger IAP oF a SBVTO Magic Number 0O
30. most up to date information please visit our web site at http Awww holtek com tw Rev 1 00 49 of 49 July 14 2011
31. nd b Descriptions Apply blank check in a specific range according to the parameters SADDR and EADDR Format Command b _ SADDR _ EADDR Return ST Item Description SADDR Start address Range 0x0 EADDR Parameter EADDR End address Range SADDR maximum address of chip Result Return ST O Blank check successful F Failed blank check some Flash content is not equal to OxFFFFFFFF Descriptions Host Device Example Blank check b _ 0x0 _ Oxffff O Rev 1 00 36 of 49 July 14 2011 SJeMUJIA dYI Pue ds 24 Busy 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK 7 www holtek com B Program Verify w Table 24 Program Verify Command w Descriptions Start Xmodem protocol for program or verify operation Format Command w L TYPE L SADDR L EADDR Return ST Item Description Program or verify mode TYPE 0 Verify mode 1 Program mode Perameten SADDR Start address for program or verify Range 0x0 EADDR End address for over range checking FABOR Range SADDR maximum address of chip Result O Program Verify successful Return ST F Failed Program Verify Address out of range Flash error Xmodem CRC error etc Descriptions Host Device Example Program w _ 0x1 _ 0x0 _ Ox fff O Verify w _ 0x0 _ 0x0 _ Ox ff
32. nfigure ion Holtek HT32 Series Flash Programmer 115200 setting ini Auto Connect Off Figure 12 Connection and Related Settings Auto Programming Off Pro srauning pour dA NIA Rev 1 00 14 of 49 July 14 2011 Jawuweiboi1g yse 4 ZELH 24 Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK Image Selection Select the which is the folder browse button to select the Code or Data image file Both binary and hex formats are supported Information regarding the file date file size and its CRC value will also be updated if the target is connected The Flash operation will be applied to the Code Data area only when its Code or Data checkbox has been checked Programming Chip Status Memory Code Memory Data About Port Name Code Data COM BaudRate 115200 v JaAuto Connect Image Selection File Date File Size CERCO C Program F les Holtek H 113 2 SeriesiHT32 Flash Programmerdataidata dat File Date Figure 13 Image Selection C Program FilestHoltek HT32 SeriesiHT32 Flash Programmertdatalimage bin File Size CRC1 www holtek com Protection Settings Select the Configure button to configure the protection settings as shown below The actual Option Bytes value is shown in the left side of the setting window This will be updated dynamically when the checkbox status is cha
33. nged Use the individual All checkboxes to select a specific line Clicking the OK button will retain the related values Note that the Option Byte Write and Security protection functions are invalid in the IAP mode Protection Setting Update Protection Setting Page Protection OsFFFFFFFF OnFFFFFFFF OxFFFFFFFF rrer Configure Security Option Byte Write Figure 14 Protection Settings Protection Security Protection Protection Setting Option Byte Value Page Erase Program Protection OB_PPO OxFFFF0000 an Pages NA Bit 15 00 Y Y MMMM L NA Bit 31 16 L NA L OXFFFFFFFF Bit 47 32 Bit 63 48 Bit 79 64 Bit 95 80 Bit 111 96 Bit 128 112 Option Byte Write Protection Rev 1 00 15 of 49 July 14 2011 Jawuweiboi1g yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK www holtek com Flash Operations The major objective of the Flash operations is for Code Data and Protection Settings These various operations will only be executed when their respective checkbox has been selected i e the flash operation can be updated partially The Necessary pages and All pages options are used to decide the behavior of the Erase and Blank Check functions If Necessary
34. not to view the release note or to launch the HT32 Flash Programmer Press the Finish button to complete the installation process ie Setup Holtek HT32 Flash Programmer Completing the Holtek HT32 Flash Programmer Setup Wizard Setup has finished installing Holtek HT32 Flash Programmer on your computer The application may be launched by selecting the installed icons Click Finish to exit Setup MY s Launch HT32 Flash Programmer Figure 6 HT32 Flash Programmer Installation Completion Rev 1 00 10 of 49 July 14 2011 Jawuweiboig YSeld ZELH aui Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com HT32 Flash Programmer Quick Start To start using the Flash Programmer several components are required as listed below A HT32 series MCU target board E A host computer running Microsoft Windows XP Vista or Windows 7 Full HT32 Flash Programmer installation as described earlier Step 1 Connect the target board to the COM port of the PC with an RS232 cable Step 2 Make sure the BOOTO and BOOT pins are setup as follows ISP BOOT1 0 BOOTO 0 or BOOTI 0 BOOTO 1 Refer to the user manual for each device IAP BOOT 1 BOOTO 0 Step 3 Double click Start All Programs Holtek HT32 Series Holtek HT32 Flash Programmer HT32 Flash Programmer to run the program fm Holtek HT32 Series fm Holtek HT32 Flash Programmer HT32 Flash Programmer
35. oDevicei Function m a tases eases A 29 Table 16 T GetliransProgress UI cio nee ae 29 Table 17 ISP Getinformation Function a e a a a 29 Tablets nCode definition of ISP2Getimfonmation UMC TE 30 Table 19s Command DE oro 34 Table 20 Get information orn RTS steers eee anne nea 35 Table 2 hy PE DeEfiMmtiomonGetintormationcommand a 35 Nablew22a5Mass Pagel Erase Command e ae ea e eee E E E eee eee eee 36 Table 239 Blank Check Command D e m e aee e E e E E E sere sete uat ter arre eee 36 Table 24T Program Nenv Commanmdi a seeeseee tees creas eee eer ee nee eee es sm Ta LR ao 37 Tablee2os Execution s EXitand i ResenCommand O perese meee tee een ete tetera nen eee 38 Tablex27FHReadiMem Commandi r mr 38 Table 28 Text Mode SourceFiles zn n cree cec eset ae earner eee eee eee eee 43 Table 29 MARU Mods de OS 46 Rev 1 00 4 of 49 July 14 2011 sa qeL 10 3817 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com 1 Introduction About This Document This document describes how to use the In System Programming ISP and In Application Programming IAP tools for the HT32 series of microcontrollers The contents are divided into two main areas the PC Based HT32 Flash Programmer user Interface and the ISP IAP firmware A short overview of the HT32 Flash Programmer and ISP IAP in the following section will assist with initial understanding of the architecture In a following chapter a description of how to use the HT32 Flash Prog
36. ol An introduction of how to use the ISP boot loader will also be provided here while the IAP example code will be discussed in the last section of this chapter HT32 Flash Command Protocol Protocol Descriptions The HT32 Flash Command Protocol is an ASCII based challenge response protocol for firmware update purposes It supports up to 7 command sets including obtaining information erase blank check program verify CRC check execution and read memory The protocol architecture is shown in the figure below The protocol consists of three parts command with parameter returned value and an acknowledgement The host sends a command to the device which starts with a 1 byte command character then follows with the optional parameters and ends with a command end character CE 0x0D Note that each byte received by the device will be sent back to the host directly for error detection Once the device has received the command end character it will respond with a 2 byte acknowledge string ACK 0x0D 0x0A to indicate that the command has been successfully received The device will then start parsing the command parameter and proceed accordingly with the required Flash operation After the operation has finished the device sends the optional information byte of status ST and 2 bytes of acknowledgement to the host Finally the device sends a prompt string such as ISP gt or IAP gt to notify that the operation has finished and is ready
37. oltekablashierogteamnnne ta aro ae 33 Figure 24 IAPR Example Code Architecture n a a a seer eae aa 40 Figure 25 1AP mode Bo FOW e eane 2 HA 41 Figure 26 IAP Example CodelFolders ennenen a a E E A ene Ia 42 Figure 27 Application Text Menus ee eee a E E E E A reneuystrevunsereaa 45 Figure 28 IAP Text Mode Text Me mu ao esto peers 45 Figure t29 TRAMIExec tedilAR Mexi Mode Texti Menur an sean ase ane eee 48 Rev 1 00 3 of 49 July 14 2011 S91N614 10 S17 32 bit ARM Cortex M3 MCU HA HT32 Series HOLTEK www holtek com List of Tables TablesieeRrocessingrStatussand RESUIISIMESS ay eee ae anes 117 Ta A DA EE 22 Hable RG E E oo ens ctticevene opt eeee 23 Table 4ealSPeSetupsenialRom onmectiOmpreurn Gti On peceeseeeseseet eases eee ee eee 24 Tablevo lsPaClosesenialRontConnecty RUM te iiesesseeess eases eee ee 24 Tables6 s1S Ps Erase Rage FUNCION S reece excuse e se ee ceeee tee see erence reece eee 25 A Ru iM Clloneccrcce ccs cree cee cece ns coe cuecese coe ret es Sec meee reece re cate eee ere eee ee 25 Table G24lSP2Blank Meck A creer cesar ese cacao ea ee cee orca ee oa a ee eee 26 Table 9 ISP WrteProgramB FUNCOM a e ea a e a 26 Table 10 ISP CRCCheck FUNCION toto 2 Table 11 ISP ReadData FUNCION ea ee e e a a a E E E E e a 2m Table 12 ISP Execute FUNCION a n arene e a esco 28 Tableta ISP EXIVF UNION aeaa ere ee T a a a E A E fous ees eceay elie 28 Table I4 ISP Reset FUNCION enne reee e a E A E E E E rues 28 Tables TISPRISConnectedi
38. otection Setting T Update Protection Setting Page Protection Perr T Coane Security T Option Byte Write Protection T Security Protection Flash Memory 1090 01q PUBLILIOO Yse 4 ZELH 090 0 d PUBWIWOD YSE Y ZE LH 2998419 U UOE9IUNLUWO sjesaydilag 9 uajs s 0x00000000 Flash Operations G Necessary pages All pages Erase T Blank 9 Program 7 Verify I CRC Run Po Conecte Holtek HT32 Series Flash Programmer AR HOLTEK 0x1F000000 NOW Sees ZELH COMI 115200 fretting int Auto Connect Off Auto Programming Off HT22F1253 ISP sjesoyduad 9 W3S A _ 0x00000000 090 0 4 PUEBLOS YSe y ZELH Host Device Figure 1 ISP IAP Programming Tools System Architecture Rev 1 00 5 of 49 July 14 2011 uononpo ju 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK www holtek com ISP and IAP Overview The ability to update application firmware is an important consideration for end products with limited communication interfaces and embedded flash memory systems A software controlled Flash programming method is thus required to erase and program the Flash memory via the predefined communication interface In System Programming ISP provides a preloaded ISP bootloader that will communicate with the PC software following Holtek s HT32 Flash Command Protocols to update the Flash memory In Application Programming IAP plays the same
39. pages is selected then only the specified Flash pages will be affected The page target range will depend on the image size If All pages is selected then all the Flash memory pages will be erased or blank checked This function can be used to erase all the device contents The following figure shows the Flash operation related settings YY Holtek HT32 Flash Programmer Y 1 0 0 Project E Help H Programming Chip Status Memory Code Memory Data About Port Name com BaudRate 115200 v auto Connect Image Selection File Size File Size FFFFF onfigure Security Option Byte Write Protection Security Protection Flash Operations Necessary pages All pages Erase Blank Program verity CRC C Run C Auto Programming Programming Holtek HT32 Series Flash Programmer HA HOLTEK COM 1 115200 setting ini Auto Comect Off Auto Programming Off N A Figure 15 Flash Operation Related Settings Rev 1 00 16 of 49 July 14 2011 Jawuweiboig yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Processing Status and Results Message The processing status and their results can assist with understanding the operational situation This is shown in the figure below A full message description is shown in Table 1 5555555 5ERS55REH Connected Iar Operations success Holtek HT32 Series Flash Programmer HA HOL
40. r pointer for CRC result Return ISP_CMD_OK Successful operation ISP_INVALID_PARAMETER Invalid parameter ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_CMD_EXECUTE_FAILED Failed operation Example BYTE bValue 2 ISP_CRCCheck 0xc00 Oxfff amp bValue E ISP_ReadData Table 11 ISP_ReadData Function API INT ISP_ReadData DWORD dwStartAddress DWORD dwEndAddr BYTE pbValue Descriptions Read Flash memory data from device Parameter dwStartAddr Flash memory start address dwEndAddr Flash memory end address pbValue Buffer pointer to which data will be read Return ISP_CMD_OK Successful operation ISP_INVALID_PARAMETER Invalid parameter ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_SECURITY_LOCK Security lock is enabled ISP BAD EW REPLY DATA Return value from firmware is invalid Example Rev 1 00 Byte buffer 16 ISP_ReadData 0xc00 OxcOf buffer Read 16 bytes from Main Flash address Oxc00 27 of 49 July 14 2011 Jawuweiboi1g yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK S 7 www holtek com B ISP_Execute Table 12 ISP_E
41. rammer will be provided and information regarding flash programmer development will also be given A further chapter will discuss details regarding the ISP and IAP firmware including command protocols ISP Boot loader and also the IAP example code HT32 Flash Programmer Overview The main tasks of the HT32 Flash Programmer are for code data programming of user applications and for flash protection setting Additionally the current status of the target device such as device name flash size code data information and the protection settings can be queried and displayed on the GUI The Flash Programmer communicates with the ISP IAP firmware via the UART interface and then uses pre defined protocols commands to apply flash operations Users can select flash images adjust the flash protection settings and assign suitable flash operations through the GUI After a few simple steps the image will be downloaded to the target device automatically Holtek HT32 Flash Programmer BB Holtek HT32 Flash Programmer 1 0 0 Project Help NOW Seas ZELH Programming Chip Status Memory Code Memory Data About PortName com BaudRate 115200 y I Auto Connect Image Selection Z Code C Program Flestotek HT32 SeriestHT32 Flash Programmeridatalimage bin File Date 2010 09 30 FileSize 26672Bytes CRCO 0x6F2F C Program Files Holtek HT32 Series HT32 Flash Pragrammeridetaldata dat FieDate 000325 File Ste Sia 5yie mo iFa y Pr
42. role except that it implements the programming procedure while the application is running The IAP code just like a normal application must first be programmed into the Flash Memory using other methods such as an ISP a USB debugger or a Flash Writer The area with dotted line in the figure below is the Flash memory that can be updated by ISP IAP 0x400 or above ISP IAP User Data 944 bytes or above 0x50 _DDATE _DSIZE _CRC1 Reserved 0x40 I_CDATE _CSIZE _CRCO Reserved A 0x30 P a e OB_CK Reserved Reserved Reserved Option Byte 0x20 Option Byte A OB_CP Reserved Reserved Reserved 0x1FFO_0000 0x10 eee OB_PPO OB_PP1 OB_PP2 OB_PP3 0x00 ISP UART Bootloader 0x1F00_0000 n ae ees ee es UI Mode ee es eee F Main Main Holtek HT32 Flash Programmer 0x0000_0C00 3K UART IAP 0x0000_0000 j Text Mode 0x0000_0000 Figure 2 Memory organization of ISP and IAP Rev 1 00 6 of 49 July 14 2011 uononpowjuy 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com 2 Using the HT32 Flash Programmer The following section describes how to install the HT32 Flash Programmer download an image configure the option byte and also how to develop a custom flash programmer for the HT32 series of MCUs using Holtek s Windows DLL Installing the HT32 Flash Programmer The recommended system requiremen
43. the example code IAP Text RAM which will be executed in RAM provides an alternative solution for updating the IAP firmware itself This example code uses link script to specify the load view and execute view of the image s RO code The RO code is located at the beginning of the main Flash and is copied to RAM by the C library before the AP routine starts Since the IAP routine is located in RAM during execution it can erase and re program the whole IAP image in the main Flash Note that during the download process the target board must not be powered off or reset otherwise the download process will fail and the target will be unable to boot from the main Flash anymore In the above situations it is required to use the ISP ICP or Flash Writer to download the IAP image Refer to the IAP Text section to build and download the IAP Text RAM example code into the target board This example code will display a Text menu via the UART as shown below Here for example press 3 to start Xmodem and update the IAP firmware Holtek Semiconductor Inc IAP Example Code 1 Execute The New Program 2 Download Image to Flash 3 Update IAP Firmware 4 Disable The Write Protection Figure 29 RAM Executed IAP Text Mode Text Menu Rev 1 00 48 of 49 July 14 2011 aJeMUI dYI Pue ds 24 Busy 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK www holtek com Holtek Semiconductor Inc Headquarters No 3 Cr
44. the path has been chosen ie Setup Holtek HT32 Flash Programmer Select Destination Location Where should Holtek HT 32 Flash Programmer be installed O Setup will install Holtek HT32 Flash Programmer into the following folder To continue click Next If you would like to select a different folder click Browse C Program Files Holtek HT 32 Series H1 32 Flash Programmer Atleast 1 9 MB of free disk space is required Figure 4 HT32 Flash Programmer Installation Select Installation Path Rev 1 00 8 of 49 July 14 2011 Jawuweiboig yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Step 4 Press the Install button to start the installation when the ready to install screen appears A Setup Holtek HT32 Flash Programmer Ready to Install Setup is now ready to begin installing Holtek HT32 Flash Programmer on your computer Click Install to continue with the installation or click Back if you want to review or change any settings Destination location C Program Files Holtek HT 32 Series HT 32 Flash Programmer Install Cancel Figure 5 HT32 Flash Programmer Installation Ready to Install Page Rev 1 00 9 of 49 July 14 2011 Jauweiboi1g USB ZE LH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Step 5 Once the installation has finished a completion page will appear as shown below Choose whether or
45. ts are A host computer running Microsoft Windows XP Vista or Windows 7 GB RAM and 20 MB of available hard disk space is recommended XGA 1024x768 colour monitor or higher display resolution A mouse or other pointing device S A CD ROM drive optional The following steps show how to install the HT32 Flash Programmer into the computer Step 1 Obtain the latest version of the HT32 Flash Programmer from the Holtek website or from the CD ROM supplied by Holtek The required filename is similar to HT32_Flash_ Programmer Vnnn exe where nnn represents the version number Step 2 Double click on HT32_ Flash Programmer Vnnn exe and press the Next button on the dialog below to continue ie Setup Holtek HT32 Flash Programmer Welcome to the Holtek HT32 Flash Programmer Setup Wizard This will install Holtek HT32 Flash Programmer 1 00 on pour computer It is recommended that you close all other applications before continuing Click Next to continue or Cancel to exit Setup b Cancel Figure 3 HT32 Flash Programmer Installation Welcome Page Rev 1 00 7 of 49 July 14 2011 Jauweiboi1g ysel4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Step 3 The default installation path is C Program Files Holtek HT32 Series HT32 Flash Programmer Select the Browse button to change the path and select the Next button to continue when
46. vious operation has finished The HT32 Flash Programmer will then start Flash operations automatically when the device is connected The Auto Connect and Auto Programming functions will help to reduce the manual operation time during high volume device programming E ae Process finish gt mwa S Programmer Processing Start ig ee ae Sn lt No response from device or v A to Connect E or Auto Programming ee cars Wi lt o oo 0 Connected Connecting Cs Device on line checking Device Probing Se Get response from device ae Figure 17 Auto Connect and Auto Programming Rev 1 00 18 of 49 July 14 2011 Jawuweiboig yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOLTEK www holtek com Device Status After the programmer is connected information such as device name Flash size connection mode will be queried by the HT32 Flash Programmer and displayed under the Chip Status tab If the device has been programmed before the image information such as date size and CRC value will be shown in the upper right area The current protection settings will also be displayed Holtek HT32 Flash Programmer F 1 0 0 Project E Help H ae Programming Chip Status Memory Code Memory Data About Chip Code Chip Name HT32F1253 File Date File Size CRCO 2010 09 30 28672 Bytes 0x8F2F Flash
47. x axf bin AP Binary file of application s Download Right click on the project name Project_AP in Project window and click on Set as Active Project Select the LOAD icon to download the IAP and application into the Flash memory Debug Ensure that the active project is Project_AP Select Ctrl F5 to enter the debug mode The IAP debug symbol will be loaded by iap ini Since both IAP and application images have been loaded into uVision trace the program switching behavior between the IAP and the application For the IAR EWARM Rev 1 00 Build Double click on EWARMv5 4 Project eww to open the multi project file Press F8 or select Project Batch Build to open the Batch Build window Select the required device name such as HT32Fxxxx Select the Make or Rebuild All button to build both the IAP and the application The programming tools output files are as follows EWARMVS 4 HT32Fxxxx Exe HT32Fxxxx_IAP_AP bin Binary file of both IAP and application EWARMVS 4 HT32Fxxxx Exe HT32Fxxxx_AP bin Binary file of application Download Ensure that the active project is Project_IAP HT32Fxxxx by selecting the drop down list in the Workspace window Select Project Download Download active application to download the IAP and the application into the Flash memory Debug Ensure that the active project is Project_ AP HT32Fxxxx Press Ctrl D
48. x55AAFAF5 Application SP and PC valid IAP Mode Application Note Application can set SBVTO as Ox55AAFAP5 and trigger a reset to start IAP mode SBVT registers only reset by Power on reset Figure 25 IAP mode Boot Flow Rev 1 00 41 of 49 July 14 2011 SJeMUJIA dYI Pue dS 24 Bush 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com Rev 1 00 The LAP example code is a part of the HT32 series firmware library Obtain the latest version of the HT32 series firmware library from Holtek s website or the supplied Holtek CD ROM The IAP example code includes four folders as shown in Figure 26 O ET32F 000_FWLib 5 example IAP O AP_Example O IAP_Text O IAP_Text_RAM 5 IAP_UI O library O project_template utilities H E Figure 26 IAP Example Code Folders AP Example shows how to set the RO address for IAP usage By default the RO address will be set to 0xC00 for the IAP application The first 3k Bytes is reserved for the IAP IAP Text and IAP UI provide an example of the IAP mode using the UART interface Details regarding the IAP text mode and the AP UI mode will be provided in the following sections Additionally IAP_ Text_RAM provides example code for self updating the IAP firmware 42 of 49 July 14 2011 aJeMUI dYI Pue dSI 24 Busy 32 bit ARM
49. x_flash icf EWARM IAP link script file ht32fxxxx_flash icf EWARM application link script file IAP_UI MDK_ARM Project uvmpw MDK ARM multi project file iap_startup_ht32fxxxx s MDK ARM IAP startup file startup_ht32fxxxx s MDK ARM application startup file iap s ASM file that includes IAP binary with application iap lin MDK ARM link script file iap_ht32fxxxx ini Debug initialisation file Additionally this example uses a multi project to manage both the IAP program and the user s application A multi project helps to build download debug both the IAP and the application at the same time The following steps show how to build download debug using a multi project setup Rev 1 00 46 of 49 July 14 2011 aJeEMUI dYI Pue dS 24 Bush 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com For the Keil uVision Build Double click on MDK_ARM Project uvmpw to open the multi project file Select the Batch Build icon on the toolbar or tick Project Batch Build to open the Batch Build window Tick the required device name such as HT32Fxxxx located in both Project AP and Project IAP Select the Build or Rebuild button to build both the IAP and the application The output files for the programming tools are as follows MDK_ARM Obj IAP_AP_HT32Fxxxx hex HEX file of both IAP and application MDK ARM Obj IAP_AP_HT32Fxxx
50. xecute Function API INT ISP_Exectue VOID Parameter None Return ISP_CMD_OK Successful operation ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_DEVICE_NOT_FOUND Device not found ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_CMD_EXECUTE_FAILED Failed operation Example ISP_Execute E ISP_Exit Table 13 ISP_Exit Function API INT ISP_Exit VOID Parameter None ISP_CMD_OK Successful operation ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected Return ISP_DEVICE_NOT_FOUND Device not found ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written Example ISP_Exit B ISP_Reset Table 14 ISP_Reset Function API INT ISP_Reset VOID Descriptions Reset the device Parameter None ISP_CMD_OK Successful operation ISP_SERIAL_PORT_NOT_CONNECTED COM port can not be connected ISP_DEVICE_NOT_FOUND Device not found pu ISP_SERIAL_PORT_UNABLE_READ COM port can not be read ISP_SERIAL_PORT_UNALBE_WRITE COM port can not be written ISP_RESET_ERROR Reset error Example ISP_Reset Rev 1 00 28 of 49 July 14 2011 Jauweiboig yse 4 ZELH aui Buisn 32 bit ARM Cortex M3 MCU HT32 Series HOUTEK 7 www holtek com E ISP_IsConnectedToDevice Table 15 ISP_IsConnectedToDev
51. y check None Stop bit 1 bit Flow control None m Turn on the device power If the connection is correct a prompt string such as ISP gt will be shown in HyperTerminal or a Connected message in the HT32 Flash Programmer Since the ISP bootloader is located at an independent area it can erase program all the device Flash memory It also supports the Mass Erase and Security protection functions If the UART interface and boot setting is accessible in the end products the ISP bootloader can be used to update the application as well as the IAP firmware 39 of 49 July 14 2011 SJeMUJIA dYI Pue dS ayy Bursn 32 bit ARM Cortex M3 MCU HA HT32 Series HOUTEK www holtek com IAP Example Code Introduction This section describes the text mode and UI mode of the IAP example code Figure 24 shows the architecture of the IAP example code The major part of the IAP example code is the IAP Handler module that is responsible for parsing commands and co working with other modules to finish all the operations The UART Buffer module uses RAM space with an Rx interrupt driving routine to store all the data from the host Using a large RAM buffer and interrupt driving data receiving and Flash programming operations can be handled simultaneously to reduce operation time IAP Handler receives both command and Xmodem packets from the buffer and uses the Flash Memory Controller to program the data into the Flash memory Add

Download Pdf Manuals

image

Related Search

Related Contents

Manual del usuario - Fondo de Garantías CONFE  favorito - smartThinQ  V33J  Rev J - AMETEK Programmable Power  ParsePDB.pm  Philips Main Voltage spot 871829123999400  DC155 Digital Visualizer  Pressure sprayer DS 5 C  

Copyright © All rights reserved.
Failed to retrieve file