can any one give me c code for ext int0 for attiny2313

Post your requests and ideas on the future development of mikroC PRO for AVR.
Post Reply
Author
Message
sallo124
Posts: 8
Joined: 09 Sep 2012 08:27

can any one give me c code for ext int0 for attiny2313

#1 Post by sallo124 » 09 Sep 2012 09:52

i m working with attiny2313.can any one give me c code to genrate ext int0... :shock:

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: can any one give me c code for ext int0 for attiny2313

#2 Post by filip » 14 Sep 2012 12:58

Hi,

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
  }
}
This code will increment the value on PORTB on every falling edge on PORTD.3.

Regards,
Filip.

sallo124
Posts: 8
Joined: 09 Sep 2012 08:27

Re: can any one give me c code for ext int0 for attiny2313

#3 Post by sallo124 » 21 Sep 2012 13:39

thank u filip

Post Reply

Return to “mikroC PRO for AVR Wish List”