A13 baremetal programming, coding direct on hardware without linux or android

Started by saand, April 14, 2013, 04:28:00 AM

Previous topic - Next topic

JohnS

Yes.

Well worth looking at all files below http://dl.linux-sunxi.org as various things are tucked away where you might not instantly realise.

John

simonc

I know this is a old topic, but I just wanted to comment on the program not working unless printf was used.

In the example code posted, I don't see any use of the volatile keyword. Using volatile is required when working with entities such as device registers or the compiler will make invalid assumptions during code generation and assume the register has not changed since the previous reference to the register in the code.

This is also probably why the code does not work without the use of printf().

The compiler should not optimise out loops containing volatile variables and since volatile is not used, printf() is used as a workaround here by referencing a variable changed within the loop.