2012-04-14 02:40 AM
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
2012-04-14 03:25 AM
Problem solved - seems to have been a deployment problem. Full reboot seems to have fixed it.
Regards,Mark