2010-08-30 05:38 AM
Hello! I have STM8S-Discovery, STVD+Cosmic_32K. I write:
#include ''stm8s.h'' main() { GPIO_DeInit(GPIOD); GPIO_Init(GPIOD, GPIO_PIN_0, GPIO_MODE_OUT_PP_LOW_FAST); TIM3_DeInit(); TIM3_TimeBaseInit(TIM3_PRESCALER_2, 999); TIM3_Cmd(ENABLE); for(;;) { if (TIM3_GetCounter() < 500) { GPIO_WriteLow(GPIOD, GPIO_PIN_0); } else { GPIO_WriteHigh(GPIOD, GPIO_PIN_0); } } } All is normal, the light-emitting diode is shone, since the period of repetition 1 �?ºHz, but the problem what when I look an oscillograph on PD0 at that time when there should be a low level in its middle periodically appears a positive impulse??? Why?? Thanks!2010-08-31 03:40 AM
Hi petrd,
Why you don't use TIM3 in output compare mode, you can configure the duty cycle and you will get your timer controlling the led while the CPU is free. NB: I have run your code on another device (i don't have discovery kit) but I couldn't reproduce the behavior you described. good luck and regards, MCU Lüfter