Software > Software

AVR timer problem

<< < (2/3) > >>

dunk:
i tell you what,
wait 25 days and submit it to the GCC developers as a bug....

i did exactly the same thing the first time i tried to get a delay while using a compiler.
(pity i didn't read this after your first post hu?)
it makes sense when you think about it. the optimisation is looking for unnecessary loops in your code that it can remove to increase performance (ie, speed the thing up again).

a far nicer way to program is to use one of the on board timers. it takes a little work to figure them out but it's well worth the effort.

dunk.

dunk:

--- Quote ---would it make sense to have an optimization level that understands and therefore allows looping waits?
--- End quote ---
not really.
optimization is looking for anything that will speed up execution time.
if you are using a loop for timing you clearly don't want to speed up the program so OPT=0 is the right option.

dunk.

JesseWelling:
IIRC you can make it so it doesn't optimize loops....but I can't remember the argument that you feed into the compiler.
I'll look around awhile for it.

JesseWelling:
here is what man avr-gcc had to tell me about optimization an loops

--- Code: ----floop-optimize
           Perform loop optimizations: move constant expressions out of loops, simplify exit test conditions and optionally do strength-reduction and loop unrolling as well.
           Enabled at levels -O, -O2, -O3, -Os.

--- End code ---

But if you look at what -O does:

--- Code: ----O turns on the following optimization flags:-fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize -fif-conversion -fif-conversion2 -fdelayed-branch -fguess-branch-probability -fcprop-registers
--- End code ---

So what you could do is just copy paste every thing in except for the -floop-optimize. althought it might be one of the branching options that's messing with the loop.

NOOBinDistress:
SPeaking of AVR Admin can you take a look at the posts I have made about programing the robot I built from your 50$ robot tutorial? THANKS

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version