Problems Using Interrupts on Atmega88

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Oderlando
Posts: 33
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Problems Using Interrupts on Atmega88

Post 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.
Attachments
Teste_Atmega88.fcfx
(9.91 KiB) Downloaded 2 times

mnf
Valued Contributor
Valued Contributor
Posts: 1096
Joined: Wed May 31, 2017 11:57 am
Has thanked: 66 times
Been thanked: 418 times
Contact:

Re: Problems Using Interrupts on Atmega88

Post 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

Oderlando
Posts: 33
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Re: Problems Using Interrupts on Atmega88

Post 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).

mnf
Valued Contributor
Valued Contributor
Posts: 1096
Joined: Wed May 31, 2017 11:57 am
Has thanked: 66 times
Been thanked: 418 times
Contact:

Re: Problems Using Interrupts on Atmega88

Post 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 3 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

Oderlando
Posts: 33
Joined: Tue Jul 17, 2018 11:30 am
Has thanked: 7 times
Been thanked: 3 times
Contact:

Re: Problems Using Interrupts on Atmega88

Post 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 !

mnf
Valued Contributor
Valued Contributor
Posts: 1096
Joined: Wed May 31, 2017 11:57 am
Has thanked: 66 times
Been thanked: 418 times
Contact:

Re: Problems Using Interrupts on Atmega88

Post by mnf »

No problem - glad it worked... I'd misread your post as ATTiny88 :roll:

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

Post Reply