volatile access optimized away (CW10.1 Kinetis)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

volatile access optimized away (CW10.1 Kinetis)

1,108 次查看
konrada
Contributor IV

Hello all,

 

I compiled the following C++ function with CW 10.1 for Kinetis and found what I believe to be a volatile optimization bug.

void DebugResetFTM0Status(){  volatile uint32* pReg = &FTM0_STATUS;  *pReg = *pReg & 0;}

I expect the assembly code to read the FTM register and write back a 0. The Freescale FlexTimer has interrupt flags with a "write 0 after reading 1" reset protocol, so I really care for the read. If I want reads and writes optimized away, I leave out the "volatile".

The disassembly (from the debugger) shows that the C++ compiler optimized the volatile read-write combination away.

00010120:   movw r5,#0x805000010124:   movt r5,#0x400300010128:   movs r0,#00001012a:   str r0,[r5,#0]     ; Blind store of 0 into the FTM register!; followed by an uninteresting epilogue, ldm this, add sp that.

Version info: CodeWarrior for MCU Version: 10.1 Build Id:110204, with whatever C++ compiler that brings along. I compiled for the K60 derivate on the TWR K60 board.

 

Greetings, KA

标签 (1)
0 项奖励
回复
1 回复

918 次查看
J2MEJediMaster
Specialist I

Please file an on-line service request for this problem. Click here to go the the service request page.

 

---Tom

0 项奖励
回复