cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S Discovery and CCO

Nevyn
Associate II
Posted on April 14, 2012 at 11:40

I am new at this so please be gentle with me 🙂 I am struggling to get the CCO pin to output the current clock frequency and I'm struggling. I have checked out the examples in the STM8S library (version 2.1), in particular the CLK_MaxSpeed example and I seem to be getting no where.

For the hardware I am just using the Discovery board and I have hooked a scope to CN4, pin 4 which I believe is the CCO pin. For the software I have distilled the following from various examples:

#include ''stm8s.h''
#include ''stm8s_gpio.h''
#include ''stm8s_clk.h''
int
main( 
void
)
{
//
// Initialise the clock
//
CLK_DeInit();
CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1); 
// CPU Prescaler = 1.
CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1); 
// Prescaler = 1.
CLK_CCOConfig(CLK_OUTPUT_CPU); 
// Output clock on CCO pin.
CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);
//
// Initialise GPIOs
//
GPIO_DeInit(GPIOC);
GPIO_Init(GPIOC, GPIO_PIN_2, GPIO_MODE_OUT_PP_LOW_FAST);
GPIO_WriteHigh(GPIOC, GPIO_PIN_2);
//
// Config done.
//
while
(1)
{
GPIO_WriteReverse(GPIOC, GPIO_PIN_2);
}
}

The while loop is just me trying to get some other form of output to prove the program is actually running. I am not seeing any meaningful output on the scope for either CCO or the GPIO. FYI - I am using the IAR environment. Any help would be appreciated, Mark #stm8s-discovery-clock-cco
1 REPLY 1
Nevyn
Associate II
Posted on April 14, 2012 at 12:25

Problem solved - seems to have been a deployment problem.  Full reboot seems to have fixed it.

Regards,

Mark