lpcopen v2.10 lpc17xx EMC driver, not working with optimalization

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

lpcopen v2.10 lpc17xx EMC driver, not working with optimalization

407 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wella-tabor on Fri Feb 06 01:39:19 MST 2015
Hello,

during the SDRAM initialization, code in the lpcopen emc driver is behaving faulty after the optimization flags are turned on.

It is caused by the "i" variable. This is not declared as volatile and the compiler deletes the useless! loop.
/*FIXME: if Timer driver is ready, it should replace below "for" delay technic */
for (i = 0; i < 1000; i++) {/* wait 100us */
}
pEMC->DYNAMICCONTROL    = 0x00000183;/* Issue NOP command */

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

369 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Sun Feb 08 06:00:16 MST 2015
Even if "i" is declared volatile, the compiler is allowed to delete the empty loop if "i" is not global visible.

Even worse: the 0,,,999 loop may execute in less than 100us.

The only valid solution is to to implement the udelay() function.

Every programmer using a for() loop for delays should be beaten.

regards
Wolfgang
0 项奖励