-
NUC131 PWM0 CH2 CH3双通道输出,为啥只有CH2输出呢?
[i=s] 本帖最后由 sky_42959069 于 2021-11-17 11:12 编辑 [/i] [img]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAzkAAAA+CAYAAAAI/9U8AAAWl0lEQVR4Ae2dy3GsOhBAJy4CIo2XAhtH4f3sbxLeEMINQq9aUkPri8Ye7GvmuMoFCH1ap1tIjSTm5viDAAQgAAEIQAACEIAABCBwIQK3C9WFqkAAAhCAAAQgAAEIQAACEHA4ORgBBCAAAQhAAAIQgAAEIHApAjg5l1InlYEABCAAAQhAAAIQgAAEcHKwAQhAAAIQgAAEIAABCEDgUgRwci6lTioDAQhAAAIQgAAEIAABCODkYAMQgAAEIAABCEAAAhCAwKUI4ORcSp1UBgIQgAAEIAABCEAAAhDAycEGIAABCEAAAhCAAAQgAIFLEcDJuZQ6qQwEIAABCEAAAhCAAAQggJODDUAAAhCAAAQgAAEIQAAClyKAk3MpdVIZCEAAAhCAAAQgAAEIQAAnBxuAAAQgAAEIQAACEIAABC5FACfnUuqkMhCAAAQgAAEIQAACEIAATg42AAEIQAACEIAABCAAAQhcigBOzqXUSWUgAAEIQAACEIAABCAAAZwcbAACEIAABCAAAQhAAAIQuBQBnJxLqZPKQAACEIAABCAAAQhAAAInOzmrW+bJ3W43/z/Ns5umxVNfFw2f3LIGRSxTiHeb71Ez7fTPUV3If4rlTvPi5S3kifLfbpOb9aa7u3kLv7lbrNeYXKsLdd3r7tPd58Aq5rXxsOXIeeRT3rfyjUnyzFjLlNXHtfX3Pfp/bf327ePYftf17u6LtNmbmza7r1lMzGtrt7U4NmzM/m2K2vl9ludFbnNlTLG1uvzYZ6LWb37+nG6f6+Km5Nk5O+1ZSiuxId9knyLftLjY/VkBOIcABCAAgScQONXJkcHF7hQ4t97DQ32T+z6ngw+5NgOlw/RbRrWTu5NB97y0u7X7PLn5brqYdXVzMlCXwZvtGMOgKBkYxI5K8krCayLZsNgB2/pKHtNky3Nuya6dpNsYD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xHAybmUOqkMBCAAAQhAAAIQgAAEIICTgw1AAAIQgAAEIAABCEAAApcigJNzKXVSGQhAAAIQgAAEIAABCEAAJwcbgAAEIAABCEAAAhCAAAQuRQAn51LqpDIQgAAEIAABCEAAAhCAAE4ONgABCEAAAhCAAAQgAAEIXIoATs6l1EllIAABCEAAAhCAAAQgAAGcHGwAAhCAAAQgAAEIQAACELgUAZycS6mTykAAAhCAAAQgAAEIQAACODnYAAQgAAEIQAACEIAABCBwKQI4OZdSJ5WBAAQgAAEIQAACEIAABP4HBi+snPYiyEUAAAAASUVORK5CYII=[/img]SYS->GPA_MFP&=~(SYS_GPA_MFP_PA14_Msk|SYS_GPA_MFP_PA15_Msk); SYS->GPA_MFP|=(SYS_GPA_MFP_PA14_PWM0_CH2|SYS_GPA_MFP_PA15_PWM0_CH3);//PA14 PA15 用于PW0-CH2 CH3 //引脚设置 void PWM_Init(void) { PWM_ConfigOutputChannel(PWM0,2,20000,0); PWM_ConfigOutputChannel(PWM0,3,20000,0); PWM_EnableOutput(PWM0,PWM_CH_2_MASK); PWM_EnableOutput(PWM0,PWM_CH_3_MASK); PWM_EnablePeriodInt(PWM0,2,0); PWM_EnablePeriodInt(PWM0,3,0); NVIC_EnableIRQ(PWM0_IRQn); } //初始化 请大神们帮忙看下,初次玩新唐请多关照!
1989浏览量 2回复量 关注量 -
用SYSTICK延时实现stm32f103ZET6的呼吸灯效果
[color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px]今天学习了pwm的原理后,尝试用SYSTICK模拟pwm的占空比变化来实现LED的呼吸效果,但没有成功.是因为不使用GPIO的pwm模式就无法输出模拟电压吗?[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px]代码如下:[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px]int main(void)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px]{[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] u32 i;[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] LED_Init();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] delay_init();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] while(1)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] for(i=0xFFFFF; i>0 ;i--)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] LED_Output_Low();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] delay_ms(1);[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] LED_Output_High();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] delay_ms(9);[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] for(i=0xFFFFF; i>0;i--)[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] {[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] LED_Output_Low();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] delay_ms(9);[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] LED_Output_High();[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] delay_ms(1);[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] }[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px] [/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px]}[/size][/font][/backcolor][/color] [color=#444444][backcolor=rgb(255, 255, 255)][font=Tahoma, "][size=15px]在两个时间段内赋予不同的占空比,跟pwm的原理应该是一样的,但不知道为什么不能实现呼吸灯效果[/size][/font][/backcolor][/color]
12047浏览量 32回复量 关注量 -
用SYSTICK延时stm32f103ZET6的呼吸灯效果 sos
今天学习了pwm的原理后,尝试用SYSTICK模拟pwm的占空比变化来实现LED的呼吸效果,但没有成功.是因为不使用GPIO的pwm模式就无法输出模拟电压吗? 代码如下: int main(void) { u32 i; LED_Init(); delay_init(); while(1) { for(i=0xFFFFF; i>0 ;i--) { LED_Output_Low(); delay_ms(1); LED_Output_High(); delay_ms(9); } for(i=0xFFFFF; i>0;i--) { LED_Output_Low(); delay_ms(9); LED_Output_High(); delay_ms(1); } } } 在两个时间段内赋予不同的占空比,跟pwm的原理应该是一样的,但不知道为什么不能实现呼吸灯效果
3499浏览量 0回复量 关注量