TIM1的PWM波配置两星期了,还是输不出来PWM波,具体错在哪里了请大家指正。不胜感激!!!!!!
目的:想让PE2/TIM1_CH3N输出PWM波。
#include"stm8l152.h"
void GPIO_CONFIG(void);
void TIM1_CONFIG(void);
main()
{
GPIO_CONFIG();
TIM1_CONFIG();
while(1);
}
void GPIO_CONFIG(void)
{
PE_DDR=0x04;
PE_CR1=0x04;
}
void TIM1_CONFIG(void)
{
TIM1_CCR3H=0x05;
TIM1_CCR3L=0x35;
TIM1_ARRH=0x0a;
TIM1_ARRL=0x6a;
TIM1_CNTRH=0x0a;
TIM1_CNTRL=0x6a;
TIM1_CCMR3=0x78;
TIM1_CCER2=0x04;
TIM1_CR1=0x96;
TIM1_CR2=0x81;
TIM1_BKR=0xc0;
TIM1_EGR|=0x01;
TIM1_CR1|=0x01;
}
此帖出自
小平头技术问答
一周热门 更多>