Page 1 of 1

Problems Using Interrupts on Atmega88

Posted: Wed Sep 15, 2021 11:07 am
by Oderlando
Hi. I'm recently testing an Atmega88 so far I've had a lot of problems. After a few attempts I managed to make a led blink (because I didn't know the chip settings well). But I can only make it blink using using pooling. Another port should be told using interrupts, but it doesn't work. I selected different ports and verified that the problem is not with the port, but with the interrupt tool. I often use PIC and I use very little AVR. I've used an Atmega328P before, but this Atmega88 is giving me problems. The tests were done in simulations and in real tests. Could someone give me a tip? I'm posting the file.

Re: Problems Using Interrupts on Atmega88

Posted: Wed Sep 15, 2021 6:26 pm
by mnf
Hi Oderlando,

I think you are trying to be too 'precise' on the comparisons -

if clock = 1 (which might get caught on the first loop) and if clock = 7800 (which is very unlikely to ever get a hit)

You need to check for a 'range' - so for example (if clock > 1000 and clock < 5000)

You also have delays in your code (during which time clock keeps incrementing).

What are you trying to achieve? Currently it looks like you want to 'switch on' the LED at the start and then off at ~0.5s - however after the delays '1' (to turn the LED back on is very unlikely to be hit....

Martin

Re: Problems Using Interrupts on Atmega88

Posted: Wed Sep 15, 2021 6:37 pm
by Oderlando
Hi. I'm trying to make the led blink to check if the interrupts are working. The second led blinks using a delay so I can see if the chip is really working (Because the breadboard connections are not so good and I can check if the chip is being powered).

Re: Problems Using Interrupts on Atmega88

Posted: Wed Sep 15, 2021 6:56 pm
by mnf
Here is a blinkie using interrupt...

On the ATTiny board I have the power LED (green) is too bright and the 'test' LED (red) is outshone... You might also need to adjust the clock speed - here it's 8MHz (the HW-Tiny boards run at 12MHz - if that's what you are using?)
I used a USBTiny programmer...

Here I'm using D0 as the pin (which has the inbuilt LED attached) - and I've gone with an approx 1s blink using a 30Hz (actually 30.58Hz) interrupt.
attiny88.fcfx
(8.7 KiB) Downloaded 230 times
Note - you could add a 1->d2 delay 0->d2 before the loop as a check (but not in the loop) if required

Martin

Re: Problems Using Interrupts on Atmega88

Posted: Thu Sep 16, 2021 12:48 pm
by Oderlando
Hello Martin! I used your flowchart and adapted it for Atmega88. Worked perfectly ! I am very grateful for your willingness to have helped. You really took me out of a puzzle to make interrupts work. Thank you very much !

Re: Problems Using Interrupts on Atmega88

Posted: Thu Sep 16, 2021 12:54 pm
by mnf
No problem - glad it worked... I'd misread your post as ATTiny88 :roll:

The principle should be the same though.....