Author: Not specified Language: asm
Description: Not specified Timestamp: 2017-09-19 15:05:45 +0000
View raw paste Reply
  1. /*
  2.  * GccApplication1.c
  3.  *
  4.  * Created: 9/19/2017 3:41:01 PM
  5.  *  Author: Micro_Lab
  6.  */
  7.  
  8.  
  9. #include <avr/io.h>
  10.  
  11. #define F_CPU 8000000UL //matching fq
  12. #include <util/delay.h>
  13. #include <avr/interrupt.h>
  14.  
  15. ISR(INT0_vect){  //external interrupt 0
  16.         int count = 3; // three times
  17.         while(count){
  18.                 PORTD = 0xFF; // led on
  19.                 _delay_ms(150);
  20.                 PORTD = 0x00; // led off
  21.                 _delay_ms(100);
  22.                 count--;
  23.         }
  24. }
  25.  
  26. int main(void)
  27. {
  28.         DDRD = 0b11100000; //set output ports
  29.         sei(); //global interrupt enabled; the i bit in the status register sreg is set to one
  30.         EIMSK = 0b00000001;//external interrupt enabled
  31.         EICRA = 0b00000000;
  32.         while(1)
  33.         {
  34.                 PORTD = 0b10000000;
  35.                 _delay_ms(500);
  36.                 PORTD = 0b01000000;
  37.                 _delay_ms(500);
  38.                 PORTD = 0b00100000;
  39.                 _delay_ms(500);
  40.         }
  41. }
View raw paste Reply