1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
设置Timer3 中断
void TIM3_INT_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; /* TIM3 clock enable */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); /* TIM3 ÖжÏǶÌ×Éè¼Æ*/ NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } 设置Timer3 模式 void TIM3_OUT_Config(void) { TIM_TimeBaseInitTypeDef TIM3_TimeBaseStructure; TIM_OCInitTypeDef TIM3_OCInitStructure; /* ¼ÆËãÔ¤·ÖƵֵ */ TM3_PrescalerValue = (uint16_t) (SystemCoreClock / TM3_PRESCALER) - 1; /* Time ¶¨Ê±Æ÷»ù´¡ÉèÖà */ TIM3_TimeBaseStructure.TIM_Period = 65535; TIM3_TimeBaseStructure.TIM_Prescaler = 0; TIM3_TimeBaseStructure.TIM_ClockDivision = 0; TIM3_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3, &TIM3_TimeBaseStructure); /* Ô¤·ÖƵÆ÷ÅäÖà */ TIM_PrescalerConfig(TIM3, TM3_PrescalerValue, TIM_PSCReloadMode_Immediate); /* Êä³ö±È½ÏʱÐòģʽÅäÖÃÉèÖà */ TIM3_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing; TIM3_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; /* Êä³ö±È½ÏʱÐòģʽÅäÖÃ: ƵµÀ3*/ TIM3_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM3_OCInitStructure.TIM_Pulse = TM3_CCR1_Val; //3000 TIM_OC3Init(TIM3, &TIM3_OCInitStructure); TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Disable); /* TIM ÖжÏʹÄÜ */ TIM_ITConfig(TIM3, TIM_IT_CC3 , ENABLE); /* TIM3 ʹÄÜ */ TIM_Cmd(TIM3, ENABLE); } 3. 中断子程序 void TIM3_IRQHandler(void) { if (TIM_GetITStatus(TIM3, TIM_IT_CC3) != RESET) { TIM_ClearITPendingBit(TIM3, TIM_IT_CC3); /* LED3 toggling with frequency = 219.7 Hz */ // LED1_Toggle(); // capture3 = TIM_GetCapture3(TIM3); // TIM_SetCompare3(TIM3, capture3 + TM3_CCR1_Val); OutToggle(); if(TimeRxFlag) { TimeInterval++; if(TimeInterval》4) { RxFrameEndFlag =1; } } if(KeyCtrl.bDebunceTime != 0) { KeyCtrl.bDebunceTime--; } // SevenSegShow(DispBuffer); capture3 = TIM_GetCapture3(TIM3); TIM_SetCompare3(TIM3, capture3 + TM3_CCR1_Val); } } |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1767 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1619 浏览 1 评论
1069 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
724 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1673 浏览 2 评论
1935浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
728浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
567浏览 3评论
592浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
551浏览 3评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 00:12 , Processed in 0.781731 second(s), Total 76, Slave 60 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号