Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

Interrupts don't work

2 posters

Go down  Message [Page 1 of 1]

1Interrupts don't work Empty Interrupts don't work Thu Oct 26, 2023 7:54 pm

ry



Regardless of the mcu I select no interrupt or timer works. But the code works just fine on the physical circuit. Is this a bug or some setting I need to do of sort?

2Interrupts don't work Empty Re: Interrupts don't work Fri Oct 27, 2023 1:56 am

arcachofo

arcachofo

Hi.
Difficult to know what is the problem without more information.

You can open and test some examples to see if everything is ok:
File Explorer->Examples->Micro.

3Interrupts don't work Empty Re: Interrupts don't work Fri Oct 27, 2023 2:31 am

ry



I wrote the follwing code that works except when I use the simulator

#include
#include
#include

ISR(INT0_vect){
PORTB = 0xff;
_delay_ms(10000);
}

int main(){

MCUCR |= (1 << ISC11 | 1 << ISC01);
GIMSK |= (1 << INT0 | 1 << INT1);
sei();
DDRD = 0x00;
PORTD = 0xff;
DDRB = 0xFF;
while (1)
{
/* code */
PORTB = 0xff;
_delay_ms(500);
PORTB = 0x00;
_delay_ms(500);
}
return 0;
}

4Interrupts don't work Empty Re: Interrupts don't work Fri Oct 27, 2023 2:35 am

arcachofo

arcachofo

To post code please use the"code" button.
If not, the includes will not appear.

Interrupts don't work Kk27

5Interrupts don't work Empty Re: Interrupts don't work Fri Oct 27, 2023 3:09 am

arcachofo

arcachofo

And which Microcontroller are you using?

6Interrupts don't work Empty Re: Interrupts don't work Fri Oct 27, 2023 4:17 pm

ry



I'm using the attiny4313 , I tried the 2313 but it didn't work either.

here's the code again

Code:


#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

ISR(INT0_vect){
  PORTB = 0xff;
  _delay_ms(10000);
}

int main(){

  MCUCR |= (1 << ISC11 | 1 << ISC01);
   GIMSK |= (1 << INT0 | 1 << INT1);
  sei();
  DDRD = 0x00;
  PORTD = 0xff;
  DDRB = 0xFF;
  while (1)
  {
    /* code */
    PORTB = 0xff;
    _delay_ms(500);
    PORTB = 0x00;
    _delay_ms(500);
  }
  return 0;
}

7Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 5:12 am

arcachofo

arcachofo

Thanks.

There is an error in an xml file, you can fix it yourself:
data/AVR/tinyx313/tinyx313_regs.xml

At line 95, change mask="00010011" for mask=""
at line 112, change mask="00000111" for mask="11100000"

8Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 5:49 am

ry



It more or less broke the 1.0.0 version and in the 1.1.0 it detects the interrupt but won't return from it

9Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 5:52 am

arcachofo

arcachofo

It is working for me.

It more or less broke the 1.0.0 version
Can you explain what that means?

and in the 1.1.0 it detects the interrupt but won't return from it
Did you wait 10 seconds (circuit time)?

10Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 5:56 am

ry



In the stable version the mcu won't read the code, I used the mcu monitor and only portd is what it should be.

in version 1.1.0 it works when I push the push button but i waited like 5 minutes and it still keeps all the leds on. It's like it won't return from the interrupt , this is also a similar to a problem I have whenever I use assembly , it won't return from subroutines unless I use rcall , ret doesn't work.

11Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 6:01 am

ry



Update on the test with version 1.0.0 , the problem is the sei() function , when I remove it the code works as should , minus the enable interrupts. But with it it's like none of the other registers actually have the value I try to load in them

12Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 6:05 am

arcachofo

arcachofo

Try this code:
Code:

#define F_CPU 8000000L

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

ISR( INT0_vect ){
    PORTB = 0xf0;
    _delay_ms(1000);
}

ISR( INT1_vect ){
    PORTB = 0x0f;
    _delay_ms(1000);
}

int main()
{
    MCUCR |= (1 << ISC11 | 1 << ISC01);
    GIMSK |= (1 << INT0 | 1 << INT1);
   
    DDRD = 0x00;
    PORTD = 0xff;
    DDRB = 0xFF;
   
    sei();
   
    while (1)
    {
        PORTB = 0x00;
    }
    return 0;
}

13Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 6:17 am

arcachofo

arcachofo

Seems that in 1.0.0 an unintented interrupt is triggered at sei().

1.1.0 is working ok for me.

14Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 6:19 am

ry



I tried the code, it worked for the first press at the start of the simulation , but afterwards it doesn't work again

15Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 6:37 am

arcachofo

arcachofo

Ok, definetly 1.0.0 is triggering an extra interrupt, apart of that it is working ok
But let's leave this version aside for now.

1.1.0 is working for me in all cases (circuit and code attached).
Maybe you are using a different circuit.
If you want to share it I can test.
Attachments
Interrupts don't work Attachmenttiny2313_INTx.zip
You don't have permission to download attachments.
(6 Kb) Downloaded 3 times

16Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 8:41 am

ry



It worked, my code works when I build it using microchip studio, I've been using platform io to build it , why is this the case?

17Interrupts don't work Empty Re: Interrupts don't work Sat Oct 28, 2023 8:55 am

arcachofo

arcachofo

It worked, my code works when I build it using microchip studio, I've been using platform io to build it , why is this the case?
Nice to know.

18Interrupts don't work Empty Timer's won't start Sat Oct 28, 2023 4:42 pm

ry



How do I fix the timer issue , the timers don't start

19Interrupts don't work Empty tiny4313 timer issue Mon Oct 30, 2023 6:35 am

ry



I forgot to add the mcu, I'm using the tiny4313, the timer won't start

I have this code

Code:

TCCR1B = (1<<CS12|1<<CS10|1<<WGM12);
  OCR1A = 7812;
  TIMSK = (1<<OCIE1A);

and for the isr

Code:
ISR(TIMER1_COMPA_vect){
  seconds=20;
  if(seconds == 60){
    seconds = 0;
    minutes++;
  }
  if(minutes == 60){
    minutes = 0;
    hours++;
  }
  if(hours == 24){
    hours = 0;
    minutes = 0;
    seconds = 0;
  }
}

i also tried timer0

20Interrupts don't work Empty Re: Interrupts don't work Mon Oct 30, 2023 9:28 am

arcachofo

arcachofo

Thanks for the code, I will have a look.

21Interrupts don't work Empty Timers in attinyx313 Thu Nov 09, 2023 9:16 pm

ry



Hello ,
Did you get a chance to take a look at the problem with the timers in the tinyx313 MCUs?

22Interrupts don't work Empty Re: Interrupts don't work Fri Nov 10, 2023 10:36 am

arcachofo

arcachofo

Hi.
Yes, confirmed that Timer1 is not working, I'm working on it.
Timer0 works for me, but maybe does not work in all configurations.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum