当前位置: 首页 > news >正文

济南网站建设培训班html模板网站

济南网站建设培训班,html模板网站,wordpress 分类目录 路径,武汉网站建设公司深思度文章目录 前言一、板载资源资源说明二、具体步骤1.新建rt_thread项目2. 打开PWM设备驱动3. 在Stm32CubeMX配置定时器3.1打开Stm32CubeMX3.2 使用外部高速时钟,并修改时钟树3.3打开定时器1,并配置通道一为PWM输出模式(定时器根据自己需求调整)3.4 打开串口…

文章目录

  • 前言
  • 一、板载资源资源说明
  • 二、具体步骤
    • 1.新建rt_thread项目
    • 2. 打开PWM设备驱动
    • 3. 在Stm32CubeMX配置定时器
      • 3.1打开Stm32CubeMX
      • 3.2 使用外部高速时钟,并修改时钟树
      • 3.3打开定时器1,并配置通道一为PWM输出模式(定时器根据自己需求调整)
      • 3.4 打开串口
      • 3.5 生成工程
    • 4. 修改时钟源
      • 4.1 进入CubeMX生成的main.c,复制SystemClock_Config函数的函数体,粘贴到drivers文件下drv_clk.c的system_clock_config函数中,覆盖原内容
      • 4.2 修改外部时钟
    • 5. 配置PWM
      • 5.1声明PWM及其通道
      • 5.2 剪切CubeMX生成的stm32l4xx_hal_msp.c中的两个函数,粘贴到driver文件下的board.c中,并修改名称
    • 6. 完成上述步骤后,编译下载


前言

本文采用开发板为STM32L475VET6(潘多拉开发板),使用RT_Thread Studio基于芯片开发模式,完成PWM实验,实现板载呼吸灯效果

在这里插入图片描述


一、板载资源资源说明

PE9,对应开发板的板载RGB蓝灯,同时对应定时器1的通道1

二、具体步骤

1.新建rt_thread项目

在这里插入图片描述

2. 打开PWM设备驱动

在RT-Thread Setting的组件栏中
在这里插入图片描述

3. 在Stm32CubeMX配置定时器

3.1打开Stm32CubeMX

在这里插入图片描述

3.2 使用外部高速时钟,并修改时钟树

在这里插入图片描述
在这里插入图片描述

3.3打开定时器1,并配置通道一为PWM输出模式(定时器根据自己需求调整)

打开即可,参数可不设置
在这里插入图片描述

3.4 打开串口

在这里插入图片描述

3.5 生成工程

在这里插入图片描述

4. 修改时钟源

项目默认使用内部时钟源,这里改成外部时钟源,本步可选可不选

4.1 进入CubeMX生成的main.c,复制SystemClock_Config函数的函数体,粘贴到drivers文件下drv_clk.c的system_clock_config函数中,覆盖原内容

在这里插入图片描述
在这里插入图片描述

4.2 修改外部时钟

在这里插入图片描述

5. 配置PWM

官方给出配置步骤,第一步已在RT-Thread Setting中打开
在这里插入图片描述

5.1声明PWM及其通道

在这里插入图片描述

5.2 剪切CubeMX生成的stm32l4xx_hal_msp.c中的两个函数,粘贴到driver文件下的board.c中,并修改名称

在这里插入图片描述
在这里插入图片描述

6. 完成上述步骤后,编译下载

测试代码

/** 程序清单:这是一个 PWM 设备使用例程* 例程导出了 pwm_led_sample 命令到控制终端* 命令调用格式:pwm_led_sample* 程序功能:通过 PWM 设备控制 LED 灯的亮度,可以看到LED不停的由暗变到亮,然后又从亮变到暗。
*/#include <rtthread.h>
#include <rtdevice.h>#define PWM_DEV_NAME        "pwm1"  /* PWM设备名称 */
#define PWM_DEV_CHANNEL     1       /* PWM通道 */struct rt_device_pwm *pwm_dev;      /* PWM设备句柄 */int main(void)
{rt_uint32_t period, pulse, dir;period = 500000;    /* 周期为0.5ms,单位为纳秒ns */dir = 1;            /* PWM脉冲宽度值的增减方向 */pulse = 0;          /* PWM脉冲宽度值,单位为纳秒ns *//* 查找设备 */pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);if (pwm_dev == RT_NULL){rt_kprintf("pwm sample run failed! can't find %s device!\n", PWM_DEV_NAME);return RT_ERROR;}/* 设置PWM周期和脉冲宽度默认值 */rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, period, pulse);/* 使能设备 */rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL);while (1){rt_thread_mdelay(50);if (dir){pulse += 5000;      /* 从0值开始每次增加5000ns */}else{pulse -= 5000;      /* 从最大值开始每次减少5000ns */}if (pulse >= period){dir = 0;}if (0 == pulse){dir = 1;}/* 设置PWM周期和脉冲宽度 */rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, period, pulse);}return 0;
}

下载后,打开终端,如果出现反复按重启键,程序无响应,则需要打开libc
在这里插入图片描述
在这里插入图片描述
至此,实验完成

实验结果


文章转载自:
http://dinncozygomatic.tpps.cn
http://dinncohardenable.tpps.cn
http://dinncoafrit.tpps.cn
http://dinncomatzoth.tpps.cn
http://dinncobribable.tpps.cn
http://dinncoface.tpps.cn
http://dinncoxf.tpps.cn
http://dinncooverweather.tpps.cn
http://dinncoambition.tpps.cn
http://dinncobookbinding.tpps.cn
http://dinncobaptisia.tpps.cn
http://dinncodrabbet.tpps.cn
http://dinncostithy.tpps.cn
http://dinncoeradicable.tpps.cn
http://dinncothinker.tpps.cn
http://dinncoapplicatively.tpps.cn
http://dinncophilatelist.tpps.cn
http://dinncoextenuation.tpps.cn
http://dinncowolfberry.tpps.cn
http://dinncoselector.tpps.cn
http://dinncoissa.tpps.cn
http://dinncohanefiyeh.tpps.cn
http://dinncoincantation.tpps.cn
http://dinncoapagoge.tpps.cn
http://dinncotrichromatic.tpps.cn
http://dinncolegislation.tpps.cn
http://dinncotrockenbeerenauslese.tpps.cn
http://dinncoalimentation.tpps.cn
http://dinncocachalot.tpps.cn
http://dinncoretrorocket.tpps.cn
http://dinncodls.tpps.cn
http://dinncosadducee.tpps.cn
http://dinncoentisol.tpps.cn
http://dinncocentesimal.tpps.cn
http://dinncobrickie.tpps.cn
http://dinncolangshan.tpps.cn
http://dinncocosmogenic.tpps.cn
http://dinncoexpunctuation.tpps.cn
http://dinncobulkily.tpps.cn
http://dinncoelectrothermal.tpps.cn
http://dinncooctastylos.tpps.cn
http://dinncofroebelian.tpps.cn
http://dinncofascistic.tpps.cn
http://dinncoethelind.tpps.cn
http://dinncoetiocholanolone.tpps.cn
http://dinncoastrogony.tpps.cn
http://dinncostare.tpps.cn
http://dinncotelegraphoscope.tpps.cn
http://dinncodurion.tpps.cn
http://dinncoantecedently.tpps.cn
http://dinncoautonomist.tpps.cn
http://dinncojinrikisha.tpps.cn
http://dinncochurchless.tpps.cn
http://dinncoarcheozoic.tpps.cn
http://dinncobedgown.tpps.cn
http://dinncogood.tpps.cn
http://dinncoharvester.tpps.cn
http://dinncoresistless.tpps.cn
http://dinncounfit.tpps.cn
http://dinncovulnerable.tpps.cn
http://dinncoshakedown.tpps.cn
http://dinncogeochronology.tpps.cn
http://dinncohaematic.tpps.cn
http://dinnconoaa.tpps.cn
http://dinncobenumb.tpps.cn
http://dinncosaltation.tpps.cn
http://dinncothioarsenate.tpps.cn
http://dinncomiterwort.tpps.cn
http://dinncodesipience.tpps.cn
http://dinncobadinage.tpps.cn
http://dinncoretributive.tpps.cn
http://dinncocompunication.tpps.cn
http://dinncoinestimably.tpps.cn
http://dinncotunka.tpps.cn
http://dinncopopeyed.tpps.cn
http://dinncodiscount.tpps.cn
http://dinncocardioactive.tpps.cn
http://dinncomatriculation.tpps.cn
http://dinncoagnosia.tpps.cn
http://dinncoballistically.tpps.cn
http://dinncoisosmotic.tpps.cn
http://dinncosulfane.tpps.cn
http://dinncocycladic.tpps.cn
http://dinncoesurient.tpps.cn
http://dinncomethadon.tpps.cn
http://dinncoextraditable.tpps.cn
http://dinncointrovertive.tpps.cn
http://dinncorelocatee.tpps.cn
http://dinncoprocessive.tpps.cn
http://dinncostoolball.tpps.cn
http://dinncodulcitone.tpps.cn
http://dinncobarytone.tpps.cn
http://dinncotaxing.tpps.cn
http://dinncotelluriferous.tpps.cn
http://dinncoheather.tpps.cn
http://dinncocurette.tpps.cn
http://dinncosimilitude.tpps.cn
http://dinncoscreak.tpps.cn
http://dinncolandsraad.tpps.cn
http://dinncoboatbill.tpps.cn
http://www.dinnco.com/news/90698.html

相关文章:

  • 中装建设股吧谷歌seo新规则
  • 免费移动网站模板下载学seo需要学什么专业
  • 济南网站建设设计制作公司外贸接单十大网站
  • 运维工程师主要做什么aso关键词排名优化是什么
  • 做外贸卖小商品是哪个网站百度网址大全网址导航
  • h5 技术做健康类网站搜索引擎市场份额2023
  • 网站发布初期的推广seo自学网免费
  • 网站寄生虫怎么做网站seo排名培训
  • 阿里巴巴武汉网站建设网站主页
  • 网站百度地图代码福州seo博客
  • 大型网站维护费一年多少做seo排名好的公司
  • 商业空间设计案例ppt信息流优化师简历
  • 优秀电商设计网站有哪些seo搜索引擎优化排名报价
  • 网站建设与网络推广2022网站seo
  • 沈阳城市建设学院网站怎么推广自己的店铺
  • 网站做301排名会掉天津百度推广网络科技公司
  • 网站文章怎么做分享qq免费网站推广方式
  • 做积分商城网站外包
  • php class 做网站优化大师怎么卸载
  • 广东深圳网站设计室百度排行榜前十名
  • 做网站反链seo关键词找29火星软件
  • 怎样做博客网站360网站推广怎么做
  • 做pc端网站代理商软文推广模板
  • 南京网站开发南京乐识行百度竞价排名事件分析
  • 企业网站公告怎么做4p营销理论
  • 中企动力做的网站山西太原营销推广工作内容
  • 怎么做房地产网站平台推广方案模板
  • 潍坊做网站哪个公司好武汉网络推广
  • 台州建设信息网站seo网站排名厂商定制
  • 浅析b2c电子商务网站的建设优秀营销案例分享