Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
read this program. its working well with int1. tell me how can I use both int0 & int1??
////////////////////////////////////////////////////////////////////////////////////////
int cnt = 0, cnt2 = 0; // Global variable cnt
void interrupt_ISR () org IVT_ADDR_INT1
{ // Interrupt rutine
SREG_I_bit = 0; // Disable Interrupts
cnt++;
PORTD = cnt; // Increment variable cnt
SREG_I_bit = 1; // Enable Interrupts
}
void interrupt_ISR () org IVT_ADDR_INT0 // Look here. how can I call/enable
intrrupt 1?
{ // Interrupt rutine
SREG_I_bit = 0; // Disable Interrupts
cnt2++;
PORTC = cnt; // Increment variable cnt
SREG_I_bit = 2; // Enable Interrupts
}
void main()
{ // Main program
DDRD = 0b00110011; // Set PD3 as input
DDRB = 0xFF;
DDRC = 0xFF; // Set PortB as output
//PORTD = 0x00;
PORTB = 0xFF; // Starting value for PortD
GICR = 0x80; // Set the Interrupts
MCUCR = 0x08; // Configure Interrupt for falling edge on PortD.3
SREG_I_bit = 1; // Enable Interrupts
while(1)
{ // Unending loop
PORTB = 0xFF;
Delay_ms(10);
PORTB = 0x00;
Delay_ms(10);
// Write on PortB value of varibale cnt
}
}
////////////////////////////////////////////////////////////////////////////////////////
int cnt = 0, cnt2 = 0; // Global variable cnt
void interrupt_ISR () org IVT_ADDR_INT1
{ // Interrupt rutine
SREG_I_bit = 0; // Disable Interrupts
cnt++;
PORTD = cnt; // Increment variable cnt
SREG_I_bit = 1; // Enable Interrupts
}
void interrupt_ISR () org IVT_ADDR_INT0 // Look here. how can I call/enable
intrrupt 1?
{ // Interrupt rutine
SREG_I_bit = 0; // Disable Interrupts
cnt2++;
PORTC = cnt; // Increment variable cnt
SREG_I_bit = 2; // Enable Interrupts
}
void main()
{ // Main program
DDRD = 0b00110011; // Set PD3 as input
DDRB = 0xFF;
DDRC = 0xFF; // Set PortB as output
//PORTD = 0x00;
PORTB = 0xFF; // Starting value for PortD
GICR = 0x80; // Set the Interrupts
MCUCR = 0x08; // Configure Interrupt for falling edge on PortD.3
SREG_I_bit = 1; // Enable Interrupts
while(1)
{ // Unending loop
PORTB = 0xFF;
Delay_ms(10);
PORTB = 0x00;
Delay_ms(10);
// Write on PortB value of varibale cnt
}
}