Forum : ARM
Post Information | Post |
---|---|
July 8, 2008 - 4:20pm
|
Hello, using Ride 7 (7.01.0002 / RKit 1.03.0004) on a Win XP Pro system, i got a strange bug while compiling the following code : --- start ---- int main() // GPIO Config GPIO_BitWrite (GPIO1,8,0); } Compile and run OK when optimization is disabled, but as soon as i enable optimisation (any level), the code still compile, but won't run properly. Let me explain : when optimization is enable, the software won't enter the FOR loops, and the GPIO is toggling way too fast. I know for sure, as i checked the GPIO with an oscilloscope, and i also checked with NOICE, and the FOR loops are never entered. Once again, disabling optimisation (with ALL other settings being the same) instantly makes the code run properly. Any ideas ? Regards, |
It seems to be an expected behavior (the optimizer just does its job).
A workaround consists in doing something that cannot be optimized in the loop. Typically, you could call an external function.
If you need to wait for an exact delay, you must use a timer (if not, you code will be dependent on the version of the compiler).
I think it's a normal behavior since the T variable is not declare as volatile.
So if you declare this variable as volatile your code should work correctly.
Rgds
Thank you, you were right, declaring variable T as volatile did the trick.
I'm just an EE who's trying to run some test code before handling the project to some 'real' software guy (not found yet...)
Best regards,
Dave