i want to do some rc5 transmitter project.
i already have a circuit with a stm8s003 to send data and a ne555 to make 38khz frequency. with connect them together and send the specific data my rc5 transmitter works fine and its no word about it.
but i want to remove the ne555 and do both work with only use stm8s003.
i only need a code to make TIMER_1 send 38khz frequency.
here a example code but i have no idea about it.
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);
}
void main(void)
{
int j;
signed int i = 0;
clock_setup();
GPIO_setup();
TIM1_setup();
while(TRUE)
{
for(i = 0; i < 1000; i += 1)
{
TIM1_SetCompare1(i);
for(j=1;j<0x5FFF;j++);
}
for(i = 1000; i > 0; i -= 1)
{
TIM1_SetCompare1(i);
for(j=1;j<0x5FFF;j++);
}
};
}
it seems to this code make a led change brightness smoothly