can any one give me c code for ext int0 for attiny2313
can any one give me c code for ext int0 for attiny2313
i m working with attiny2313.can any one give me c code to genrate ext int0...
Re: can any one give me c code for ext int0 for attiny2313
Hi,
Try this ::
This code will increment the value on PORTB on every falling edge on PORTD.3.
Regards,
Filip.
Try this ::
Code: Select all
int cnt = 0; // Global variable cnt
void interrupt_ISR () org IVT_ADDR_INT1 { // Interrupt rutine
SREG_I_bit = 0; // Disable Interrupts
cnt++; // Increment variable cnt
SREG_I_bit = 1; // Enable Interrupts
}
void main() { // Main program
DDRD = 0xF7; // Set PORTD.3 as input
DDRB = 0xFF; // Set PORTB as output
// Clear PORTB and PORTD
PORTD = 0;
PORTB = 0;
PCMSK = 0x08; // Set PORTD.3 as the interrupt pin in this example
MCUCR = 0x08; // Set interrupt for falling edge on PORTD.3
GIMSK = 0x80; // External interrupt for INT1 (PORTD.3) is enabled
SREG_I_bit = 1; // Enable Interrupts
while(1){ // Unending loop
PORTB = cnt; // Write on PORTB value of varibale cnt
}
}
Regards,
Filip.