Hello,
The problem is I have a Flash Initialization Failure on SWT0 after the software reset, so it becomes a destructive reset, my value in RAM is suppressed and I go again directly in my application
There can be no flash initialization failure on SWT0 as SWT0 does not have flash.
I can reproduce the issue with the simple hello_world project, where I added the detection of a push button that provokes the call to the SystemSoftwareReset function. Then the F_SWT0_RES bit in MC_RGM is raised.
The fault you are seeing is either SWT_0 timeout reset reaction or failure in HW flash module initialization (which is guarded by SWT_0) performed during reset phase1.
You can exclude Flash initialization failure during reset phase.(it is very hard to get this failure even with incorrect voltages on flash)
So what you are seeing is simple SWT_0 timeout reset.
To understand the issue please see following:
The device is by default (from NXP factory) programmed by active SWT_0 which timeout is 20ms. By default there is enabled reset reaction on this timeout and in addition there is also reset escalation enabled to 15 consecutive resets.
What you have to do in your code is to service/disable the SWT_0 in first 20ms after reset event. Have in mind that 20ms is quite fast and your application wont reach main.(maybe in case you wrote startup assemble and optimize it)
Simply add watchdog disable in assembly to your startup, for example:
#/* SWT_0.SR.R = 0xc520; */
e_lis r12,-0x3FB # r12,-66781184
e_li r0,0xC520 # r0,50464
e_li r11,0xD928 # r11,55592
#/* SWT_0.SR.R = 0xd928; */
e_stw r0,0x10(r12) # r0,16(r12)
e_lis r0,-0x1000 # r0,-16777216
e_stw r11,0x10(r12) # r11,16(r12)
#/* SWT_0.CR.R = 0xFF00010A; */
e_add16i r0,r0,0x10A # r0,r0,266
e_stw r0,0x0(r12) # r0,0(r12)
best regards,
Peter