STM8L_6_EXIT:
1.User:工程及main文件
2.Hardware:EXIT,CLK,LED,Delay
3.STM8L15x_StdPeriph_Driver:STM8自带库文件
4.Debug:hex文件存放于EXE文件夹
5.Function: 外部中断上升沿触发,翻转LED
/**
******************************************************************************
* @file main.c
* @author Alex——小白
* @version V1.0
* @date 2019.5.1
* @brief 外部中断点灯
* @store 有家Proteus仿真店子
* @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) //若有其他3号引脚,如PA3,可再次使用if判断PA3是否为0来区分PD3
{
Delay(0x7FFF); //近10ms
if(GPIO_ReadInputDataBit(KEY_IOPORT,GPIO_Pin_3) == RESET)
{
LED0_Toggle();
}
}
EXTI_ClearITPendingBit(EXTI_IT_Pin3);
}
上一篇:STM8L151C8单片机学习例程(7)——ADC采集,串口发送电压值
下一篇:STM8L151C8单片机学习例程(5)——TIMER1定时0.5s
推荐阅读最新更新时间:2024-11-07 21:25