when i try to erase or write to the program flash on my S32K146 i run into a Fault at the moment the FTFC should execute the command. Also the RDCOLLERR bit in the FTFC_STAT register is set.
BusFault: A precise (synchronous) data access error has occurred. and also instruction fetching error i got.
Strangely enough this does not happen, when i step through the program line by line. Then the flash gets programmed correctly.
This is my routine for erasing a flash sector:
Solved! Go to Solution.
There's simple rule - whatever the situation is, you can't access a flash block which is being erased or programmed. As you can see in the source files, FLASH_DRV_CommandSequence is executed in RAM:
Not sure what kind of differences you did, so please check if the function is really executed from RAM.
And try to disable interrupt when programming the flash. This is the most common issue.
Regards,
Lukas
this is caused by Read While Write (RWW) error.
RWW is supported only between partitions/blocks. S32K146 has two 512KB blocks of program flash memory. When a block is being programmed or erased, the code must run from different block or from data flash or from RAM. If there are interrupts which could access the block, it's necessary to either disable all interrupts or put all the interrupt resources (vector table, ISR handlers...) to different block or to RAM.
Some screenshots from the reference manual:
Regards,
Lukas
Hi lukaszadrapa,
Thanks for the reply it worked. I have one more query related to this.
My memory mapping order will be like this for S32K144:
Vector table : 0x00000000 - 0x000003FF
Flash Config: 0x00000400 - 0x0000040F
Bootloader area : 0x00000410 - 0x00003FFF
Parameter area : 0x00004000 - 0x00004FFF
Application area : 0x00006000 - 0x00023FFF
During Bootloader sequence my Flash_Command() will be executed from my ROM area only at that time there is no issue in the Flashing part.
But when i try to write the parameter in the respective area and Flash_Command() is executing from Application area at that time i am facing issues related to BUS_Fault but during debugging i am not facing any issues.
if Flash_Command() has to executed from RAM area then for Bootloader how it works can you explain on this part.
There's simple rule - whatever the situation is, you can't access a flash block which is being erased or programmed. As you can see in the source files, FLASH_DRV_CommandSequence is executed in RAM:
Not sure what kind of differences you did, so please check if the function is really executed from RAM.
And try to disable interrupt when programming the flash. This is the most common issue.
Regards,
Lukas