I'm trying to write to the FLASH on a K20 using KSDK 2.0. My issue seems to be more of a general programming error than anything else. Here is is.
I'm using the following function:
status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes)
My call looks like this:
uint8_t packet[2048]; // Data starts at index 9
result = FLASH_Program(&flashDriver, address, (uint32_t*)&packet[9], length);
The guts of this function where I'm having the problem is here
kFCCOBx[1] = *src++; |
I can use a hardcoded value in place of *src++ and the value makes its way into flash. I can put *src++ on another line and that works. Trying to read *src always causes a fault. I can see in the debugger it points to the data I would expect it to point to.
Any help?
Solved! Go to Solution.
It was an unaligned uint32 access.
Thank you,
Ryan
(sent from mobile device)
Hi Ryan,
Have you compared your code to our example:
C:\NXP\KSDK_v2\SDK_2.0_FRDM-KL43Z_KDS\boards\frdmkl43z\driver_examples\flash\flash_erase_program_verify\kds
Which K20 device? 50MHz? 72MHz? 100MHz? 120MHZ?
Did you erase the sector (or two) before trying to program the flash?
Regards,
David
It was an unaligned uint32 access.
Thank you,
Ryan
(sent from mobile device)
Hi Ryan,
Thank you for letting one and all know the issue,
Regards,
David