I am trying to modify SIM_SOPT1CFG.
Either line of 'C' code causes a bus fault:
SIM_SOPT1CFG |= (SIM_SOPT1CFG_URWE_MASK);
or
*(unsigned long *)0x40047004 |= (0x1000000u);
When at either line of code above I can use a JTAG debugger and manually set the bit. So, I know the register can be accessed via the JTAG debugger when at that line of code.
What am I missing? Why can't I do this?
Solved! Go to Solution.
Hi @kfranz,
please try it this way instead;
SIM->SOPT1CFG |= SIM_SOPT1CFG_URWE_MASK;
As this is the way you can access the register now. Hope it helps!
Best regards, Julian
Is there any clocks that need turned on to access this register?
The debugger could have different clocking systems going on.
Also do you really need to read the register with '|='?
NXP frequently shows these in examples where only simple assignment '=' should be used.
Hi @bobpaddock,
The '|=' operators are a simple way to access a register without overwriting it, this way, the configuration you add will be additional and will not affect any other bits.
Best regards, Julian
The |= is a Read-Modify-Write operation that at best wastes time when
used, where an assignment is appropriate.
At its worst using |= can unintentionally clear unexpected bits,
causing interrupts to be lost, when assignment was the intention on
status registers that have Write-1-To-Clear (W1C) bits.
It is simply bad practice to use |= when it is not needed.
Sadly the NXP documentation and example code is full of this bad
practice, and it harms people new to Embedded System development by
setting a bad precedent of coding style.
Hi @kfranz,
please try it this way instead;
SIM->SOPT1CFG |= SIM_SOPT1CFG_URWE_MASK;
As this is the way you can access the register now. Hope it helps!
Best regards, Julian