Home

Holtek I/O 8-Bit MTP Starter Kit User's Guide

image

Contents

1. 0060 0970 0980 0990 0940 09B0 09CO 09DO OSEO 0060 00 00 00 00 00 00 00 00 0068 09F0 O9FF 0086 0941 DIE 0952 0962 09E4 0068 00 00 00 00 00 00 00 00 0070 0968 0948 O9E3 0940 0960 09CO0 094C 0959 0070 00 00 00 00 00 00 00 00 0078 0946 0958 09D8 0086 OSEE O0SED OSEB 09E7 0078 00 00 00 00 00 00 00 00 0080 09DE 09DD 09DE 09D 09BE 09ED 09BB 0957 0080 00 00 00 00 00 00 00 00 0088 097E 097D 097B 0977 0086 O9FE OSFD 09FB 0088 00 00 00 00 00 00 00 00 0090 09F O9FB O9FD 0000 0000 0000 0000 0000 0090 00 00 00 00 00 00 00 00 0098 0000 0000 1785 2899 0003 0000 0000 0000 0098 00 00 00 00 00 00 00 00 00A0 0000 0000 0000 1785 28A2 0000 1785 28 5 00A0 00 00 00 00 00 00 00 00 00A8 17EA 2845 0003 OOEB 070A OOEC 076C 008A 00A8 00 00 00 00 00 00 00 00 D00B0 076B 0004 OOEB 070 OOEC 076C 008A 076B 00B0 00 00 00 00 00 00 00 00 00B8 0004 OOEB 070A OOEC 10E3 28BF 28C0 15E3 00B8 00 00 00 00 00 00 00 00 00C0 10E4 28C3 28C4 15E4 OFO1 0365 OOEO0 OFOO 00C0 00 00 00 00 00 00 00 00 00C8 1366 OOFE1 0760 OOES 0761 OO0E6 OFOO 0261 00C8 00 00 00 00 00 00 00 00 OODO 380A 28D8 390A 28E3 OFFA 0260 3C0A 28E3 00D0O 00 00 00 00 00 00 00 00 DOD8 1F65 1F66 1467 OOEO 0760 00E OF63 0260 00D8 00 00 00 00 00 00 00 00 QOOEO 3COA 28E3 1F67 076C 008A 076B 0004 10E3 DOEO0 00 00 00 00 00 00 00 DD DOES 28FF 1462 OOED OF06 026D 3C0A 28
2. Related Files Total read bits Clear WR Data Prepare the place where the read bit Will be stored Move read data to high bit EEPROM prepares the data at the rising edge Read data bit if it is 0 don t change bit value If it ig l set the WR Data All data bits have been read If no continue to read Move the read data to the accumulator ACC EE DATA MTP is the downloaded file when you want to run this tutorial program Browse and specify this file name in the File menu Open command in Fig 1 7 EE DATA ASM is the assembly source file for this program and EE DATA1 C is the C language source file 30 HOLTEK f Chapter 2 Tutorial Programs Flowchart Read Initial value from EEPROM Set current time Initial value Start Timer Display current time Key Pressed 7 Save current time to EEPROM Tutorial 5 Melody This tutorial program controls the buzzer to play songs by programming two internal timers in the HT48E50 microcontroller The clock source of the buzzer output in the HT48E50 is origi nates from two timers Timer 0 and Timer 1 The internal Timer 0 contains an 8 bit programma ble count up counter and Timer 1 contains a 16 bit programmable count up counter Their clock may come from an external source or from the system clock In this tutorial program the buzzer clock source originates from Timer 1 and the clock source for Timer 1 originates from the system clock divided by 4 T1 Different
3. changed Operation ACC 3 ACC 0 lt m 7 m 4 ACC 7 ACC 4 lt m 3 m O Affected flag s None 53 HOLTEK f SZ m Skip if Data Memory is O Description If the contents of the specified Data Memory is 0 the following instruction is skipped As this requires the insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is not O the program proceeds with the following in struction Holtek I O 8 Bit MTP Starter Kit Users Guide Operation Skip if m O Affected flag s None SZA m Skip if Data Memory is 0 with data movement to ACC Description The contents of the specified Data Memory are copied to the Accumulator If the value is zero the following instruction is skipped As this requires the insertion of a dummy in struction while the next instruction is fetched it is a two cycle instruction If the result is not O the program proceeds with the following instruction Operation ACC lt m Skip if m 0 Affected flag s None SZ m i Skip if bit i of Data Memory is 0 Description If bit i of the specified Data Memory is 0 the following instruction is skipped As this re quires the insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is not 0 the program proceeds with the following instruc tion Operation Skip if m i O Affected flag s None TABRDC m Read table curren
4. Chapter 3 Modify the Tutorial Programs Chapter 3 Modify the Tutorial Programs This chapter helps users in modifying the tutorial program to suit other applications Before Starting you have to install HT IDE3000 on your PC Build a New Project for Tutorial Programs Enter the HT IDE3000 by selecting Start Program Group HT IDE3000 Create a new project by selecting Project New command Set Project Name to buzzer Select HT48E50 as the microcontroller Press the OK button The Configuration Option dialog box is displayed then set the configuration the same as with the following sections which depends on the tutorial program Add the source file to the project by selecting Project Edit command Browse the directory select the file BUZZER ASM only or BUZZER1 C only press ADD button to add into the project press OK button to complete the project edit Build the project by selecting Project Build command The downloaded file BUZZER MTP is generated Then follow the section Run the Starter Kit Tutorial Program of chapter 1 to download the new file and run For other tutorial programs just change the project name source file name and configuration options then build the corresponding MTP file The following table lists the configuration set ting of each tutorial program 35 HOLTEK f Set the DIP Switch for the Clock Source When selecting the clock source of the MTP microcontroller the HT48E50 the DIO switch on
5. JONWINDI WS D asrtep SHE wer HInWEB Fig 1 9 10 HOLTEK f Chapter 1 Getting Starter Run the Starter Kit Tutorial Program Click the Start button select Program and select MTP Starter Kit Then the main window will be displayed as shown in Fig 1 10 Untitled Holtek MTP Starter Kit amp ISP cable E Joj xj Ex Edit View Upload Download Tools Help Moen Save Saves WE Select MCU Type k 1 HT45E50 MTP 2 D AHTEA8 test bool Testi2e mtp 3 HT48E30 MTP 4 HT45E06 MTP Exit Fig 1 10 Select the File menu Open command to open a tutorial file e g CLOCK MTP The contents of the file are displayed as shown in Fig 1 11 The left side of the window is the binary code of the program and the right side is the data to be written to the Data EEPROM 11 HOLTEK Holtek I O 8 Bit MTP Starter Kit Users Guide HT48E50 MTP Holtek MTP Starter Kit amp ISP cable File Edit View Upload Download Tools Help t cb aBel ft Di PP ee Program Memory ADDR 0 1 2 3 4 5 6 7 0000 2413 2213 0003 0000 28AB 0000 0000 0000 0008 2889 0000 0000 0000 28B2 0086 O9FF DIFF 0010 0909 O9F1 09E6 O9F1 O9AC O9F2 0971 09F3 0018 0921 O9F4 O9CF O9F4 096A O9FS 0903 O9F6 0020 0997 O9F6 0920 09F7 O99F 09F 0914 09F8 0028 0988 O9F8 O9F3 O9F8 0959 09F9 O9B9 09F9 0030 0913 O9FA 0968 O9FA O9B O9FA 0903 09FB 0038 094C O9FB 0990 O9FB O9D0 O9FB 090B O9FC 0040 0944 O9FC 097A O9FC O9AD O9FC 09DD O9FC 0048 090A O9FD 0934 O9
6. PDF lt 0 Affected flag s TO PDF 43 HOLTEK f CLR WDT1 Pre clear Watchdog Timer Description The TO PDF flags and the WDT are all cleared Note that this instruction works in con junction with CLR WDT2 and must be executed alternately with CLR WDT2 to have ef fect Repetitively executing this instruction without alternately executing CLR WDT2 will have no effect Holtek I O 8 Bit MTP Starter Kit User s Guide Operation WDT cleared TO O0 PDF lt 0 Affected flag s TO PDF CLR WDT2 Pre clear Watchdog Timer Description The TO PDF flags and the WDT are all cleared Note that this instruction works in con junction with CLR WDT1 and must be executed alternately with CLR WDT1 to have ef fect Repetitively executing this instruction without alternately executing CLR WDT1 will have no effect Operation WDT cleared TO 0 PDF lt 0 Affected flag s TO PDF CPL m Complement Data Memory Description Each bit of the specified Data Memory is logically complemented 1 s complement Bits which previously contained a 1 are changed to O and vice versa Operation m lt m Affected flag s Z CPLA m Complement Data Memory with result in ACC Description Each bit of the specified Data Memory is logically complemented 1 s complement Bits which previously contained a 1 are changed to 0 and vice versa The complemented re sult is stored in the Accumulator and the contents of the Data Memory remain un c
7. 5 Instruction Definition ADC A m Add Data Memory to ACC with Carry Description The contents of the specified Data Memory Accumulator and the carry flag are added The result is stored in the Accumulator Operation ACC ACC m C Affected flag s OV Z AC C ADCM A m Add ACC to Data Memory with Carry Description The contents of the specified Data Memory Accumulator and the carry flag are added The result is stored in the specified Data Memory Operation m ACC m C Affected flag s OV Z AC C ADD A m Add Data Memory to ACC Description The contents of the specified Data Memory and the Accumulator are added The result is stored in the Accumulator Operation ACC lt ACC m Affected flag s OV Z AC C 41 ADD A x Add immediate data to ACC Description The contents of the Accumulator and the specified immediate data are added The re sult is stored in the Accumulator Operation ACC ACC x Affected flag s OV Z AC C ADDM A m Add ACC to Data Memory Description The contents of the specified Data Memory and the Accumulator are added The result is stored in the specified Data Memory Operation m ACC m Affected flag s OV Z AC C AND A m Logical AND Data Memory to ACC Description Data in the Accumulator and the specified Data Memory perform a bitwise logical AND operation The result is stored in the Accumulator Operation ACC lt ACC AND m Affected flag s
8. Alas SWI SW2 SW3 SW4 RP4 en 51KX4 D Q O O O O O aes PA4 SW5 SW6 SW7 SWS u__ u__ u __ un __ O Q O O O _ PAS SW9 SW10 SWII SWI2 s O Q O E E Lr O OQ PAG SWB Sv E S Wd e moc Q e v E O PA7 lo lt e e RP5 5 1KX4 A V o o mnm oN OIOI clle NITA w m len keel e eale 38 HOLTEK Chapter 4 MTP Starter Kit Board Vss supply for48E06 VCC R4 lohm R5 E lohm i Cl IOuf 10V C2 0 1uf Tem 0 1uf VDD VCC DSI GEM4201BG C7 USBD R7 DIG2 V2 u 47pf O luf Ul I elolaimiiocola PBS us 560X4 De PA2 PAI PAO PBI BZ PBO BZ PB6 PB7 PA4 PAS PA6 PA7 PB3 OSC2 PG2 PB2 OSC1 PG1 VDD RES VSS PCS TMRI PGO INT PCO TMRO PCI PB4 INDI P BS IND2 P B6 IND3 PB7 IND4 GND 39 PC4 PC3 PC2 PCO R20 TMR 220 arge 3 N Discharge 2 dn 19 VDD CIL 3 bi I8 RC RESB 4 17 TMR Y PAO PA4 5 16 PAO 3E ES AC mi VDD V330 V330 13 USBD 9 USBD 12 USBD USBD 11 HT82K96E 20SOP VCC VSS_CTL UsBD T cio Y _ O luf xUSBD xUSBD RC ohm R16 10K R14 100K ID Io I CNI VDD USBD USBD VSS SHELL USB MINI B D1 IN4148 C12 0 01uf R13 100K RIS VDD 10K SW20 RESET GND 0 01uf VCC C6 0 1uf GND X2 12M C17 Cl 22pf 22pf GND HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide 40 Chapter
9. Kit Users Guide Specify the path you want to install the MTP starter Kit in Fig 1 3 and click the lt Next gt button Select Destination Location Where should Holtel MTP Starter Kit be installed JC Progrem Filesi HT MTP Starter Kit Fig 1 3 Then specify the shortcut name which will be inserted into the Program Group of the Start Menu in Fig 1 4 ie setup Holek MTP starter Eit Select Start Menu Folder Where should Setup place the pragram amp shortcuts setup will create the program s shortcuts m the following Start Menu older To continue click Hest Bronse x HI MEP Starter Fat Fig 1 4 HOLEN Holtek I O 8 Bit MTP Starter Kit Users Guide Ready to Install Setup is now ready to begin installing Holtek MTP Starter Kit on pour computer HOLTEK f In Fig 1 5 press the lt Install gt button to start installing All the corresponding files will be cop ied to the specified destination location If the process is successful Fig 1 6 will be shown Press the lt Finish gt button and you can run MTP Starter Kit utility now Chapter 1 Getting Starter Completing the Holtek MTP Starter Kit Setup Wizard To complete the installation of Holtek MTP Starter Kut Setup must restart your computer Would pau like to restart rior Yes restart the computer now C No wall restart the computer later Fig 1 6 HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide
10. Run the Starter Kit Built in Sample Connect the MTP Starter Kit PCB to the USB port of the PC using the USB cable then the sample program residing in the MTP microcontroller will be executed automatically The LEDs light up one by one and the two 7 segment displays will show the count number The built in sample program will be erased when you download other tutorial program into MTP microcontroller The file LIGHT MTP is the built in sample program which you can down load it again for demonstration If the PC system is Win95 98 and no USB driver is installed then Fig 1 7 Will be displayed press the Next button Add New Hardware Wizard This wizard searches for new drivers for USB Human Interface Device hardware device work Fig 1 7 HOLTEK f Fig 1 8 will be displayed select the Search the best driver for your device press the Next button Add New Hare Hardware Wizard What do you want tvm dows to do Chapter 1 Getting Starter E Bs earch for the pen diver for your device poten ES you ee ae you or Fig 1 8 HOLTEK f Fig 1 9 will be displayed Select the CD ROM drive and insert the Win93 System CD into the CD ROM then press lt Next gt button and follow the instructions to install the driver Holtek I O 8 Bit MTP Starter Kit Users Guide ur ar uid dd ak the fall 2 in ns Click Nest to start the search ir Terga windows Update Specify location
11. file for this program and SCANKEY 1 C is the C language source file 19 HOLTEK f Flow Chart Holtek I O 8 Bit MTP Starter Kit Users Guide Scan key Start Initial PAO PA3 as output PA4 PA7 as input Output 0000 from PAO 3 PACZOFO0h PA 00h keyX PA amp OFOh get high nibble Define PAO 3 as input PA4 7 as output Output 0000 to PA4 7 PAC 0Fh PA 00h keyY PA amp OFh Look up the table get the key code End 20 HOLTEK f Chapter 2 Tutorial Programs Tutorial 3 Timer Display This tutorial program presents how to use the timer When the timer starts the 7 segment LED will display the time from 1 second to 99 seconds When is exceeds 99 seconds it will re set to O0 and continue to count from 1 Press the sw18 button to stop the timer Restart count ing from where it stopped by pressing the sw18 button again The sw19 button will reset the time count to 0 Timer O is used for the Stopwatch It is an 8 bit internal timer which originates from the system clock The time base for Timer O is set to 1ms therefore a time of one second has elapses when the Timer O s interrupts have occurred 1000 times In order to perform the above func tion an initial value for Timer O register TMRO must be calculated first The value in this regis ter increases by one each time an internal clock pulse is received The Timer O will count from this initial value to the full count value of FFH at which point the Timer O ov
12. insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is not 0 the program proceeds with the following instruction Operation m m 1 Skip if m 0 Affected flag s None SIZA m Skip if increment Data Memory is zero with result in ACC Description The contents of the specified Data Memory are first incremented by 1 If the result is O the following instruction is skipped The result is stored in the Accumulator but the speci fied Data Memory contents remain unchanged As this requires the insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is not O the program proceeds with the following instruction Operation ACC m 1 Skip if ACC 0 Affected flag s None SNZ m i okip if bit i of Data Memory is not O Description If bit i of the specified Data Memory is not O the following instruction is skipped As this requires the insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is O the program proceeds with the following instruc tion Operation Skip if m i O Affected flag s None SUB A m Subtract Data Memory from ACC Description The specified Data Memory is subtracted from the contents of the Accumulator The re sult is stored in the Accumulator Note that if the result of subtraction is negative the C flag will be clear
13. m i i 0 6 m 0 lt C C lt m 7 Affected flag s C RLCA m Rotate Data Memory left through Carry with result in ACC Description Data in the specified Data Memory and the carry flag are rotated left by 1 bit Bit 7 re places the Carry bit and the original carry flag is rotated into the bit O The rotated result is stored in the Accumulator and the contents of the Data Memory remain unchanged Operation ACC i 1 lt m i i 0 6 ACC C C lt m 7 Affected flag s C RR m Rotate Data Memory right Description The contents of the specified Data Memory are rotated right by 1 bit with bit O rotated into bit 7 Operation m i lt m i 1 i 0 6 m 7 lt m O Affected flag s None RRA m Rotate Data Memory right with result in ACC Description Data in the specified Data Memory and the carry flag are rotated right by 1 bit with bit O rotated into bit 7 The rotated result is stored in the Accumulator and the contents of the Data Memory remain unchanged Operation ACC i lt m i 1 i 0 6 ACC 7 lt m 0 Affected flag s None 49 RRC m Rotate Data Memory right through Carry Description The contents of the specified Data Memory and the carry flag are rotated right by 1 bit Bit O replaces the Carry bit and the original carry flag is rotated into bit 7 Operation m i lt m i 1 i 0 6 m 7 lt C C lt m 0 Affected flag s C RRCA m Rotate Data Memory right through C
14. result is displayed on the screen Verify Data Read the data from the MTP microcontroller s Data EEPROM and check if it is the same as the contents on the active window the result is displayed on the screen Verify ALL Read both program code and data from the MTP microcontroller then check them with the corresponding active window the result is displayed on the screen ioi x File Edit View Upload Download Tools Help m X E Program P EFData emory a EEData Memory R ALL ri ADDR 0 1 2 3 4 5 6 7 0000 2413 z 28AB 0000 0000 0000 0000 48 4F 4C 54 45 4B 00 00 HOLTEE 0008 28B9 ALLEE 0086 DIFF DIFF 0008 00 00 00 00 00 00 00 00 0010 0909 ify EEData 09AC 09F2 0971 09F3 0010 00 00 00 00 00 00 00 00 0018 0921 C verify Al 096A 09F5 0903 09F6 0018 00 00 00 00 00 00 00 OO 0020 0997 099F 09F7 0914 O9FS 0020 00 00 00 00 00 00 00 00 0028 0988 O9F8 O9F3 O9F8 0959 09F9 09B9 09F9 0028 00 00 00 00 00 00 00 00 0030 0913 O9FA 0968 O9FA O9B 09F 0903 09FB 0030 00 00 00 00 00 00 00 00 0038 094C O9FB 0990 09FB O9D0 09FB 090B 09FC 0038 00 00 00 00 00 00 00 00 0040 0944 O9FC 097A O9FC 09AD 09FC 09DD 09FC 0040 00 00 00 00 00 00 00 00 0048 090A O9FD 0934 O9FD 095C O9FD 0982 09FD 0048 00 00 00 00 00 00 00 00 0050 0946 O9FD 09C8 O9FD DIES O9FD 0906 09FE 0050 00 00 00 00 00 00 00 00 0058 0086 0900 0910 0920 0930 0940 0950 0960 0058 00 00 00 00 00 00 00 00
15. shutting down the starter kit completely zinixs File Edit Yiew Upload Download Tools Help Gd X G0 vo FREIEN Program ADDR 0 2 3 0000 2413 2213 0003 0000 Bower On 00 0000 008 2889 0000 0000 0000 Power Off FF O9FF 010 0909 O9F1 09E6 O9F1 71 09F3 018 0921 09F4 O9CF 09F4 096A 09F5 0903 O9F6 a EEData Memory 0 12 3 4 5 6 7 D 48 4F 4C 54 45 4B 00 00 HOLTEK 0008 00 00 00 00 00 00 00 00 0 0 oooooo0 e 20 0997 O9F6 0920 O9F 099F O9F 0914 O9FS 0020 00 00 00 00 00 00 00 00 028 0988 O9F8 O9F3 O9F8 0959 O9F9 O9B9 09F9 0028 00 00 00 00 00 00 00 00 0030 0913 O9FA 0968 O9FA 09B O9FA 0903 O9FB 0030 00 00 00 00 00 00 00 00 0038 094C O9FB 0990 O9FB 09D0 O9FB 090B 09FC 0038 00 00 00 00 00 00 00 DO 0040 0944 O9FC 097 DIFC O9AD O9FC 09DD O9FC 0040 00 00 00 00 00 00 00 00 0048 00 00 00 00 00 00 00 00 0050 00 00 00 00 00 00 00 00 0058 00 00 00 00 00 00 00 00 0060 00 00 00 00 00 00 00 00 0048 0904 O9FD 0934 O9FD 095C O9FD 0982 09FD 0050 0946 O9FD 09C8 O9FD 09ES O9FD 0906 O9FE 0058 0086 0900 0910 0920 0930 0940 0950 0960 60 0970 0980 0990 0940 O9B0 09C0 O9D0 OSEO 68 09F0 O9FF 0086 0941 O9E 0952 0962 09E4 0068 00 00 00 00 00 00 00 00 70 0968 0948 09E3 0940 0960 09C0 094C 0959 0070 00 00 00 00 00 00 00 00 78 0946 0958 09D8 0086 O9EE O9ED SEB DIE 0078 00 00 00 00 00 00 00 00 80 09DE 0
16. the Starter Kit must be correctly set If the crystal is selected then both position 1and 4 of the DIP switch must be On and position 2 and 3 are Off If RC is selected then position 2 must be On and the rest are Off A variable resistor should be inserted in location VR2 on the Starter Kit board The capacitor is 4 70pF Holtek I O 8 Bit MTP Starter Kit Users Guide Configuration Option Table Configuration tem Buzzer Scan Key Timer EEPROM Melody System Frequency 4MHz 4MHz 4MHz 4MHz 4MHz Product 28 SKDIP A 28 SKDIP A 28 SKDIP A 28 SKDIP A 28 SKDIP A Wake up PAO PA7 Non wake up Non wake up Non wake up Non wake up Non wake up Input Type PA Seal CHI San ll all trigger trigger trigger trigger trigger Pull High PA Pull High Pull High Pull High Pull High Pull High Pull High PB Pull High Pull High Pull High Pull High Pull High Pull High PC Pull High Pull High Pull High Pull High Pull High Pull High PD Pull High Pull High Pull High Pull High Pull High Pull High PG Pull High Pull High Pull High Pull High Pull High OSC Crystal Crystal Crystal Crystal Crystal WDT Disable Disable Disable Disable Disable cLRWOT Fee P Foi iod ee T1 System T1 System T1 System T1 System T1 System WO EISEN SONIEE coe cn Ah m ain PB01 Buzzer BZ BZ PBO PB1 PBO PB1 PBO PB1 BZ BZ LVR Disable Disable Disable Disable Disable LVR Voltage 3 0V 3 0V 3 0V 3 0V 3 0V BZ Source Timer O Timer O Timer O Timer O
17. this Selection Guide THESE MATERIALS ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED Holtek further does not warrant the accuracy and indirect incidental or consequential damages including without limitation lost revenues or lost profits which may result from use of these materials Holtek s products are not authorized for use as critical components in life support devices or systems Holtek may make changes to these materials or to the products described therein at any time without notice Holtek makes no commitment to update the information contained herein For the most up to date information Please visit our web site at http www holtek com tw www holtfek com Tw
18. timer counter preload values will result in different overflow times and therefore gen erate different output frequencies for the buzzer The 16 bit Timer 1 is selected as the clock source for the buzzer in this tutorial program The frequencies of 7 basic musical note in octave 5 i e Do Re Mi Fa So La Ti are 523Hz 58 Hz 659Hz 698Hz 83Hz 880Hz 987Hz respectively 91 HOLTEK f The corresponding preload value for Timer 1 is calculated as follows the system clock is se lected to be 4MHz tt X R 1 4x10 4 oo Holtek I O 8 Bit MTP Starter Kit User s Guide Where R is the count until timer overflow and fnote is the frequency of the note Then R is equal to 778h when fnote is 523Hz the note Do The initial value for the Timer 1 preload reg ister is O 778h F888h The low byte is 88h and the high byte is F8h The following table lists the initial value of the Timer 1 preload registers for the notes Note TIMER 1 Initial Value TMR1H Hex TMR1L Hex Do 523 f8H 88H gt 587 f9H 59H Mi 659 faH 13H Fa 698 faH 68H BO 783 fbH 03H La 880 fbH 90H u 987 fcH 06H Timer O is selected as the base timer for a musical note s duration in this tutorial program Timer 0 generates an interrupt every 8 milliseconds and a note duration is set to be a multiple of the base time The variable T Counter is such a multiple then the note duration 8 msxT Counter Accor
19. 9DD O9DB 09D 09BE O9BD 09BB 0987 0080 00 00 00 00 00 00 00 00 88 097E 097D 097B 0977 0086 O9FE O9FD O9FB 0088 00 00 00 00 00 00 00 00 090 09F SFB O9FD 0000 0000 0000 0000 0000 98 0000 0000 1785 2899 0003 0000 0000 0000 0A0 0000 0000 0000 1785 28A2 0000 1785 28A5 OA8 17EA 2845 0003 OOEB 070 OOEC 076C 008A OBO 076B 0004 OOEB 070A OOEC 076C 008A 076B 0B8 0004 OOEB 070A OOEC 10E3 28BF 28C0 15E3 CO 10E4 28C3 28C4 15E4 OFO1 0365 OOEO OFOO 00C8 1366 ODE1l 0760 OOES 0761 DOES OFOO 0261 00D0 380A 28D8 390A 28E3 OFFA 0260 3C0A 28E3 00D8 1F65 1F66 1467 OOEO 0760 00E OF63 0260 DDEU 3C0A 28E3 1F6 076C 008A 076B 0004 10E3 D 0ES 28FF 1462 OOED OFO06 026D 3COA 28F0 1F62 OOFO OFOF 0694 F 1 0362 O0BSC 208C OOED 116D 0 0F8 OEFO OOED 076D 0594 OF14 OOE3 14E2 0003 oo oo Cro ooooooo0 oo0o0000 M Cr ono e 0098 00 00 00 00 00 00 00 00 0 0 00 00 00 00 00 00 00 00 0048 00 00 00 00 00 00 00 00 00E0 00 00 00 00 00 00 00 00 00B8 00 00 00 00 00 00 00 00 00C0 00 00 00 00 00 00 00 00 00C8 00 00 00 00 00 00 00 00 00D0 00 00 00 00 00 00 00 00 00D8 00 00 00 00 00 00 00 00 00E0 00 00 00 00 00 00 00 00 00ES8 00 00 00 00 00 00 00 00 OFO 00 00 00 00 00 00 00 00 OOF8 00 00 00 00 00 00 00 00 cOoOoooootc e wo c Iw e 0100 0086 0915 0904 0915 0904 091E 0904 091C nino nana Nats NANA NAIC NANS
20. E 1 Starter Kit Contents P 1 Install the MTP Starter Kit z u z4u002200 0000 n00n anno anno nnnn nun nun nnnnnnnnnnnnnnnnnunnnnnna nenn 2 Run the Starter Kit Built in Sample 2 220022002000n000nunanunnnn seen eene nennen nnns 8 Run the Starter Kit Tutorial Program eeeeeeeeeee nnnnnnnun anna nun nun 11 Menus and Commands of the MTP Starter Kit Utility 13 Chapter 2 Tutorial Programs ess 17 eglise qu 17 Tutorial 2 Kev Matrix SCdlluonisiusdumduEiau rn 19 T torals Timer DISpIay t M 21 Tutorial 4 EEPROM Data Memory Processing eere ree 23 Tutorial 9 MELOY susanne rear iaia nennen 31 HOLTEK Contents Chapter 3 Modify the Tutorial Programs 35 Build a New Project for Tutorial Programs eere nee enne nnne 35 Set the DIP Switch for the Clock Source 1 eeeeeeeee eren rene 36 Connguration OPLON Table oc 36 Chapter 4 Target Board ia 37 Chapter 5 Instruction Definition 43 wore chapter Getting Starter Chapter 1 Getting Starter Introduction The MTP Multi Time Pro
21. F0 1F62 00E8 00 00 00 00 00 00 00 00 DOFO OFOF 0694 OFO1 0362 OB8C 208C OOED 116D OOFO 00 00 00 00 00 00 00 00 OOF8 OEFO OOED 076D 0594 OF14 OOE3 14E2 0003 DOFS 00 00 00 00 00 00 00 00 0100 0086 0915 0904 0915 0904 091E 0904 091C NINO NANA nats nana naric NAANA nate non nate m 4 2 verify Porgram memory of MCU with PC Buffer CAP NUM L 15 HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide Menu Tools The Tools menu Fig 1 14 provides commands to set the configuration options of the MTP microcontroller and to control the MTP microcontroller after programming e View Option Display the configuration options of the MTP microcontroller on the screen e Reset Implements a reset operation which has the same function as the Reset button on the toolbar e Power On Turns on the MTP microcontroller power on the starter kit This command is used when changing the MTP microcontroller on the starter kit It is used to turn off the MTP microcontroller upon replacing it with a new one then turn it on in programming the new one MTP microcontroller e Power Off When you want to replace the MTP microcontroller on the starter kit with a new one either empty or programmed the same type or another type of MTP microcontroller use this command to power down the MTP After replacing then turn on by selecting the Power On command These two commands help users in replacing the MIP microcontroller without
22. FD 095C O9FD 0982 09FD 0050 0946 O9FD 09C8 09FD DIES O9FD 0906 O9FE 0058 0086 0900 0910 0920 0930 0940 0950 0960 0060 0970 0980 0990 09A0 0980 09CO O9D0 09E0 0068 09F0 O9FF 0086 0941 OSE 0952 0962 09E4 0070 0968 0948 09E3 0940 0960 09C0 094C 0959 0078 0946 0958 09D8 0086 OSEE SED O9EB DIE 0080 09DE 09DD 09DE 09D 09BE 09BD O9BB 09B7 0088 097E 097D 097B 0977 0086 O9FE O9FD O9FB 0090 09F O9FB O39FD 0000 0000 0000 0000 0000 0098 0000 0000 1785 2899 0003 0000 0000 0000 00A0 0000 0000 0000 1785 28A2 0000 1785 2845 00A8 17E 28A5 0003 OOEB 070A OOEC 076C 008A 00B0 076B 0004 OOEB 070 OOEC 076C 008A 076B 00B8 0004 OOEB 070 OOEC 10E3 28BF 28C0 15E3 00C0 10E4 28C3 28C4 15E4 OFO1 0365 OOEO OFOO 00C8 1366 DOE1 0760 OOES 0761 OOE6 OFOO 0261 00D0 380A 28D8 390A 28E3 OFFA 0260 3COA 28E3 OOD8 1F65 1F66 1467 OOEO 0760 00E OF63 0260 00EU 3COA 28E3 1F67 076C 008A 076B 0004 10E3 00ES 28FF 1462 OOED OFO6 026D 3C0A 28F0 1F62 DOFO OFOF 0694 OFO1 0362 OBSC 208C OOED 116D OOF8 OEFO OOED 076D 0594 OF14 OOE3 14E2 0003 0100 0086 0915 0904 0915 0904 091E 0904 091C NINO NANA na 13 NANA NAIC NANS Nate NANAI na141Cc bet gt Ready CAP NUM A Fig 1 11 15 x EEData Memory 1234557 AF 4C 54 45 4B 00 00 HOLTEEK 0 e Select the Download menu ALL command as shown in Fig 1 12 This will download the program code and data to the corresponding memory of the MTP microcontroller HT48E50 HT48E50 MTP Holtek MTP S
23. LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLE 00 0 0000 Address Register Control Logic and Generator Address Decoder EECR Memory Cell Array 2K 256x8 Data Register Output Buffer Same as HT93LC56 EEPROM Data Memory Block Diagram 24 HOLTEK f READ The READ instruction will stream out data at a specified address on DO The data on DO changes during the low to high edge of SK The 8 bit data stream is preceded by a logical O dummy bit Irrespective of the condition of the EWEN or EWDS instruction the READ com mand is always valid and independent of these two instructions After the data word has been read the internal address will be automatically incremented by 1 allowing the next consecu tive data word to be read out without entering further address data The address will wrap around with CS High until CS returns to Low Chapter 2 Tutorial Programs EWEN EWDS The EWEN EWDS instruction will enable or disable the programming capabilities During both the power on and power off state the device automatically enters the disable mode Be fore a WRITE ERASE WRAL or ERAL instruction is given the programming enable instruc tion EWEN must be issued otherwise the ERASE WRITE instruction is invalid After the EWEN instruction is issued the programming enable condition remains until power is turned off or an EWDS instruction is issued No data can be written in
24. Nate nan na1Cc 4 gt View Option CAP NUM A 16 HOLTEK f Chapter 2 Tutorial Programs Chapter 2 Tutorial Programs This chapter describes the tutorial programs supplied with the MTP Starter Kit When the tuto rial program is downloaded to the Starter Kit board and executed the corresponding function will run as specified Each of the tutorial programs contain a functional description a program flowchart and the related assembly language and C language source code The source code files can be found in the related directory in the CD or hard disk These files can be modified by the user and downloaded to the starter kit for verification Refer to Chapter 3 for more information The list of tutorial programs contain the following e Buzzer e Key Matrix Scan e Timer Display e EEPROM Data Memory Processing e Melody Tutorial 1 Buzzer The BZ and BZ are a pair of complimentary buzzer signal output pins The buzzer is driven by Timer O 8 bit internal timer or Timer 1 16 bit internal timer A range of different buzzer fre quencies can be provided with the different prescaler values and with different preloaded values in Timer 0 or Timer 1 The BZ or BZ pin should be set as output pins first Setting pin BZ high will enable the buzzer function otherwise setting BZ low will disable it 17 HOLTEK f Timer O is an 8 bit count up timer which can originate from the system clock or an external clock The cloc
25. O0E1 0760 DOES 0761 OE6 OFOO 0261 00D0 380A 28D8 390A 28E3 OFFA 0260 3C0A 28E3 OOD8 1F65 1F66 1467 OOEO 0760 00E OF63 0260 QOOEQ 3C0A 28E3 1F67 076C O08A 076B 0004 10E3 00ES 28FF 1462 DOED F 6 026D 3COA 28F 1F62 OOFO OFOF 0694 OFO1 0362 BS8C 208C OOED 116D OOF8 OEFO OOED 076D 0594 OF14 DOES 14E2 0003 0100 0086 0915 0904 0915 0904 091E 0904 091C NINO NANA Nats NANA NAIC nant NAIC NANI naire m n Download program and EEData memory from MCU to PC CAP NUM P e When the download has started a progress bar indicates the download percentage Press the reset button to run the tutorial program when the download is complete 12 HOLTEK f Menus and Commands of the MTP Starter Kit Utility There are a total of seven menus File Edit View Upload Download Tools and Help which are described below Chapter 1 Getting Starter Menu File The file menu provides file processing commands as follows e Open Open an existing file with file extension name MTP This command will close the currently opened file automatically before opening the specified file e Save Write the active windows data to the active file Save As Write the active windows data to the specified file Select MCU Type Select the MTP MCU type from the list box If an MTP file has been opened already then the MCU type specified by this MTP file is selected in the list box Otherwise the default MCU type is selected User can select an MCU t
26. Semiconductor Inc Headquarters No 3 Creation Rd Il Science Park Hsinchu Taiwan Tel 886 3 563 1999 Fax 886 3 563 1189 Holtek Semiconductorn Inc Taipei Sales Office AF 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 Shanghai Sales Office 7th Floor Building 2 No 889 Yi Shan Road Shanghai China 200233 Tel 021 6485 5560 Fax 021 6485 0313 Holtek Semiconductor Inc Shenzhen Sales Office 5 F Unit A Productivity Building Cross of Science M 3rd Road Building and Gaoxin M 2nd Road Science Park Nanshan District Shenzhen China 518057 Tel 0755 8616 9908 8616 9308 Fax 0755 8616 9533 Holtek Semiconductor Inc Beijing Sales Office Suite 1721 Jinyu Tower A129 West Xuan Wu Men Street Xicheng District Beijing China 100031 Tel 010 6641 0030 6641 7751 6641 7752 Fax 010 6641 0125 Holmate Semiconductor Inc North America Sales Office 46729 Fremont Blvd Fremont CA 94538 Tel 510 252 9880 Fax 510 252 9885 Evertek Semiconductor Inc Development Tools Manufactory 503 5 F Unit C Productivity Building Cross of Science M 3rd Road Building and Gaoxin M 2nd Road Science Park Nanshan District Shenzhen China 518057 Tel 0755 8615 6156 Fax 0755 8615 6080 rer Sharing Success Through Excellence Holtek Semiconductor assumes no responsibility for errors or omissions in
27. T48E50 or 7 HT48E06 Only HT48E50 has the following instructions Output the first bit don t care bit Output 8 bits of address for the HT48E50 Only the highest 7 bits are valid for the HT48E06 Move to the next bit Generate a falling edge Total address bits have been output If noe continue to Surp r Lf yes Peturn HOLTEK f Chapter 2 Tutorial Programs e Write data to the EEPROM data memory This program outputs the data to the specified address of the EEPROM A total of 8 bits have to be written WriteData MOV A C Data Length MOV COUNT A WriteData 0 CLR OZ SET CLR RLC SET CLR o DA JMP GLR NOP SET SNZ JMP RET DI WR Data DI C WR Data SK SK COUNT WriteData 0 OF Gs DO 29 Total data bit Output the data bit Move to the next bit Generate a falling edge to write data Total data bit have been output LE qno Continue CO OULU Generate a TCDS size low pulse to start Writing Wait for the completion of writing Still writing Writing completed return HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide e Read data from the EEPROM data memory This program reads data from the EEPROM data memory and store the read data into WR_Data buffer ReadData MOV MOV CLR A C Data Length COUNT A WR Data ReadData 0 CIRC RLC WR Data SET SK p DO SET WR Data 0 CLR SK ODZ COUNT JMP ReadData 0 MOV A WR Data RET
28. Timer 1 36 HOLTEK f Chapter 4 MTP Starter Kit Board Zi Chapter 4 MTP Starter Kit Board The following is the layout of the MTP Starter Kit PCB The HT48Exx can be replaced with HT48E50 with a 28 SKDIP A package Use the correct tutorial program for demonstration HZ USB Terminal 9 LED2 LED usa HOLTEK 1 0 8 bit MTP Starter Kit C C REV B 2004 12 10 000800000000 0000000000000 t Dei OO 000806668660 o0 00000000000 Q Free Pad Matrix for User 0 u uuu u 00 00000000000 I 000808000006 00000000008 00000000000 00000000000 C l cig EJ Wd IWdzwa td vd 5Ydgwi LYd fX Terminal MCU Ports Crystal RC OSC 3 Unique Keys NR EE ee L E ee C5 CH 57 C3 CI C9 cl4 CH UZ T HT82K96E E2 o R12 01R15R13 amp 009009094 52009009 DIP Switch SW17 SW18 SW19 37 HOLTEK f Holtek I O 8 Bit MTP Starter Kit User s Guide The DIP switch selects the clock source of the MTP microcontroller as shown in the following table DIP Switch Position Clock Source 1 2 3 4 Crystal On Off Off On RC Off On Off Off Cll 0 01uf GND VDD C14 470pf 510K RIO 12K GND XI 4 0M GND SW DIP 4 OSCrc DIG2 DIG2c RP2 560X4 BZl BUZZER PBO GND 47 VDD a e e s In ol Ir lt lt lt t lt lt lt Olea clel le alas Olena la lacl
29. Z AND A x Logical AND immediate data to ACC Description Data in the Accumulator and the specified immediate data perform a bitwise logical AND operation The result is stored in the Accumulator Operation ACC ACC AND x Affected flag s Z ANDM A m Logical AND ACC to Data Memory Description Data in the specified Data Memory and the Accumulator perform a bitwise logical AND operation The result is stored in the Data Memory Operation m lt ACC AND m Affected flag s Z 42 HOLTEK f CALL addr Subroutine call Description Unconditionally calls a subroutine at the specified address The Program Counter then increments by 1 to obtain the address of the next instruction which is then pushed onto the stack The specified address is then loaded and the program continues execution from this new address As this instruction requires an additional operation it is a two cy cle instruction Chapter 5 Instruction Definition Operation Stack lt Program Counter 1 Program Counter lt addr Affected flag s None CLR m Clear Data Memory Description Each bit of the specified Data Memory is cleared to 0 Operation m 00H Affected flag s None CLR m i Clear bit of Data Memory Description Bit i of the specified Data Memory is cleared to 0 Operation m i lt 0 Affected flag s None CLR WDT Clear Watchdog Timer Description The TO PDF flags and the WDT are all cleared Operation WDT cleared TO lt 0
30. arry with result in ACC Description Data in the specified Data Memory and the carry flag are rotated right by 1 bit Bit O re places the Carry bit and the original carry flag is rotated into bit 7 The rotated result is stored in the Accumulator and the contents of the Data Memory remain unchanged Operation ACC i lt m i 1 i 0 6 ACC e C C m O Affected flag s C SBC A m Subtract Data Memory from ACC with Carry Description The contents of the specified Data Memory and the complement of the carry flag are subtracted from the Accumulator The result is stored in the Accumulator Note that if the result of subtraction is negative the C flag will be cleared to 0 otherwise if the result is positive or zero the C flag will be set to 1 Operation ACC lt ACC m C Affected flag s OV Z AC C SBCM A m Subtract Data Memory from ACC with Carry and result in Data Memory Description The contents of the specified Data Memory and the complement of the carry flag are subtracted from the Accumulator The result is stored in the Data Memory Note that if the result of subtraction is negative the C flag will be cleared to O otherwise if the result is positive or zero the C flag will be set to 1 Operation m ACC m C Affected flag s OV Z AC C 50 HOLTEK f SDZ m Skip if decrement Data Memory is 0 Chapter 5 Instruction Definition Description The contents of the specified Data Memory are fi
31. by indirect addressing mode using MP1 23 Label EECR Bits Function 0 3 Unused bit read as 0 CS 4 EEPROM data memory select SK 9 Serial clock input to EEPROM data memory DI 6 Serial data input to EEPROM data memory DO 7 Serial data output from EEPROM data memory The EEPROM data memory is accessed via a three wire serial communication interface by writing to EECR It is arranged into 256 words by 8 bits The EEPROM data memory contains seven instructions READ ERASE WRITE EWEN EWDS ERAL and WRAL For HT48E50 these instructions are all made up of 12 bits data 1 start bit 2 op code bits and 9 address bits By writing to CS SK and DI these instructions can be transmitted to the EEPROM These serial instruction data when presented at DI will be written into the EEPROM data memory on the rising edge of SK During the READ cycle DO acts as the data output and during the WRITE or ERASE cycle DO indicates the BUSY READY status When DO is active for read data or as a BUSY READY indicator the CS pin must be high otherwise DO will be in a high state For successful instructions CS must be low once after the instruc tion is sent After power on the device is by default in the EWDS state An EWEN instruction must be performed before any ERASE or WRITE instruction can be executed The following are the functional descriptions of all seven instructions DLLLELLLLLLLLLLLLLLLLLLLLLLLLLLLLL
32. care Programming the EEPROM Since the address of EECR is 40H of RAM bank 1 it can be read and written to only by indi rect addressing mode using MP1 No other location in RAM bank 1 will be used hence we can set BP to 1 MP1 to 40H during system initialization It will not be changed throughout this program In addition to the register IAR1 we can read write the EEPROM data memory by programming the EECR register The following are examples to read write the EEPROM data memory using Holtek assembly instructions 26 HOLTEK lZ der ne the constant Cs EOU oK EQU DI EJU DO EQU IAR1 4 ITAR1 5 IAR1 6 IARI 7 EECR EQU 40H C WRITECOM C READCOM EQU See EQU OO l CS is the 4th bit of IAR1 DI is the 6th bit of IARI Chapter 2 Tutorial Programs EERC register EERC register EERC register EERC register SK 1s the 5th bit of IARI DO is the 7th bit of IARI Write data EEPROM command Read data EEPROM command define the constant according to the MTP microcontroller type ifdef HT48E06 C BOO Len C Dara Len endir gnt EQU 7 gth EQU CO ifdef HT48E50 C Adar Len Daca ben endif ght EQU 8 gth EQU OD l l Condition compile for HT48E06 Total bits of EEPROM address Total bits of EEPROM data For HT48E50 Total bits of EEPROM address Total bits of EEPROM data There are four subroutines WriteCommand WriteAddr WriteData and Rea
33. cells to a logical 1 state in the pro gramming enable mode After the erase all instruction set has been issued the data erase feature is activated by a falling edge of CS Since the internal auto timing generator provides all timing signal for the erase all operation so the SK clock is not required During the internal erase all operation we can verify the busy ready status if CS is high DO will remain low but when the operation is over DO will return to high and further instruction can be executed WRAL The WRAL instruction writes data into the entire 256x8 memory cells in the programming en able mode After the write all instruction set has been issued the data writing is activated by a falling edge on CS Since the internal auto timing generator provides all timing signals for the write all operation so the SK clock is not required During the internal write all operation we can verify the busy ready status if CS is high DO will remain low but when the operation is over DO will return to high and further instruction can be executed Instruction Comments Start Bit Op Code Address Data READ Read Data 1 10 X A7 AO D7 DO ERASE Erase Data 1 11 X A A0 WRITE Write Data 1 01 X A7 A0 D7 DO EWEN Erase Write Enable 1 00 11 XXXXXXX EWDS Erase Write Disable 1 00 OO0XXXXXXX ERAL Erase All 1 00 10XXXXXXX WRAL Write All 1 00 01XXXXXXX D7 DO Note X stands for don t
34. dData to implement the EEPROM data memory operations Each command contains one start bit and two op codes a total of three bits are written e Output the command code This program outputs 3 bits of Read command 110 or Write command 101 These 3 bits are stored in bit 7 6 5 of the variable EE command WriteCommand MOV A 3 MOV COUNTS JA WriteCommand 0 CLE OL SZ EE command SET DI SET SK CLR SK CLR 9 RLC EE command SDZ COUNT JMP WriteCommand 0 RET 4 Start bit and op code of a command LoOLal DbrLbs Set the bit value of a command If bit 7 of EE command register is l Then write 1 else write 0 to DI Output the bit at the rising edge Change SK to low to prepare write the next pit Clear carry flag bit Move to the next bit being written All bits have been output If no continue to output If yes return 27 HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide e Output the address of the EEPROM memory For the HT48E50 a total of 9 bits have to be output even if only 8 bits are valid The first bitis either O or 1 don t care For HT48E06 only 7 bits are valid and output 7 bits WriteAddr MOV MOV ifndef E NOP GLR endif A C Adar L ngth COUNT A HT48E06 oK OK WriteAddr 0 CLR OZ e CLR RLC SET NOP CLR SDZ JMP RET DI ADDR Bab ADDR oK SK COUNT WriteAddr 0 e y 28 Total bits of the EEPROM address 8 H
35. ding to the index PAT1 the multiple can be taken from the scale table which contains 16 scales as follows 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255 32 HOLTEK f In this tutorial program PAT1 is defined to be 4 then T_Counter is 80 the 4th scale of the scale table Then the quarter note is equal to 640 ms 8msx80 To define PAT2 to be double PAT1 then it is 1280 ms The scale table and PAT1 PAT2 can be adjusted as desired Chapter 2 Tutorial Programs The data format of the Song Table Every note is composed of apitch and a duration value The pitch index is the first byte which refers to the Note Table The second byte is the duration value index which refers to Note Length Table The last two bytes contain O to indicate the end of the song Related Files MELODY MTP is the downloaded file to run this tutorial program Browse and specify this file name in the File menu Open command in Fig 1 7 MELODY ASM is the assembly source file for this program and MELODY1 C is the C language source file Flowchart System Initialization swl8 pressed Plav song 1 sw18 released sw 19 pressed Play song 2 7 sw 19 released 33 wore sek VO 8 Bit MTP Starter Kit Users Guide Plav song X FINISH Get the initial value of Timer 1 Get the duration value save to T COUNTER Start the Timer 1 Timer 0 and the Buzzer A note is completed 34 HOLTEK f
36. e data Program execution continues at the restored address Operation Program Counter lt Stack ACC lt x Affected flag s None RETI Return from interrupt Description The Program Counter is restored from the stack and the interrupts are re enabled by setting the EMI bit EMI is the enable master global interrupt bit bit 0 register INTC If an interrupt was pending when the RETI instruction is executed the pending Interrupt routine will be processed before returning to the main program Operation Program Counter lt Stack EMI lt 1 Affected flag s None RL m Rotate Data Memory left Description The contents of the specified Data Memory are rotated left by 1 bit with bit 7 rotated into bit O Operation m i 1 lt m i i 0 6 m O lt m 7 Affected flag s None RLA m Rotate Data Memory left with result in ACC Description The contents of the specified Data Memory are rotated left by 1 bit with bit 7 rotated into bit O The rotated result is stored in the Accumulator and the contents of the Data Mem ory remain unchanged Operation ACC i 1 lt m i i 0 6 ACC 0 lt m 7 Affected flag s None 48 HOLTEK f Chapter 5 Instruction Definition RLC m Rotate Data Memory left through Carry Description The contents ofthe specified Data Memory and the carry flag are rotated left by 1 bit Bit 7 replaces the Carry bit and the original carry flag is rotated into bit 0 Operation m i 1 lt
37. ed to O otherwise if the result is positive or zero the C flag will be set to 1 Operation ACC ACC m Affected flag s OV Z AC C 52 HOLTEK f SUBM A m Subtract Data Memory from ACC with result in Data Memory Description The specified Data Memory is subtracted from the contents of the Accumulator The re sult is stored in the Data Memory Note that if the result of subtraction is negative the C flag will be cleared to O otherwise if the result is positive or zero the C flag will be set to 1 Operation m lt ACC m Affected flag s OV Z AC C Chapter 5 Instruction Definition SUB A x Subtract immediate data from ACC Description The immediate data specified by the code is subtracted from the contents of the Accu mulator The result is stored in the Accumulator Note that if the result of subtraction is negative the C flag will be cleared to O otherwise if the result is positive or zero the C flag will be set to 1 Operation ACC ACC x Affected flag s OV Z AC C SWAP m owap nibbles of Data Memory Description The low order and high order nibbles of the specified Data Memory are interchanged Operation m 3 m 0 lt gt m 7 m 4 Affected flag s None SWAPA m Swap nibbles of Data Memory with result in ACC Description The low order and high order nibbles of the specified Data Memory are interchanged The result is stored in the Accumulator The contents of the Data Memory remain un
38. er Kit User s Guide Character 0 1 2 3 4 5 6 7 8 9 Code 41h E7h 52h 62h EAh 68h 48h E3h 40h 60h Character A b C d E F Code COh 4Ch 59h A6h 58h D8h Related Files CLOCK MTP is the downloaded file to run this tutorial program Browse and specify this file name in the File menu Open command in Fig 1 7 CLOCK ASM is the assembly source file for this program and CLOCK1 C is the C language source file Flowchart en gt System Initialization Interrupt Initialization 22 Stop timer clear time count E Start Timer HOLTEK f Chapter 2 Tutorial Programs Timer Interrupt Service Routine Interrupt count 1 Clear Interrupt count 0 seconds 1 return Tutorial 4 EEPROM Data Memory Processing This tutorial program will read a value from the data EEPROM in the MTP microcontroller as an initial time and display it on the 7 segment LED The Timer starts to count from this initial time and display until the specified key is pressed Then the Timer is stopped and the current time will be written to the data EEPROM for the next run The purpose of this program is to present how to access the data EEPROM in the MTP microcontroller EEPROM Data Memory The 256x8 bits of EEPROM data memory is readable and writable during normal operation It is indirectly addressed through the control register EECR 40H in Bank 1 The EECR can be read and written to only
39. erflows and an internal interrupt signal is generated The corresponding interrupt service routine will han dle this situation The Timer O value will then be reset with the initial value and continue count ing To calculate the initial value of the TMRO register follow the steps below e Internal timer s clock source originates from the system clock which is 4MHz in this pro gram e Select a timer prescaler rate in the TMROC register OEH 1 16 in this program Hence one internal clock pulse requires 1 4x109 16 24x10 seconds e imer 0 overflows and generates an interrupt every 1 millisecond If the remaining count to overflow is R then 4x10 9 R21ms 21x10 seconds Therefore R 250 and the initial value of TMRO register should be 256 250 or 6 Two 7 segment LEDs we use for the timer display The corresponding mapping between the segment and port is shown in following table f e 9 b C o Segment Port PA2 PA3 PA4 PA PAS PA PAO PA6 21 HOLTEK f The 7 segment LED is common anode The output pin is set to O to light up the corresponding segment of LED module which is de termined by a peripheral electric circuit for example in order to light up the segment a then PA2 pin should be set to low The following table depicts the corresponding code of each char acter from 0 9 and A F Holtek I O 8 Bit MTP Start
40. grammable Starter Kit helps in understanding the Holtek s I O 8 Bit MTP microcontroller providing a quick easy and low cost way of instruction It can also serve as an MTP programmer and demonstration board Features e Simple printed circuit board e Can be connected to the PC s USB port for communication e Easy to use MTP Starter Kit software utility e Tutorial programs for applications which can be easily modified e Supports different MTP microcontrollers Starter Kit Contents e MTP Starter Kit Printed Circuit Board PCB e USB cable e CD ROM with HT IDE3000 and Starter Kit Utility e User s Manual HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide Install the MTP Starter Kit Insert the HT IDE3000 CD into the CD ROM drive Fig 1 1 will be shown HTI IDE3000 Release Version CD AUTORUN User s Guide HT Handhiriter HT Witer Pr CU S DEN a amp Con Air nn e mos Holtek Integrated Devela Ihen Es A T 4 Setup MTP Starter kit HOLTEK f Click the lt Setup MTP Starter Kit gt button and Fig 1 2 will be shown Chapter 1 Getting Starter eG RT tup Holtek M TP Starter Eit Fy al 1 Welcome to the Holtek MTP Starter Kit Setup Wizard This wall install Holek ITF Starter Eit v1 0 on your computer IL is recommended that wou close all other applications before continuing Click Next to continue ar Cancel ta ext Setup Lancel Fig 1 2 er Holtek I O 8 Bit MTP Starter
41. hanged Operation ACC lt m Affected flag s Z 44 HOLTEK f DAA m Decimal Adjust ACC for addition with result in Data Memory Description Convert the contents of the Accumulator value to a BCD Binary Coded Decimal value resulting from the previous addition of two BCD variables If the low nibble is greater than 9 or if AC flag is set then a value of 6 will be added to the low nibble Otherwise the low nibble remains unchanged If the high nibble is greater than 9 or if the C flag is set then a value of 6 will be added to the high nibble Essentially the decimal conversion is performed by adding 00H 06H 60H or 66H depending on the Accumulator and flag conditions Only the C flag may be affected by this instruction which indicates that if the original BCD sum is greater than 100 it allows multiple precision decimal addition Operation m lt ACC 00H or Im ACC 06H or Im ACC 60H or m lt ACC 66H Affected flag s C Chapter 5 Instruction Definition DEC m Decrement Data Memory Description Data in the specified Data Memory is decremented by 1 Operation m m 1 Affected flag s Z DECA m Decrement Data Memory with result in ACC Description Data in the specified Data Memory is decremented by 1 The result is stored in the Accu mulator The contents of the Data Memory remain unchanged Operation ACC lt m 1 Affected flag s Z HALT Enter power down mode Description This instructio
42. his tutorial program presents a 4x4 key matrix scan and displays the number ofthe pressed key on the 7 segment LED The number displayed is from 1 to 16 A O is displayed if no key or an invalid key is pressed Scan Method This applies to the Invert Key Scanned method in the tutorial program First it has to set the configuration options of port A as follows e Setthe inputtype of port A to Schmitt Trigger input which helps to diminish switch bounce e Set the port A to use the internal pull high resistor At the beginning of the program set PAO PA3 of port Ato be output pins and PA4 PA7 to be input pins Then output 0000 to PAO PA3 and read from PA4 PA7 The read data should be 1111b if there s no key pressed since the PA4 PA7 have pull high resistors in the config uration option Otherwise some key may be pressed down the data of PA4 PA 7 not 1111b is recorded in the variable named keyX For the next step change PAO PAS to be inputs and PA4 PAT to be outputs then use the same method to output 0000b to PA4 PA7 and read back from PAO PA3 Store the read data to the variable keyY Combine keyY with keyX to form 8 bit data then look up the Key Status table to get the code of the key and finally display the code number on the LED display Related Files SCANKEY MTP is the downloaded file for this tutorial program Browse and specify this file name in the File menu Open command in Fig 1 7 SCANKEY ASM is the assembly source
43. k source is first divided by a prescaler 8 stage prescaler the division ratio of which is conditioned by the timer control register bits PSC2 PSC1 and PSCO of TMROC Then the register TMRO which contain the actual value of the timer and into which an initial value can be preloaded will count up until an overflow occurs Holtek I O 8 Bit MTP Starter Kit User s Guide In this tutorial program we select the internal Timer O as the clock source for the buzzer function the system clock is the timer source clock the prescaler s ratio is 1 4 The Timer 0 s counter is preloaded with Ox80h BZ shared with PBO pin is the output pin We can test the function with two buttons sw18 and sw19 as follows e The key sw18 pressed buzzer beeps once the beep lasts for 250 milliseconds e The key sw19 pressed buzzer beeps twice each beep lasts for 125 milliseconds the in terval of two beeps is 125 milliseconds Flowchart Initialization cep once f 5 Beep twice ji Im Related Files BUZZER MTP is the downloaded file When you want to run this tutorial program browse and specify this file name in the File menu Open command in Fig 1 7 BUZZER ASM is the source file of this tutorial program with assembly language BUZZER1 C is the C language version The next chapter will describe how to modify these files to adapt them for the user s applications 18 HOLTEK f Chapter 2 Tutorial Programs Tutorial 2 Key Matrix Scan T
44. n stops the program execution and turns off the system clock The con tents of the Data Memory and registers are retained The WDT and prescaler are cleared The power down flag PDF is set and the WDT time out flag TO is cleared Operation TO 0 PDF lt 1 Affected flag s TO PDF 45 INC m Increment Data Memory Description Data in the specified Data Memory is incremented by 1 Operation m m 1 Affected flag s Z INCA m Increment Data Memory with result in ACC Description Data in the specified Data Memory is incremented by 1 The result is stored in the Accu mulator The contents of the Data Memory remain unchanged Operation ACC m 1 Affected flag s Z JMP addr Jump unconditionally Description The contents of the Program Counter are replaced with the specified address Program execution then continues from this new address As this requires the insertion of a dummy instruction while the new address is loaded it is a two cycle instruction Operation Program Counter addr Affected flag s None MOV A m Move Data Memory to ACC Description The contents of the specified Data Memory are copied to the Accumulator Operation ACC lt m Affected flag s None MOV A x Move immediate data to ACC Description The immediate data specified is loaded into the Accumulator Operation ACC lt x Affected flag s None MOV m A Move ACC to Data Memory Description The contents of the Accumulator are c
45. ntroller s program memory Erase EEData Erase the contents of the MTP microcontroller s data EEPROM Erase All Erase both the program memory and data EEPROM of the MTP microcontroller Lock Chip This instruction will implement a protect function in the MTP device preventing the contents of this MTP device from being read After programming an MTP device this instruction can be used to protect its contents 14 HOLTEK f Chapter 1 Getting Starter Menu Upload The Upload menu provides commands Fig 1 13 to read data from the MTP microcontroller Program Read the program code from the MTP microcontroller s program memory and display on the active window If you want to store the program code to a file then select the File menu Save As command The file extension name is MTP EEPROM Data Read the data from the MTP microcontroller s data EEPROM and display on the right side of the active window If you want to store the data to a file then select the File menu Save As command The file extension name is MTP ALL Read both program code and data from the MTP microcontroller then display on the left side and right side of active the window respectively If you want to store the data to a file then select the File menu Save As command The file extension name is MTP Verify Program Read the program code from the MTP microcontroller s program memory and check if it is the same as the contents on the active window the
46. opied to the specified Data Memory Operation m lt ACC Affected flag s None 46 HOLTEK f Chapter 5 Instruction Definition NOP No operation Description No operation is performed Execution continues with the next instruction Operation No operation Affected flag s None OR A m Logical OR Data Memory to ACC Description Data in the Accumulator and the specified Data Memory perform a bitwise logical OR operation The result is stored in the Accumulator Operation ACC ACC OR m Affected flag s Z OR A x Logical OR immediate data to ACC Description Data in the Accumulator and the specified immediate data perform a bitwise logical OR operation The result is stored in the Accumulator Operation ACC lt ACC OR x Affected flag s Z ORM A m Logical OR ACC to Data Memory Description Data in the specified Data Memory and the Accumulator perform a bitwise logical OR operation The result is stored in the Data Memory Operation m ACC OR m Affected flag s Z RET Return from subroutine Description The Program Counter is restored from the stack Program execution continues at the restored address Operation Program Counter Stack Affected flag s None 47 HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide RET A x Return from subroutine and load immediate data to ACC Description The Program Counter is restored from the stack and the Accumulator loaded with the specified immediat
47. ore FE Holtek I O 8 Bit MTP Starter Kit User s Guide October 2005 Copyright 2005 by HOLTEK SEMICONDUCTOR INC All rights reserved Printed in Taiwan No part of this publication may be reproduced stored in a retrieval system or transmitted in any form by any means electronic mechanical photocopying recording or otherwise without the prior written permission of HOLTEK SEMICONDUCTOR INC NOTICE The information appearing in this User s Guide is believed to be accurate at the time of publication How ever Holtek assumes no responsibility arising from the use of the specifications described The applica tions 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 re serves the right to alter its products without prior notification For the most up to date information please visit our web site at http www holtek com tw HOLTEK f Contents Contents Chapter 1 Getting Starter esee ann eene 1 JuiigoroliTeii o o 1 ee ee EN NIE NENNE RN AME UUU EUUUR KEEREU
48. rst decremented by 1 If the result is O the following instruction is skipped As this requires the insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is not 0 the program proceeds with the following instruction Operation m m 1 Skip if m 0 Affected flag s None SDZA m Skip if decrement Data Memory is zero with result in ACC Description The contents of the specified Data Memory are first decremented by 1 If the result is O the following instruction is skipped The result is stored in the Accumulator but the speci fied Data Memory contents remain unchanged As this requires the insertion of a dummy instruction while the next instruction is fetched it is a two cycle instruction If the result is not 0 the program proceeds with the following instruction Operation ACC m 1 Skip if ACC 0 Affected flag s None SET m set Data Memory Description Each bit of the specified Data Memory is set to 1 Operation m lt FFH Affected flag s None SET m i oet bit of Data Memory Description Bit i of the specified Data Memory is set to 1 Operation m i lt 1 Affected flag s None 51 HOLTEK f SIZ m Skip if increment Data Memory is 0 Holtek I O 8 Bit MTP Starter Kit Users Guide Description The contents of the specified Data Memory are first incremented by 1 If the result is O the following instruction is skipped As this requires the
49. t page to TBLH and Data Memory Description The low byte of the program code current page addressed by the table pointer TBLP is moved to the specified Data Memory and the high byte moved to TBLH Operation m lt program code low byte TBLH lt program code high byte Affected flag s None o4 TABRDL m Read table last page to TBLH and Data Memory Description The low byte of the program code last page addressed by the table pointer TBLP is moved to the specified Data Memory and the high byte moved to TBLH Operation m lt program code low byte TBLH lt program code high byte Affected flag s None XOR A m Logical XOR Data Memory to ACC Description Data in the Accumulator and the specified Data Memory perform a bitwise logical XOR operation The result is stored in the Accumulator Operation ACC lt ACC XOR m Affected flag s Z XORM A m Logical XOR ACC to Data Memory Description Data in the specified Data Memory and the Accumulator perform a bitwise logical XOR operation The result is stored in the Data Memory Operation m lt ACC XOR m Affected flag s Z XOR A x Logical XOR immediate data to ACC Description Data in the Accumulator and the specified immediate data perform a bitwise logical XOR operation The result is stored in the Accumulator Operation ACC lt ACC XOR x Affected flag s Z 99 HOLTEK f Holtek I O 8 Bit MTP Starter Kit Users Guide 56 Holtek
50. tarter Kit amp ISP cable E ni xi File Edit View Upload Download Tools Help SH Ba rora E EEData ADDR 0 1 5 6 0000 2413 2213 OC 000 0000 0000 0008 2889 0000 0C Erase Program 086 O9FF O9FF EEData Memory l o3 4 5 B Y AF 4C 54 45 4B 00 00 HOLTEE 0 0010 0909 O9F1 Of EraseEEData 3F2 0971 09F3 00 00 00 00 00 00 00 0018 0921 O9F4 05 pea 9F5 0903 09F6 00 00 00 00 00 00 00 0020 0997 09F6 0 9F7 0914 09F8 00 00 00 00 00 00 00 0028 0988 O9F8 Of LockChip 9F9 09B9 09F9 00 00 00 00 00 00 00 0030 0913 O9FA 0 9FA 0903 09FB 00 00 00 00 00 00 00 0038 094C O9FB 0990 O9FB 09D0 O9FB 090B O9FC 0040 0944 O9FC 097A O9FC O9AD O9FC O9DD O9FC 0048 090A O9FD 0934 O9FD 095C O9FD 0982 O9FD 0050 0946 O9FD 9C8 O9FD DIES O9FD 0906 O9FE 0058 0086 0900 0910 0920 0930 0940 0950 0960 0060 0970 0980 0990 0940 O9B0 9CO O9D0 SEO 0068 09F0 DIFF 0086 0941 DIE 0952 0962 09E4 0070 0968 0948 DIES 0940 0960 O09C0 094C 0959 0078 0946 0958 09D8 0086 O9EE SED DIEB DIE 0080 09DE 9DD O9DB 09D O9BE O9BD O9BB 0987 0088 097E 097D 097B 0977 0086 O9FE O9FD O9FB 0090 09F O9FB O9FD 0000 0000 0000 0000 0000 0098 0000 0000 1785 2899 0003 0000 0000 0000 00A0 0000 0000 0000 1785 28A2 0000 1785 2845 00 8 17E 2845 0003 OOEB 070A OOEC 076C 008A 00B0 076B 0004 OOEB 070A OOEC 076C 008A O76B 00B3 0004 OEB 070A DOEC 10E3 28BF 28C0 15E3 00C0 10E4 28C3 28C4 15E4 OFO1 0365 OOEO OFOO 00C8 1366
51. to the EEPROM data memory in the programming disabled state By so doing the internal memory data can be protected ERASE The ERASE instruction erases data at the specified addresses in the programming enable mode After the ERASE op code and the specified address have been issued the data erase is activated by the falling edge of CS Since the internal auto timing generator provides all tim ing signals for the internal erase so the SK clock is not required During the internal erase we can verify the busy ready status if CS is high DO will remain low but when the operation is over DO will return to high and further instructions can be executed WRITE The WRITE instruction writes data into the EEPROM data memory at the specified ad dresses in the programming enable mode After the WRITE op code and the specified ad dress and data have been issued the data writing is activated by the falling edge of CS Since the internal auto timing generator provides all timing signal for the internal writing so the SK clock is not required The auto timing write cycle includes an automatic erase before write ca pability So itis not necessary to erase data before the WRITE instruction During the internal writing we can verify the busy ready status if CS is high DO will remain low but when the op eration is over DO will return high and further instructions can be executed 29 ERAL The ERAL instruction erases the entire 256x8 memory
52. ype which is different from the MCU type of the MTP file Recent Files List the most recently opened and closed four files e Exit Exit from the MTP Starter Kit utility and return to Windows Menu Edit e Cut Remove the selected lines from the file and place onto the clipboard Copy Place a copy of the selected lines onto the clipboard e Paste Paste the clipboard information to the present insertion point 13 Menu View The View menu provides the following commands to control the window screen of the MTP Starter Kit utility e Toolbar Display the toolbar information on the window The toolbar contains some groups of but tons whose function is the same as that of the command in each corresponding menu item When the mouse cursor is placed on a toolbar button the corresponding function name will be displayed next to the button If the mouse is clicked the command will be executed e Status Bar Display the status bar information on the window Menu Download The Download menu Fig 1 12 provides commands to program the MTP microcontroller e Program Write the active program code to the MTP microcontroller s program memory A progress bar is displayed to indicate the download percentage EEPROM Data Write the active data to the MTP microcontroller s data EEPROM e ALL Write both program code and data to the corresponding memory of the MTP microcontroller Erase Program Erase the contents of the MTP microco

Download Pdf Manuals

image

Related Search

Related Contents

    Manuel d`utilisation  【イベントツール レンタル規約】 ご利用上のご注意とお願い  7082 448 - 00 Istruzione d`uso  Télécharger ce fichier    Nokia 8260 - Microsoft    

Copyright © All rights reserved.
Failed to retrieve file