This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reading/Writing data to flash with IAP

I am using the LPC2300 (2378) board.

I need to permanently store a variety of settings so that they are available from startup to startup. These are stored in a struct. I have done the following for storing them:

  // prep sector 9 (0x00010000) for writing

  command[0] = 50;  // IAP Prepare Sectors for Write operation
  command[1] = 9;   // Controller variables stored in sector 9
  command[2] = 9;   // (end sector is same - only use 1 sector)
  iap_entry=(IAP) IAP_LOCATION;

  // copy ram to flash

  command[0] = 51;  // IAP Copy Ram to flash operation
  command[1] = 0x00010000;   //  address of sector 9
  command[2] = (unsigned long)&parms;   // parms location
  command[3] = sizeof(parms);
  command[4] = 12000;  // clock speed
  iap_entry=(IAP) IAP_LOCATION;

I am accessing the data with a simple memcpy

  memcpy(  (void *)&gParms, (void *)0x00010000, sizeof(gParms) );

When I do a write and then do the memcpy the data isn't being stored/retrieved correctly.

What am I missing/ doing wrong?

Any help is greatly appreciated.

Thanks

Dave

Parents
  • OK I have read it - that's how I have gotten this far.

    I need to disable the interrupts or move the code to RAM. Since I can't find anything yet on how to move the code to RAM I am trying to go with the disabling. The only thing I can find for disabling the interrupts is VICIntEnClr. My understanding of this is that if I do the following I should disable the irqs

    unsigned long irqStatus;
    irqStatus = VICIntEnable;
    VICIntEnClr = irqStatus; // disable the active irqs
    
    // write data as I did above
    
    VICIntEnable = irqMask; /* reEnable Interrupt */
    
    

    Am I hopelessly lost?

Reply
  • OK I have read it - that's how I have gotten this far.

    I need to disable the interrupts or move the code to RAM. Since I can't find anything yet on how to move the code to RAM I am trying to go with the disabling. The only thing I can find for disabling the interrupts is VICIntEnClr. My understanding of this is that if I do the following I should disable the irqs

    unsigned long irqStatus;
    irqStatus = VICIntEnable;
    VICIntEnClr = irqStatus; // disable the active irqs
    
    // write data as I did above
    
    VICIntEnable = irqMask; /* reEnable Interrupt */
    
    

    Am I hopelessly lost?

Children
No data