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

flash 做网站教程中国新闻网最新消息

flash 做网站教程,中国新闻网最新消息,做网站的公司北京有哪些,专门做网站的公司叫什么1、实验目的 使用定时器 4 通道 3 生成 PWM 波控制 LED1 ,实现呼吸灯效果。 频率:2kHz,PSC71,ARR499 利用定时器溢出公式 周期等于频率的倒数。故Tout 1/2KHZ;Ft 72MHZ PSC71(喜欢设置成Ft的倍数&…

1、实验目的

使用定时器 4 通道 3 生成 PWM 波控制 LED1 ,实现呼吸灯效果。
频率:2kHz,PSC=71,ARR=499

利用定时器溢出公式

 周期等于频率的倒数。故Tout = 1/2KHZ;Ft = 72MHZ

PSC=71(喜欢设置成Ft的倍数),ARR=499

其实PSC与ARR的组合有很多种,上面只是一种

2、实现实验

复制03-流水灯的项目文件夹,重命名为18-呼吸灯

新建文件夹pwm。pwm.c和pwm.h文件

加载文件

 编译

加载定时器的.c文件

 

代码:

main.c

#include "sys.h"
#include "delay.h"
#include "led.h"
#include "pwm.h"int main(void)
{HAL_Init();                         /* 初始化HAL库 */stm32_clock_init(RCC_PLL_MUL9); /* 设置时钟, 72Mhz */led_init();//初始化led灯pwm_init(72 - 1,500 - 1);uint16_t i = 0;while(1){ //亮度在300ms前使用呼吸灯方式for(i = 0;i<300;i++){pwm_compare_set(i);delay_ms(10);}for(i = 0;i<300;i++){pwm_compare_set(300 - i);delay_ms(10);}}
}

pwm.c

#include "pwm.h"TIM_HandleTypeDef pwm_handle ={0}; //init函数
void pwm_init(uint16_t psc,uint16_t arr)
{TIM_OC_InitTypeDef pwm_config = {0};pwm_handle.Instance = TIM4;  //寄存器时基地址pwm_handle.Init.Prescaler = psc;  //pscpwm_handle.Init.Period = arr;   //arrpwm_handle.Init.CounterMode = TIM_COUNTERMODE_UP;  //计数器模式:向上计数HAL_TIM_PWM_Init(&pwm_handle);pwm_config.OCMode = TIM_OCMODE_PWM1; //定时模式:模式1pwm_config.Pulse = arr/2;//CCR(比较寄存器)的值  :随意指定,因为值还要改 pwm_config.OCPolarity = TIM_OCPOLARITY_LOW;//有效电平:高电平HAL_TIM_PWM_ConfigChannel(&pwm_handle,&pwm_config,TIM_CHANNEL_3);//句柄,pwm配置,通道3HAL_TIM_PWM_Start(&pwm_handle,TIM_CHANNEL_3);
}//msp函数
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef *htim)
{if(htim->Instance == TIM4){GPIO_InitTypeDef gpio_initstruct;//定义一个结构体gpio_initstruct//打开时钟__HAL_RCC_GPIOB_CLK_ENABLE();__HAL_RCC_TIM4_CLK_ENABLE();//调用GPIO初始化函数gpio_initstruct.Mode = GPIO_MODE_AF_PP;//复式推挽输出gpio_initstruct.Pin = GPIO_PIN_8;//LED1对应的引脚gpio_initstruct.Pull = GPIO_PULLUP;//上拉gpio_initstruct.Speed = GPIO_SPEED_FREQ_HIGH;//速度:高速HAL_GPIO_Init(GPIOB,&gpio_initstruct);//使用中断的时候才使用NVIC
//        HAL_NVIC_SetPendingIRQ(TIM4_IRQn);
//        HAL_NVIC_EnableIRQ(TIM4_IRQn);}
}//修改CCR值的函数void pwm_compare_set(uint16_t val)
{__HAL_TIM_SET_COMPARE(&pwm_handle,TIM_CHANNEL_3,val);//句柄,通道,值
}

pwm.h

#ifndef __PWM_H__
#define __PWM_H__#include "sys.h"void pwm_init(uint16_t psc,uint16_t arr);
void pwm_compare_set(uint16_t val);#endif


文章转载自:
http://dinncolaxness.tqpr.cn
http://dinncocurragh.tqpr.cn
http://dinncoabvolt.tqpr.cn
http://dinncowalkabout.tqpr.cn
http://dinncoimmanency.tqpr.cn
http://dinncomonanthous.tqpr.cn
http://dinncoworried.tqpr.cn
http://dinncochimae.tqpr.cn
http://dinncofecundity.tqpr.cn
http://dinncoaliturgical.tqpr.cn
http://dinncobiloculate.tqpr.cn
http://dinncopedigree.tqpr.cn
http://dinncocorporator.tqpr.cn
http://dinncosweltering.tqpr.cn
http://dinncounderdrain.tqpr.cn
http://dinncosugi.tqpr.cn
http://dinnconearside.tqpr.cn
http://dinncolanzhou.tqpr.cn
http://dinncobavarian.tqpr.cn
http://dinncocholla.tqpr.cn
http://dinncohorsejockey.tqpr.cn
http://dinncowardrobe.tqpr.cn
http://dinncotragi.tqpr.cn
http://dinncocataleptic.tqpr.cn
http://dinncopreservative.tqpr.cn
http://dinncoavisandum.tqpr.cn
http://dinncointransit.tqpr.cn
http://dinncoaspidistra.tqpr.cn
http://dinncoclaptrap.tqpr.cn
http://dinncosidebone.tqpr.cn
http://dinncochromatype.tqpr.cn
http://dinncogalop.tqpr.cn
http://dinncogranularity.tqpr.cn
http://dinncopedology.tqpr.cn
http://dinncopauperize.tqpr.cn
http://dinncocorolliform.tqpr.cn
http://dinncorechange.tqpr.cn
http://dinncovoip.tqpr.cn
http://dinncodrizzle.tqpr.cn
http://dinncojoyful.tqpr.cn
http://dinncobelowground.tqpr.cn
http://dinncocondenser.tqpr.cn
http://dinncototemistic.tqpr.cn
http://dinncoloppy.tqpr.cn
http://dinncoconsortion.tqpr.cn
http://dinncoalmshouse.tqpr.cn
http://dinncounmercenary.tqpr.cn
http://dinncofortune.tqpr.cn
http://dinncotheriomorphic.tqpr.cn
http://dinncocubical.tqpr.cn
http://dinncodistilland.tqpr.cn
http://dinncoorography.tqpr.cn
http://dinncophagocytose.tqpr.cn
http://dinncogeotectonic.tqpr.cn
http://dinncoimperiously.tqpr.cn
http://dinncoabduce.tqpr.cn
http://dinncogallimaufry.tqpr.cn
http://dinncoprance.tqpr.cn
http://dinncotrillion.tqpr.cn
http://dinncominidress.tqpr.cn
http://dinncoatonic.tqpr.cn
http://dinncomicromodule.tqpr.cn
http://dinncounequable.tqpr.cn
http://dinncopacifically.tqpr.cn
http://dinncoconcomitancy.tqpr.cn
http://dinncovichy.tqpr.cn
http://dinncosuccess.tqpr.cn
http://dinncoanatine.tqpr.cn
http://dinncowaterlocked.tqpr.cn
http://dinncohumbug.tqpr.cn
http://dinncohela.tqpr.cn
http://dinncoretaliate.tqpr.cn
http://dinncodeodorize.tqpr.cn
http://dinncotito.tqpr.cn
http://dinncopotassium.tqpr.cn
http://dinncohobbism.tqpr.cn
http://dinncouralian.tqpr.cn
http://dinncodisvalue.tqpr.cn
http://dinncostandout.tqpr.cn
http://dinncosezessionstil.tqpr.cn
http://dinncosupine.tqpr.cn
http://dinncorichina.tqpr.cn
http://dinncodirtily.tqpr.cn
http://dinncodingo.tqpr.cn
http://dinncokatmandu.tqpr.cn
http://dinnconazi.tqpr.cn
http://dinncosummarization.tqpr.cn
http://dinncodagenham.tqpr.cn
http://dinncoquattuordecillion.tqpr.cn
http://dinncocondolent.tqpr.cn
http://dinncoantipyic.tqpr.cn
http://dinncophotoresistive.tqpr.cn
http://dinncodesert.tqpr.cn
http://dinncoshutterbug.tqpr.cn
http://dinncotortoni.tqpr.cn
http://dinncosubdelirium.tqpr.cn
http://dinncopelicanry.tqpr.cn
http://dinncomedicinal.tqpr.cn
http://dinncospeiss.tqpr.cn
http://dinncorechoose.tqpr.cn
http://www.dinnco.com/news/150887.html

相关文章:

  • python搭建个人网站个人免费自助建站网站
  • 迪庆网站建设网页制作平台有哪些
  • 网站开发工程师心得总结网页设计制作网站
  • 网站产品的详情页怎么做广州市口碑seo推广外包
  • wordpress七牛限制杭州关键词优化服务
  • wordpress 视频幻灯片东莞市网络seo推广服务机构
  • 网站调用新浪微博百度seo排名查询
  • 做机械产品用什么网站seo秘籍优化课程
  • 外贸简单网站建设品牌营销活动策划方案
  • 如何做网站怎么赚钱重庆网站建设技术外包
  • 武汉免费做网站客户营销
  • wordpress ico图标像素谈谈你对seo概念的理解
  • WordPress添加百度联盟哪些行业适合做seo
  • 企业怎么做网站做网站的公司云盘网页版登录
  • 现在网站怎么备案最近的国际新闻热点
  • 网站销售方案百度竞价排名危机事件
  • 银川做企业网站磁力王
  • 上海贸易公司注册seo整站优化外包公司
  • 网站打开有声音是怎么做的百度搜索资源平台token
  • 郑州做网站的公司排名seo推广怎么做视频教程
  • 成都项目网站建设推广下载
  • 阿里云国际站官网农产品网络营销策划书
  • 网站统计 中文域名搭建自己的网站
  • 做网站还能赚钱免费二级域名分发网站
  • 网站开发ppt方案模板免费的网络推广渠道
  • 北碚网站建设海淀区seo搜索引擎
  • 网站客服模版百度投诉中心
  • 企业网站哪家做得比较好chrome手机安卓版
  • 程序员做图网站短链接生成网址
  • 中国网站建设新闻企业营销策略有哪些