STM8L151C8 MCU learning routine (6) - External interrupt rising edge trigger

Publisher:数字狂想Latest update time:2022-01-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

STM8L_6_EXIT:

1.User: Project and main files

2.Hardware:EXIT,CLK,LED,Delay

3.STM8L15x_StdPeriph_Driver: STM8 comes with library files

4.Debug: The hex file is stored in the EXE folder

5.Function: External interrupt rising edge trigger, flip LED


/**

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

* @file    main.c

* @author  Alex——Xiaobai

* @version V1.0

* @date    2019.5.1

* @brief    External interruption lighting

* @store    has a Proteus simulation store

* @Link    https://shop484534014.taobao.com/

* @Email 844545015@qq.com

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

* @attention All Rights Reserved  

**/

 

#include "stm8l15x.h"

#include "LED.h"

#include "Delay.h"

#include "CLK.h"

#include "EXIT.h"

 

void main(void)

{

    CLK_HSI_Config(CLK_SYSCLKDiv_1);    //HSI 1分频 16MHz

    LED_Init();                         //LED FLash

    EXIT_Init();

    

    enableInterrupts();

    while(1)

    {

        

    }

}

 

INTERRUPT_HANDLER(EXTI3_IRQHandler,11)

{

    /* In order to detect unexpected events during development,

       it is recommended to set a breakpoint on the following instruction.

    */

    if(GPIO_ReadInputDataBit(KEY_IOPORT,GPIO_Pin_3) == RESET) //If there is another pin 3, such as PA3, you can use if again to determine whether PA3 is 0 to distinguish PD3

    {

        Delay(0x7FFF); //nearly 10ms

        if(GPIO_ReadInputDataBit(KEY_IOPORT,GPIO_Pin_3) == RESET)

        {

            LED0_Toggle();

        }

    }    

    

    EXTI_ClearITPendingBit(EXTI_IT_Pin3);

}

Reference address:STM8L151C8 MCU learning routine (6) - External interrupt rising edge trigger

Previous article:STM8L151C8 MCU learning routine (7) - ADC acquisition, serial port sending voltage value
Next article:STM8L151C8 MCU learning routine (5)——TIMER1 timing 0.5s

Latest Microcontroller Articles
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号