Is there any pre-requirments on using PC0 & PC1 as GPIO PP in STM8L051?
Hi all,
I am trying to use STM8L051 port c pin 0 as an output to drive a NPN. But I find that PC0 & PC1 cannot be set by using ST HAL library. All the registers seems ok (DDR, ODR, CR1 & CR2). And PC4,5,6 can be driven. Can anyone please give me a hand by providing some hints? AHere are the code:
#include "stm8l15x.h"
#include "main.h"
void delay_ms(uint16_t u16_ms)
{
for(uint16_t u16_a = 0; u16_a < u16_ms; u16_a++)
{
for(unsigned short u8_a = 0; u8_a < 37; u8_a++)
{
nop();
}
}
}
void main(void)
{
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_64);
/* Select HSI as system clock source */
CLK_SYSCLKSourceSwitchCmd(ENABLE);
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI); // CLK_SYSCLKSource_HSI
while (CLK_GetSYSCLKSource() != CLK_SYSCLKSource_HSI);
GPIO_Init(GPIOC,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6, GPIO_Mode_Out_PP_Low_Slow);
while(1)
{
GPIO_SetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6);
delay_ms(1000);
GPIO_ResetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6);
delay_ms(1000);
}
}