Keith,
Thanks for your help. I have put volatile all over the place, but a couple
of my interrupts are still not happening. (Unless I do a level 1)
Could there be anything else that I am missing?
Thanks!
-Mike
Keith Larson <
[email protected]> wrote in message news:<
[email protected]>...
> Hi Mike
>
> One of the more common mistakes is to not realize that by not specifying
> 'volatile' the optimizer is free to eliminate some variables under the
> pretense that that they are static. It is like saying that if the
> compiler writes to a memory location, that memory location should be
> assumed to hold the value that was written to it.
>
> In the example below the compiler reads location 'A' once and afterwards
> might decide that there is no need to read it again and again since the
> location is not being modified. The optimizer *did* do the right thing. No?
>
> #define TIMER (int *)0x808020 // location of my timer
> for(;;)
> {
> while(*TIMER!=0); // wait for timer to time out
> }
>
> The correct way to deal with this is to add the keyword 'volatile'
> telling the compiler that some other hidden routine (maybe an interrupt)
> or piece of hardware (DMA counter etc...) is changing the value.
>
> #define TIMER (volatile int *)0x808020 // location of my timer
> for(;;)
> {
> while(*TIMER!=0); // wait for timer to time out
> }
>
> Another common question is why symbolic debugging seems to stop when the
> optimizer is used. In a similar way, the optimizer is not keeping all
> of the variables in memory, leaving the debugger with nothing to watch.
> The newer compilers are better at being able to track things that have
> become register variables but it is not always infallable. An example
> would be a loop counter.
>
> for(x=0;x<100;x++)
> *c++=*d++;
>
> In this case the compiler may decide that it would be better to use the
> onchip block repeat hardware, which incidentally works by counting down
> instead of up. The optimized re-write would look like this, and the
> value of x would not even be possible unless the debugger was told that
> x=100-RC
>
> for(x=100;x>0;x--)
> *c++=*d++;
>
> Hope this helps
> Keith Larson
> ================================================== ==============
> Mike wrote:
>
> I was wondering what I need to watch out for when using the optimize
> feature on the compiler.
>
> For example, I noticed that -o0 and -o1, the code still seems to work
> fine. At -o2 and above, it stops working.
>
> What types of things do I need to keep in mind when I use these compiler
> options?
>
> Thank you.
> -Mike
> +------------------------------------------+
> |Keith Larson |
> |Member Group Technical Staff |
> |Texas Instruments Incorporated |
> | |
> | 281-274-3288 |
> |
[email protected] |
> |------------------------------------------+
> | TMS320C3x/C4x/VC33 Applications |
> | |
> | $150 TMS320VC33 DSK's ARE AVAILABLE NOW |
> | |
> | TMS320VC33 |
> | The lowest cost and lowest power |
> | floating point DSP on the planet! |
> | 500uw/Mflop |
> +------------------------------------------+