I am using STM8S001J3 for PWM at TIMER 1 channel 4(PC4) PIN NO 7,but not getting pwm..pls.suggest.
void PWM(void)//timer1 channel4
{
TIM1_ARRH = 0x03; // Reload counter = 960
TIM1_ARRL = 0xc0;
TIM1_PSCRH|= 0; // Prescalar = 0 (i.e. 1)
TIM1_PSCRL |= 0;
//TIM1_CR1 = 0; // Up counter.
TIM1_CR1|= 0; // Edge aligned counter.
TIM1_RCR |= 0; // No repetition.
//
// Now configure Timer 1, channel 4.
//
TIM1_CCMR4|= 0X80; // Set up to use PWM mode 2.
TIM1_CCER2|= 0X10; // Output is enabled.
TIM1_CCER2|= 0X20; // Active is defined as high.
TIM1_CCR4H|= 0x01; // 480 = 50% duty cycle (based on TIM1_ARR).
TIM1_CCR4L|= 0xe0;
TIM1_BKR|= 0X80;//1; // Enable the main output.
//
// Uncomment the following line to produce a single pulse.
TIM1_CR1|=0x01;// Enable counter
}
