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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

370 Views
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 */

Labels (1)
0 Kudos
1 Reply

332 Views
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 Kudos