AnsweredAssumed Answered

Hard Fault in FLASH_Program when source address not aligned

Question asked by Paul-Daniel Piscoi on Jul 27, 2018
Latest reply on Jul 29, 2018 by Paul-Daniel Piscoi



I have the following code:

uint8_t pData[] = {1,1,1,1,1,1,1,1,1,1,1,1,1,};

flash_config_t s_flashDriver;

memset(&s_flashDriver, 0, sizeof(flash_config_t));


FLASH_Program(&s_flashDriver, 0x55000, (uint32_t*)(pData+1), 4);




which causes a hard fault in function FLASH_Program() defined in the flash driver (fsl_flash.c) at this line:


kFCCOBx[1] = *src++;

 where src is the pointer to the data I want to write to the flash (namely pData+1).


If, however, I pass pData, or pData+4 to FLASH_Program() no hard fault is given and program behaves as expected.


So it seems that you must have a word aligned source address (not destination address, which I understand why it has to be word aligned!). Why is that? Or am I overlooking something?