2015-05-08 06:44 AM
Hello every one. I have a workable code of pwm on STM8S105K4T6 and now I paste it in STM8S003k3 fnd it won't work.
&sharpdefine CCR1_Val ((u16)2047) // Configure channel 1 Pulse Width Blue&sharpdefine CCR2_Val ((u16)2047) // Configure channel 2 Pulse Widthstatic void TIM1_Config(void){ TIM1_DeInit(); /* Time Base configuration */ /* TIM1_Period = 4095 TIM1_Prescaler = 0 TIM1_CounterMode = TIM1_COUNTERMODE_UP TIM1_RepetitionCounter = 0 */ TIM1_TimeBaseInit(0, TIM1_COUNTERMODE_UP, 4095, 0); /* Channel 1, 2,3 and 4 Configuration in PWM mode */ /* TIM1_OCMode = TIM1_OCMODE_PWM2 TIM1_OutputState = TIM1_OUTPUTSTATE_ENABLE TIM1_OutputNState = TIM1_OUTPUTNSTATE_ENABLE TIM1_Pulse = CCR1_Val TIM1_OCPolarity = TIM1_OCPOLARITY_LOW TIM1_OCNPolarity = TIM1_OCNPOLARITY_HIGH TIM1_OCIdleState = TIM1_OCIDLESTATE_SET TIM1_OCNIdleState = TIM1_OCIDLESTATE_RESET */ /*TIM1_Pulse = CCR2_Val*/ TIM1_OC2Init(TIM1_OCMODE_PWM2, TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_ENABLE, CCR2_Val, TIM1_OCPOLARITY_LOW, TIM1_OCNPOLARITY_HIGH, TIM1_OCIDLESTATE_SET, TIM1_OCNIDLESTATE_RESET); /*TIM1_Pulse = CCR4_Val*/ TIM1_OC4Init(TIM1_OCMODE_PWM2, TIM1_OUTPUTSTATE_ENABLE, CCR1_Val, TIM1_OCPOLARITY_LOW, TIM1_OCIDLESTATE_SET); /* TIM1 counter enable */ TIM1_Cmd(ENABLE); /* TIM1 Main Output Enable */ TIM1_CtrlPWMOutputs(ENABLE);}Can any one tell me what is wrong here. #stm8s003k3-tim1-pwm-problem2015-05-08 11:26 AM