// Stop the timer
TCCR0 = 0;
// Reset the timer
TCNT0=0;
if(pulse_flag == 3)
while (1)
{
display_lux();
[COLOR="#FF0000"] #asm("cli")[/COLOR]
set_delay();
[COLOR="#FF0000"] #asm("sei")[/COLOR]
}
Whenever you have variables invoked in both main and interrupt you have to be careful because the code may be interrupted in the wrong time so you have to ensure that these parts are executed atomically
only if variables occupy more than 8 bits in memory or have complex operations done on them (like shift), other wise it is pretty safe.alexan_e said:Whenever you have variables invoked in both main and interrupt you have to be careful because the code may be interrupted in the wrong time so you have to ensure that these parts are executed atomically
* previously you say set_delay() takes just 17 us. Is this always 17us or may vary?
* what does "atomically" mean? is there any clear explanation of this?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?