Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how i can use Interuption in program

Status
Not open for further replies.

danilk

New Member
hi everyone , i have a problems about interuption in AVR atmega, i trying to solve a problems is

Turn led with two buttons
bt1 in pd2 (int0)
bt2 in pd3 (int1)
LED must be Eteine if it exceeds 20s staying on, for that you need to configure a temp basis interupption for each 1s and realize a timer that counts the seconds
party to achieve
the configuration input output
int0 configure and int1
ISR (int0) and SRI (int1)
configure the interuption of SRI timer 1
SRI (tcnt1_compa_vect)
incrementation of the counter
reset to zero of the counter
any solution ?
 
Unfortunately it is difficult to tell what you are asking. Please ask someone to help you with the translation so that people can understand your question.
 
Could you pleaser attach your full code? Use code tags if possible:
{code}
//code here
{/code}
^replace above {} with [] so it looks like this:
Code:
//code here
I'm no expert in AVR on in any code in that manner but still, willing to help!
what I understood, is that you want led to turn OFF after 20 seconds?
If that's the case, what funtion buttons serve? Counter on/off and reset?
I'd do it so instead of counting seconds each time second has passed, I'd use Interrupt with timer registry with either overflow or compare-match method, which are then combined with timer interrupt....
IF timing is not issue/non-cricital, you could also use chip-timer (millis for example) and use switches with boolean status.
After writing this, I realized this is AVR, not arduino but oh well, those are still my cup of tea in this subject :D...
 
What Atmega? What development environment?

In my current project I use int4 for a button.
C:
/* Initialize interrupts for button in INT4 (PORTE PIN4) */
DDRE &= ~(1<<4);      /* PE4 as input */
PORTE &= ~(1<<4);     /* No pullups (external pull-ups) */
EIMSK |= (1<<INT4);   /* Enable INT4 */
sei();                /* Enable global interrupts */

And the ISR is:
C:
ISR(INT4_vect)
/* This handles Button presses */
{
    /* Toggle LED etc.*/
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top