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

  • 相关阅读:
    面了个腾讯拿38K跳槽出来的,见识到了真正的测试天花板
    巴斯光年python turtle绘图__附源代码
    关于麒麟x86docker问题
    SpringBoot整合Elasticsearch实现分页条件查询及注意事项
    用事务代码查看视图的函数
    体验极速——在旭日X3派上使用双频1300M USB无线网卡
    C++入门及简单例子_4
    图解Tire树+代码实现
    【MySQL】数据库基础
    拦截器
  • 原文地址:https://blog.csdn.net/m0_74295839/article/details/127942825