Accessing Program Memory Unit registers Causes Trap

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

cross mob
User19424
Level 3
Level 3
First solution authored First like received
Hello,
I am trying to change the Margin Control Register PFlash (Specifically the TRAPDIS Field from "No" to "Yes") but am having issues.
I tried several attempts:

(&FLASH0_MARP)->U = 0x00008000;
MODULE_FLASH0.MARP.B.TRAPDIS = 1;
MODULE_FLASH0.MARP.I = 0x8000; // This is how it should be if only TRAPDIS is changed in the bit field


But they all cause a Data Access Asynchronous Error (Trap Class 0).
I theorize that this maybe because they have some kind of protection, I've tried to wrap the code line in:

uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPasswordInline();
IfxScuWdt_clearSafetyEndinitInline(endInitSafetyPassword);
//CODE HERE
IfxScuWdt_setSafetyEndinitInline(endInitSafetyPassword);


And also tried

unlock_safety_wdtcon();
//CODE HERE
lock_safety_wdtcon();


I even tried them both together wrapping the one line of code, but nothing works.
Anyone know what I am doing wrong? Would appreciate any help in showing me the correct way of doing things.
0 Likes
1 Solution
User19424
Level 3
Level 3
First solution authored First like received
Hello
I solved the issue 🙂
Turns out there is SafteyEndInit and normal Endinit
I tried to turn of the safety variant and not the normal one

Doing this fixed my issue:

uint16 endinitPw = IfxScuWdt_getCpuWatchdogPassword();
IfxScuWdt_clearCpuEndinit (endinitPw);
MODULE_FLASH0.MARP.I = 0x8000;
IfxScuWdt_setCpuEndinit (endinitPw);

View solution in original post

1 Reply
User19424
Level 3
Level 3
First solution authored First like received
Hello
I solved the issue 🙂
Turns out there is SafteyEndInit and normal Endinit
I tried to turn of the safety variant and not the normal one

Doing this fixed my issue:

uint16 endinitPw = IfxScuWdt_getCpuWatchdogPassword();
IfxScuWdt_clearCpuEndinit (endinitPw);
MODULE_FLASH0.MARP.I = 0x8000;
IfxScuWdt_setCpuEndinit (endinitPw);