• 基于stm32单片机的输入捕获测量脉宽Proteus仿真


    资料编号:109  下面是相关功能视频演示:

    109-基于stm32的输入捕获测量脉宽Proteus仿真(源码+仿真+全套资料)

    功能介绍:

    采用stm32单片机作为主控,采用单片机的GPIO进行输入捕获,可以测量按键按下的低电平脉宽时间,采用LCD1602显示,全套资料齐全

    程序采用C语言,仿真使用Proteus,程序有中文注释,方便理解:

     下面是部分程序展示:

    #include "stm32f10x.h"
    #include "bsp-lcd1602.h"
    #include "delay.h"
    #include "sys.h"
    #include "adc.h"
    #define BEEP PAout(3)
    #define KEY1 PAin(0)
    #define KEY2 PAin(1)
    void LED_Init(void)
    {
     
     GPIO_InitTypeDef  GPIO_InitStructure;
         
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);     //使能P端口时钟
        
     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;                 //LED0 端口配置
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;          //推挽输出
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_Init(GPIOA, &GPIO_InitStructure);
     GPIO_SetBits(GPIOA,GPIO_Pin_3);                         //输出高


    }
    void KEY_Init(void)
    {
        GPIO_InitTypeDef GPIO_InitStructure; //定义结构体变量    
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
        
        
        GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1;
        GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;    //上拉输入
        GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
        GPIO_Init(GPIOA,&GPIO_InitStructure);
    }
    int main(void)
    {
    int a,b,c,d;
        int temp=0;
        
        delay_init();             //延时函数初始化          
        LCD1602_Init(); 
        LCD1602_ShowStr(8,0,"",3);
        LED_Init();
        KEY_Init();    
        while(1)
        {
    if(KEY2==0)
    {
    BEEP=0;
    temp++;
    }
    else BEEP=1;
    if(KEY1==0)
    {
    temp=0;
    }

        a=temp/100;
        b=temp%100/10;
        c=temp%10;
        LCD_ShowNum(8,0,a);
        LCD_ShowNum(9,0,b);
        LCD_ShowNum(10,0,c);

     delay_ms(20);

        }
    }

    下面是该资料的分享下载链接:

    https://pan.baidu.com/s/1fGhGBi58W77aUMOjzWuTKg?pwd=u14x 

  • 相关阅读:
    什么是RDB和AOF?
    RabbitMQ消息中间件概述
    视频融合平台EasyCVR语音播报功能无法关闭,且告警信息与其需要警告的内容不匹配该如何解决?
    golang笔记 mutex,抢占式调度,semaphore
    java基础03
    windows Vscode 连接 虚拟机,超详细,含免密免ip配置 以 linux 虚拟机为例
    二进制安装1.26版本k8s(docker)
    Codeforces Round #816 (Div. 2) B - Beautiful Array
    安卓实现微信聊天气泡
    快速掌握并发编程 --- 基础篇
  • 原文地址:https://blog.csdn.net/m0_74295839/article/details/127942825