• 基于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 

  • 相关阅读:
    MySQL -- mysql connect
    三策略,六步骤,Jenkins 迁移到极狐GitLab CI 的终极指南
    【C++】c++引用和小细节
    linux下抽取pdf的单双页命令
    数据结构-图的存储结构
    IIS 网站初始化与 Keep alive
    【密码学-凯撒密码】
    固定资产设备管理系统
    SpringCloud 使用与Nacos
    【云服务器】阿里云部署项目、攻击CPU解决方案
  • 原文地址:https://blog.csdn.net/m0_74295839/article/details/127942825