Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

compiler variable optimization

$
0
0

Hi All !
I'm updating a variable (time_out_serial) decreasing it by 1 at each 1 milisecond on a ISR. However when the variable time_out_serial is 0 it does not leave the while loop.


I realized that because of the compiler optimization , apparently the compiler does not "know" that eventually the variable time_out_serial will be 0.

One solution would be to declare the variable as a volatile, but my question is if it's possible to configure the E2 studio compiler optimization settings, in order to, prevent from declaring the variable as a volatile.


 I have the part of the code that i'm refering to , right below :


send ()
{
    while (time_out_serial);
}


Callback_ISR (timer_callback_args_t *p_args)
{
    time_out_serial--;
}

 

 

Kind regards,

 

Phillipe


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>