Warning: gcc optim issue with some cmsis drivers

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

Warning: gcc optim issue with some cmsis drivers

1,281件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fariouche on Sun Sep 02 08:50:28 MST 2012
Hi all,  I was debugging the CAN (I'm using nxp's cmsis implementation lpc17xx_can.c)  I'm compiling with Os optimization flag. This triggers reordering of code for optimizations... This is fine most of the time, but in some case this can lead to a disaster (or almost)   __attribute__((optimize("O0"))) should be used in front of some functions. This is the case for the can_setBaudrate function!  WHat happens is that the optimizer puts "CANx->MOD = 0;" to return to normal mode before actually writting to the BTR register (the line just above, CANx->BTR  = ) From a pure C perspective, this is perfectly fine, gcc has no idea that the order here is important!  I've forced the optim flag to O0 for this function and the CAN init function (just to be sure, don't need optimized init functions)  Most likely this must be used in other files! (all functions for example that disables/enables interrupts)  Hope this helps
0 件の賞賛
返信
4 返答(返信)

1,266件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fariouche on Wed Sep 05 13:51:40 MST 2012
I'm using lpcxpresso's gcc (until the flasher's issue is sorted)
Please discard this thread... I think I was confused by the way gdb "jumps" in optimized versions.
The issue was an invalid compiler flag.

Sorry

Thanks
0 件の賞賛
返信

1,266件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Sep 02 14:52:01 MST 2012
Writing MOD register after BTR register isn't causing any problems with LPCXpresso here. I'm using this sequence since years with -O0 (Debug) and -Os (Release) optimization :)
0 件の賞賛
返信

1,266件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Sep 02 14:26:50 MST 2012
There are no known optimisation issues with correctly written code. Please post your code, and describe what you think the compiler is doing wrong.

From an earlier posting, I think you said you were using a different compiler. Please confirm that you are using the compiler that ships with LPCXpresso.
0 件の賞賛
返信

1,266件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fariouche on Sun Sep 02 09:39:41 MST 2012
well, I don't 100% get it, as all the fields are declared volatile...
Maybe I was confused by gdb...
0 件の賞賛
返信