cancel
Showing results for 
Search instead for 
Did you mean: 

stm8s CCORDY on CCOR register never set

akhan.1
Associate II

hi friends

i asked my question just a few days ago but nobody answerd i dont know what should i do when i configure micro controller for cco output it generates out put of course its a little unaccurate when i check that is cco stable by checking CCORDY flag it remains in while loop for ever and flag CCOBSY is set forever and CCORDY never set ,itested it on two diffrent stm8s series result was same,i also check code with debugger ccor will remain 0x69 , i work with cosmic compiler and stvd environment. this is my code:

#include "STM8S.h"

#define LED_pin GPIO_PIN_0

#define LED_port GPIOD

void setup(void);

void clock_setup(void);

void GPIO_setup(void);

void main(void)

{

setup();

GPIO_WriteLow(LED_port, LED_pin);

while(TRUE){};

}

void setup(void)

{

clock_setup();

GPIO_setup();

}

void clock_setup(void)

{

CLK_DeInit();

CLK_HSECmd(DISABLE);

CLK_LSICmd(DISABLE);

CLK_HSICmd(ENABLE);

while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY) == FALSE);

CLK_ClockSwitchCmd(ENABLE);

CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV8);

CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV4);

CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI,

DISABLE, CLK_CURRENTCLOCKSTATE_ENABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_SPI, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_AWU, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_ADC, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER1, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER2, DISABLE);

CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER4, DISABLE);

CLK_CCOConfig(CLK_OUTPUT_CPU);

CLK_CCOCmd(ENABLE);

while(CLK_GetFlagStatus(CLK_FLAG_CCORDY) == FALSE);// it remains here

}

void GPIO_setup(void)

{

GPIO_DeInit(LED_port);

GPIO_Init(LED_port, LED_pin, GPIO_MODE_OUT_OD_HIZ_FAST);

}

0 REPLIES 0