LPC1788 - Flash signature generation

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Marc Crandall on Fri Sep 02 13:42:04 MST 2011

I'm having trouble with the "Flash signature generation" on the LPC1788.

First off the LPC178x_7x.h header file does not have the Flash signature generation structure or define macro.

I added the following to my code:

/*------------- Flash Signature Generation ----------------------*/
typedef struct
       uint32_t RESERVED1[8];
  __IO uint32_t FMSSTART;
  __IO uint32_t FMSSTOP;
       uint32_t RESERVED2;
  __IO uint32_t FMSW0;
  __IO uint32_t FMSW1;
  __IO uint32_t FMSW2;
  __IO uint32_t FMSW3;
       uint32_t RESERVED3[1001];
  __IO uint32_t FMSTAT;
  __IO uint32_t FMSTATCLR;

//#define LPC_FLASHSIG_BASE     (LPC_APB1_BASE + 0x04000)

#define LPC_FMC          ((FLASHSIG_TypeDef  *) 0x00200000 )


The problem I have is I get a hardfault when I access the FMSSTOP register.

Basically this is my code:

void CalcSignature()
    /* align flash address to refer the flash word in the array */
    uint32_t startAddr =    0x40000;
    uint32_t length =       0x3FFFF;
    startAddr = (startAddr >> 4) & 0x0001ffff;
    length = ((startAddr + length) >> 4) & 0x0001ffff;
    /* write start address of the flash contents to the register*/
    LPC_FMC->FMSSTART = startAddr;
    LPC_FMC->FMSTATCLR |= (1 << 2); // clear the SIG done
    /* write stop address of the flash contents to the register, start generating
    the signature*/
    length |= ( 1 << 17);
    LPC_FMC->FMSSTOP = length;   //HARD FAULT HERE!!!!!!!!!!!!!!!!!
    while((LPC_FMC->FMSTAT & (1 << 2)) == 0);

Anybody have any ideas or see what I'm doing wrong?