avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Something I don't understand (loops and interrupts)


From: BERTRAND Joël
Subject: Re: Something I don't understand (loops and interrupts)
Date: Fri, 3 Apr 2020 14:23:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 SeaMonkey/2.53.1

Jim Jackson a écrit :
> 
> Not looked too closely, but ...
> 
> On Fri, 3 Apr 2020, BERTRAND Joël wrote:
> 
>> ISR(TIMER1_COMPA_vect, ISR_BLOCK)
>> {
>>     uint8_t     i;
>>
>>     interrupt_counter = (interrupt_counter + 1) % 25;
>>
>>     if (interrupt_counter == 0) // 1 s
>>     {
>>         gpio_toggle(&i_led[i_work]);
>>     }
>>
>>     // Switch debug leds off
>>     for(i = 0; i < i_max; i++)
>>     {
>>         if (interrupt_counter == 0) serial_send_byte(i);
> 
> This gets called every time the for loop iterates, so will get called i_max 
> times, all but the first call will cuase serial_send_byte(i) to loop 
> waiting for the transmit buffer to empty. You do NOT want to be calling
> serial_send_byte(i) in an ISR anyway. Check for interrupt_counter == 0 in 
> the main loop, and make sure it's declared volatile.

        I agree, but I dont have any other solution to debug. I only try to
discover why several leds are not switched off.

        For example: in main(), I call gpio_on(&i_led[i_comm_ok], 5);
Thus, i_comm_ok should be turned off after 0.25 s. And this led remains
on...

        Regards,

        JB



reply via email to

[Prev in Thread] Current Thread [Next in Thread]