AnsweredAssumed Answered

Using COSMIC C - trying to understand Clock setting

Question asked by MHz on Aug 29, 2014
Hello there, I am playing with my STM8s Discovery board but unable to set the clock properly. Can someone please put some light on what I am doing wrong. My code is as follows:

---------------------------------------------
#include "stm8s.h"
u16 c=9000;


main()
{
               void CLK_Deinit();
               void CLK_HSICmd(ENABLE);
               void CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV8);
               void CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV128);
               CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO,CLK_SOURCE_HSI,ENABLE,CLK_CURRENTCLOCKSTATE_DISABLE);
               GPIO_DeInit (GPIOD);
               GPIO_Init (GPIOD,GPIO_PIN_0,GPIO_MODE_OUT_PP_LOW_FAST);
//               TIM2_DeInit();
//               TIM2_TimeBaseInit(TIM2_PRESCALER_2048, 300);
//               TIM2_Cmd(ENABLE);
               while (1){
/*                         if (TIM2_GetCounter()>150){
                              GPIO_WriteHigh(GPIOD,GPIO_PIN_0);
                         }     
                         else {
                              GPIO_WriteLow(GPIOD,GPIO_PIN_0);
                         }*/
                    while (c>1){
                         c--;
                    }
                    GPIO_WriteReverse(GPIOD,GPIO_PIN_0);
                    c=9000;
               }
}
-----------------------------------

My LED blinks at the same rate even when I change the HSI prescaler and/or sys clock config. Thanks

Outcomes