XMC_FLASH_WriteBlocks Stuck in Default handler in startup_XMC1300.S

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I am attempting to use the XMC_FLASH_WriteBlocks function to save parameters to Flash memory but I get stuck in this default handler in the startup_XMC1300.S file. Here are some code snippets:

// Declare global pointer
const uint32_t *parameter;

// Declare array of parameters in main of main.c
uint8_t defaultParam[7] = {0,0,5,2,3,70,15};

// Assign location of data to save to Flash to the pointer variable
parameter = &defaultParam;

// Address I verified wasn't used by the program, pointer to the location of data, # of blocks, verify
XMC_FLASH_WriteBlocks(10009000, parameter, 1, 1);

As soon as it gets to *address = *data; in the XMC_FLASH_WriteBlocks function, it goes to the default handler. What am I missing here?
0 Likes
1 Reply
chismo
Employee
Employee
First like received
Hello,

I suspect that the input address to the function is being read as an integer value and hence, writing to an undefined address.
Better will be to use a #define for the address, or write in the hex format.

Another suggestion is to always erase the Flash page before any programming.
Therefore your code should be:


// Erase Flash page before writing to the block
XMC_FLASH_ErasePage(0x10009000);

// Address I verified wasn't used by the program, pointer to the location of data, # of blocks, verify
XMC_FLASH_WriteBlocks(0x10009000, parameter, 1, 1);


Regards,
Min Wei
0 Likes