ABSTRACT:
Corrects the Runtime programming example shown in the 8XC196KR Users Manual (270952-001).
RUNTIME PROGRAMMING EXAMPLE CORRECTION
The Runtime programming example in the 8XC196KR User's Manual (#270952-001) is incorrect. Figure 17.5 on page 17-13 shows how to program the 8XC196KR using an example copied from the 8XC196KC User's Manual. This example uses the HSIO peripheral which exists on the 8XC196KC but not on the 8XC196KR. The example shown in the users manual will not work on the 8XC196KR. The following code example uses the EPA peripheral and works on the 8XC196KR:
;************************************************************************************ ;* This routine will program a table of data words into the internal EPROM. EPA0 is used to generate a ;* 100uS programming pulse. The EA# pin must be high at reset to allow access to the internal EPROM. ;* Also, Vpp must be at +12.5V during execution of this routine to program the internal EPROM. ;************************************************************************************ ;* The following variables (words) must be declared in the user program: ;* ADDRESS_TEMP ;* DATA_TEMP ;* COUNT ;* TEMP0 ;* TEMP1 ;* TEMP2 ;* FLAG ;* ;* The following constants must be defined in the user program: ;* EPA0_TIMER = 01000000B (EPA control) ;* FREE_RUN = 11000000B (Timer control) ;* ENABLE_EPA0 = 10H (EPA0 interrupt enable mask) ;* DISABLE_EPA0 = 0EFH (clear EPA0 interrupt pending mask ;* PROG_SOURCE = (memory location of table that contains the data to be programmed starts) ;* PROGRAM_PULSE = (number that will equal 100uS when the timer is using an internal clock ;* with no prescaler) ;* ;* The format of the table containing the data to be programmed is: ;* word 1 = address of EPROM location to be programmed ;* word 2 = number of words to program ;* word 3 = start of data to be programmed ;********************************************************************************** ;********************************************************************************** ;* EPA0_ISR can reside in internal or external memory space. However, the EPA0_ISR vector must be ;*programmed at location 2008H in internal EPROM before this routine can be used. ;********************************************************************************** EPA0_ISR: Clr flag Ret ;*********************************************************************************** ;* This section of the program starts Timer1 and loads the data and address to be programmed. The ;* starting address to be programmed is at PROG_SOURCE, the number of words to be programmed is at ;* (PROG_SOURCE + 2) and the data to be programmed starts at (PROG_SOURCE + 4). temp1 stores ;* the current external source address and temp2 to stores the current count. ;************************************************************************************ START: Ldb wsr,#7CH Ld W1_T1CONTROL,#Free_run ;start timer1 Clrb wsr Ld temp1,#PROG_SOURCE ;start of external data Ld address_temp,[temp1] Inc temp1 Inc temp1 Ld temp2,[temp1] ;number of words to program DATA_PROGRAM_LOOP: Inc temp1 Inc temp1 Ld data_temp,[temp1] Call program Inc address_temp Inc address_temp ;point to next address to program Djnzw temp2,data_program_loop Sjmp $ ;Finished programming ;********************************************************************************** ;* This routine programs the EPROM using the run-time programming mode ;********************************************************************************** ;* The user calls this routine with the data to be programmed in data_temp and the address in ;* address_temp. The routine then programs each word 25 times. For Runtime programming to function ;* properly, the device cannot be accessing internal EPROM. Placing the device in idle mode or executing ;* out of external memory accomplishes this. While programming each word, the device remains in a ;* waiting loop until a flag is cleared. This requires that the wait loop is located in external memory. ;* EPA0 is used to end the waiting loop at the appropriate time. ;*********************************************************************************** ;* This routine assumes: ;* EPA0 devoted to run-time programming only, Timer1 previously setup as free-running timer using ;* internal clock (Timer1 used with EPA0 to generate programming pulse width). EPA0_ISR assigned ;* as EPA0 interrupt vector ;*********************************************************************************** PROGRAM: Pusha Ldb WSR,#7BH ;Select 32-byte window with EPA0 Ld count,#25 ;Number of times to pulse location Andb INT_PEND,#DISABLE_EPA0 ;clear EPA0 pending bit if set Ldb INT_MASK,#ENABLE_EPA0 ;EPA0 interrupt enabled Ldb INT_MASK1,ZERO_REG ;Clear INT_MASK1 Ldb W1_EPA0_CON,#EPA0_TIMER ;EPA0 set up as timer QPP_LOOP: Ld temp0,TIMER1 Add W1_EPA0_TIME,temp0,#PROGRAM_PULSE ;Program pulse width Ei St data_temp,[address_temp] ;user has stored data in data_temp and address in ;address_temp before calling program routine Ld flag,#5555H ;init flag to not zero ;******************************************************************************** ;* The following routine must be located in external memory ;******************************************************************************** PROG_WAIT_LOOP: Subb flag,zero_reg Jne prog_wait_loop ;loop until timer interrupt Djnz count,qpp_loop ;Loop 24 times Popa Ret endThe user should note that:
An example of the table used is:
CSEG PROG_SOURCE: DCW 3000H,0005H,1111H,2222H,3333H,4444H,5555H
* Legal Information © 1999 Intel Corporation