Kinetis K53 write to SIM_SOPT1CFG causes bus fault

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Kinetis K53 write to SIM_SOPT1CFG causes bus fault

ソリューションへジャンプ
1,840件の閲覧回数
kfranz
Contributor III

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?

0 件の賞賛
返信
1 解決策
1,811件の閲覧回数
Julián_AragónM
NXP TechSupport
NXP TechSupport

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

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
1,808件の閲覧回数
bobpaddock
Senior Contributor III

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.

0 件の賞賛
返信
1,803件の閲覧回数
Julián_AragónM
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信
1,795件の閲覧回数
bobpaddock
Senior Contributor III

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.

 

0 件の賞賛
返信
1,812件の閲覧回数
Julián_AragónM
NXP TechSupport
NXP TechSupport

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

0 件の賞賛
返信