atmega8 routine: INT1 external interrupt

Publisher:平静宁静Latest update time:2018-07-16 Source: eefocusKeywords:atmega8  INT1 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere


 

 


/***********************************************************

* Function library description: ATMEGE8 INT1 interrupt program                        

* Version: v1.0       

************************************************************

*Note: button PD3                                         

*       LED     PD5

*       buzzer  PB1                                         

***********************************************************/

 

#include

#include

 

int main(void)

{

    //PD3 external interrupt 1 port is set as output

    DDRD &= ~(1 << DDD3);

    //PD3 pull-up resistor enable

    PORTD |= (1 << PORTD3);

    //Buzzer control port is output

    DDRB |= (1 << DDB1);

    DDRC |= (1 << DDC5);

    

    //INT1 falling edge trigger

    MCUCR |= (1 << ISC10) | (1 << ISC11);

    //INT1 interrupt enable

    GICR |= (1 << INT1);

 

    // Enable global interrupt

    be();

 

    while(1)

    {

        

    }

 

 

 

    return 0;

}

 

//External interrupt 1 service routine

SIGNAL(SIG_INTERRUPT1)

{

    PORTB ^= (1 << PORTB1); 

    PORTC ^= (1 << PORTC5); 

}


Keywords:atmega8  INT1 Reference address:atmega8 routine: INT1 external interrupt

Previous article:AVR external interrupt INT1 detects the key and uses LED for indication
Next article:Atmage16 interrupt learning - external interrupt

Recommended ReadingLatest update time:2024-11-16 15:04

ATmega88 Power Saving Mode
When SM2..0 is 011, the SLEEP instruction will put the MCU into power-saving mode. This mode is different from the power-down mode in one respect: if the timer/counter 2 and/or are enabled, they continue to run during device sleep. In addition to the wake-up method of the power-down mode, the overflow interrupt and c
[Microcontroller]
ATMEGA8 Designed 8-way Keyboard D-type Trigger Latch
Achievement purpose: When a pin is configured as an input, learn how to program a pull-up resistor to simplify the hardware. How to use software to control sampling frequency and time to achieve anti-interference purpose. In order to make the program run more stably and preve
[Microcontroller]
ATMEGA8 Designed 8-way Keyboard D-type Trigger Latch
ATmega8 reference voltage enable signal and startup time
ATmega8 has an on-chip bandgap reference source for brownout detection or as an input to an analog comparator or ADC. The 2.56V reference voltage of the ADC is generated by this on-chip bandgap reference source. The startup time of the voltage reference may affect its operation. The startup times are listed in Table
[Microcontroller]
ATmega8 reference voltage enable signal and startup time
atmega8l direct drive pen segment lcd driver
#include "include.h" uchar lcdtab ={{{0x07,0x01,0x03},{0x04,0x00,0x02},{0x06,0x03,0x01}, {0x06,0x02,0x03},{0x05,0x02,0x02},{0x03,0x02,0x03},{0x03,0x03,0x03},{0x06,0x00,0x02}, {0x07,0x03,0x03} ,{0x07,0x02,0x03}}, {{0x18,0x14,0x0c},{0x10,0x10,0x00},{0x18,0x08,0x0c}, {0x18,0x18,0x08}, {0x10,0x1c,0x00},{0x08,0x1c,0x08},{
[Microcontroller]
ATMega8 PWM function (T/C 1) test program
#include #include avr/delay.h #define uchar unsigned char #define uint unsigned int #define FREQ 4 //延时 void DelayMs(uint ms) {       uint i;       for(i=0;i ms;i++)         _delay_loop_2(FREQ * 250); } int main (void) {       uchar direction=1;       uchar pwm=0;             //       8-bit phase
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号