2011-10-06 06:24 AM
Hi all,
I'm use the STM8S103K MCU with COSMIC + STVD + STLINK debugger. I setup TIMER1 to generate a bitsequence (each 14ms) on an output pin during timer overflow. Everything is fine as long as the debugger is connected to the device (load the code to the MCU). Now I disconnect the debugger and switch off the power of the MCU. After power on the MCU now, the bitsequence which is generated is very slow( now 448ms). The timing difference ist exact factor of 32. There are any ideas, what kind of things I do wrong? I use the HSI with prescaler 1, CPU prescaler is also 1. I never had such a problem with other projects. How can I debug this? Thanks for any help! SMPS_Gerd #timer-hsi-debugger-stm8s-cosmic2011-10-06 10:05 AM
I suggest you to do a little debugging/investigation:
put system clock or peripheral clock out on a pin (MCO) and observe it in both case (debugger plugged and debugger unplugged).brazov2011-10-06 12:40 PM
Yes, I will try this tomorrow morning.
Thanks for the hint. SMPS_Gerd2011-10-07 04:06 AM
Hi,
I tried the following setup to get the internal clock to the CLK_COO pin: GPIO_Init_TypeDef GPIO_InitStructure; // Clock out on CCO pin PD.0 for STM8S103K GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUT_PP_HIGH_FAST; GPIO_InitStructure.GPIO_Pin = GPIO_PIN_0; GPIO_Init(GPIOD, &GPIO_InitStructure); //CLK_CCOConfig(CLK_OUTPUT_HSI); // HSI out CLK_CCOConfig(CLK_OUTPUT_CPUDIV16); // CPU/16 out CLK_CCOCmd(ENABLE); Anyhow, I don't get a clock on the output pin. Why does this not work? I also set the option bytes, so the CLK_COO pin is enabled (I also verified, that the option byte is realy set). SMPS_Gerd2011-10-11 12:28 AM
Hi all,
I had some time to test the clock out functionality. The setup I posted above is working. My oszi had some problems to display the high frequency if I do not zoom in. Result: All different clocks are working as expected, there is no change w/ or w/o debugger after power on. So I still have the problem, that the timer1 (which I used to genereate the bit sequence) run a factor of 32 slower w/o debugger than with debugger. Has nobody any idea, what causes the different timing of timer1 if I do not use the debugger? Any ideas are welcome! Thank you very much! SMPS_Gerd