Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

IAP command problems

2004-09-27 by koerner_stefan

Could anyone help me to run the IAP commands on KEIL MCB2100 
(LPC2129)?

I am working with the ARM RVDS tools (& RV ICE) and tried to run a 
small sample calling the IAP commands (program runs from iRAM).

Most time I get a "memory access violation" several seconds after 
calling the IAP commands.
Sometimes the first IAP command (code 50) runs ok but I did never saw 
a guilty write command. I tried it also with cclk = 12MHz. Do I have 
to do additional initialisation?
I have reserved 16 bytes on top of Stack.

best regards
Stefan

This is my source

static void PLL_Init(void)
{
// Fosc = 12.000.000 MHz

    PLLCON  = 1;           // enable PLL 
    PLLCFG  = 0x24;        // M=5 and P=2 -> Cclk = 60.000.000 MHz
    PLLFEED = 0xAA;        // PLL Feed Sequence
    PLLFEED = 0x55;        // PLL Feed Sequence

    while (!(PLLSTAT & 0x400));    // wait for the PLL to be locked

    PLLCON  = 3;           // enable and connect PLL 
    PLLFEED = 0xAA;        // PLL Feed Sequence
    PLLFEED = 0x55;        // PLL Feed Sequence
	
    VPBDIV = 0;           // Pclk = 15.000.000 MHz

}

static void PLL_Off(void)
{
// Fosc = 12.000.000 MHz

    PLLCON  = 0;                   // disable PLL cclk = Fosc 
    VPBDIV = 1;                    // Pclk = cclk

}


void savesetup(struct SETUP *setup){
typedef void (*IAP)(unsigned int [],unsigned int[]);
unsigned int command[5];
unsigned int result[2];
IAP iap_entry;
// PLL_Off();
//__ARMLIB_disableIRQ();
iap_entry=(IAP) IAP_LOCATION;
// prepare to erase
command[0]=50;
command[1]=14;   /* start sector */	
command[2]=14;   /* end sector */
iap_entry(command, result);
if (result[0] != 0) goto error;
// erase
command[0]=52;
command[1]=14;                   /* start sector */
command[2]=14;                   /* end sector */
command[3]=60000;                /* System Clock cclk in KHz */
sendstr ("\nnow erase");
iap_entry(command, result);      /* erase the block */
if (result[0] != 0) goto error;
// prepare to program
iap_entry=(IAP) IAP_LOCATION;
command[0]=50;
command[1]=14;                   /* start sector */
command[2]=14;                   /* stop sector */
sendstr ("\nnow prepair to program");
iap_entry(command, result);
if (result[0] != 0) goto error;
// program
command[0]=51;
command[1]=0x1C000;              /* destination address */
command[2]=(int)setup;           /* source RAM adress */
command[3]=512;                  /* number of Bytes*/
command[4]=60000;                /* system clock cclk in KHz */
sendstr ("\nnow program");
iap_entry(command, result);
if (result[0] != 0) goto error;
//__ARMLIB_enableIRQ();
return;
error:
sendstr ("\nFlash Access error");
//__ARMLIB_enableIRQ();
}


int main (void) {

unsigned int ui_cnt;

struct SETUP setup; 
struct SETUP * nonvolatile;
nonvolatile= (struct SETUP*) 0x1C000;  /* Points to page 14 in Flash 
(LPC2106)*/

  PLL_Init();
//  PLL_Off();

/* Init General Purpose I/O GPIO */
  IOCLR1 = 0xFFFFFFFF;  
  IODIR1 = 0x00FF0000;     /* Port 1[23..16] is Output LEDs   */

  init_serial();             /* Initialize Serial Interface   */
  sendstr ("\nIAP Test");
  while (1) {                              /* Loop forever */

   setup=*nonvolatile;                    /* read ROM to RAM */ 

  sendstr ("\nsetup.ui_CH_ZS_Value = 0x");  
  sendhex((setup.ui_CH_ZS_Value[0] >> 28) & 0x0F); 
  sendhex((setup.ui_CH_ZS_Value[0] >> 24) & 0x0F); 
  sendhex((setup.ui_CH_ZS_Value[0] >> 20) & 0x0F);  
  sendhex((setup.ui_CH_ZS_Value[0] >> 16) & 0x0F); 
  sendhex((setup.ui_CH_ZS_Value[0] >> 12) & 0x0F);  
  sendhex((setup.ui_CH_ZS_Value[0] >> 8) & 0x0F);   
  sendhex((setup.ui_CH_ZS_Value[0] >> 4) & 0x0F);   
  sendhex(setup.ui_CH_ZS_Value[0]  & 0x0F);        

   setup.ui_CH_ZS_Value[0]++;        /*modify for test */	
   setup.ui_CH_FS_Value[0]++;
  
   savesetup (&setup);
   
  }

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.