EasyManuals Logo

STMicroelectronics STM8 User Manual

STMicroelectronics STM8
126 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #89 background imageLoading...
Page #89 background image
Likewise, there are some additional info we must feed when configuring the OC channels. We need to
set info about complementary channels even if we don’t need them. We can additionally set the
default idle states of PWMs apart from polarities.
void TIM1_setup(void)
{
TIM1_DeInit();
TIM1_TimeBaseInit(16, TIM1_COUNTERMODE_UP, 1000, 1);
TIM1_OC1Init(TIM1_OCMODE_PWM1,
TIM1_OUTPUTSTATE_ENABLE,
TIM1_OUTPUTNSTATE_ENABLE,
1000,
TIM1_OCPOLARITY_LOW,
TIM1_OCNPOLARITY_LOW,
TIM1_OCIDLESTATE_RESET,
TIM1_OCNIDLESTATE_RESET);
TIM1_CtrlPWMOutputs(ENABLE);
TIM1_Cmd(ENABLE);
}
To change the duty cycle of a channel, we need to call this function:
TIM1_SetCompareX(duty_cycle); // where X represents channel ID (1, 2, 3 or 4)
Complementary outputs occur in pairs and so they are interdependent. That’s why there is no
separate function for outputs labelled N.

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the STMicroelectronics STM8 and is the answer not in the manual?

STMicroelectronics STM8 Specifications

General IconGeneral
BrandSTMicroelectronics
ModelSTM8
CategoryMicrocontrollers
LanguageEnglish

Related product manuals