2021-06-12 11:13 PM
void main()
{
uint32_t clockFrequency = 0x0000;
//clock enable for MCU
/* Select HSE as system clock source */
CLK_HSICmd(ENABLE);
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
/* system clock prescaler: 1*/
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
while (CLK_GetSYSCLKSource() != CLK_SYSCLKSource_HSI);
clockFrequency = CLK_GetClockFreq();
GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOE, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOF, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOG, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOH, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
GPIO_Init(GPIOI, GPIO_Pin_All, GPIO_Mode_Out_OD_Low_Fast);
while (1)
{
GPIO_Write(GPIOA, 0xff);
GPIO_Write(GPIOB, 0xff);
GPIO_Write(GPIOC, 0xff);
GPIO_Write(GPIOD, 0xff);
GPIO_Write(GPIOE, 0xff);
GPIO_Write(GPIOF, 0xff);
GPIO_Write(GPIOG, 0xff);
GPIO_Write(GPIOH, 0xff);
GPIO_Write(GPIOI, 0xff);
Delay(1000);Delay(1000);
GPIO_Write(GPIOA, 0x00);
GPIO_Write(GPIOB, 0x00);
GPIO_Write(GPIOC, 0x00);
GPIO_Write(GPIOD, 0x00);
GPIO_Write(GPIOE, 0x00);
GPIO_Write(GPIOF, 0x00);
GPIO_Write(GPIOG, 0x00);
GPIO_Write(GPIOH, 0x00);
GPIO_Write(GPIOI, 0x00);
Delay(1000);Delay(1000);
}
}Above is the code I am working on. One more interesting point, even clockFrequency set to zero it is always showing some random value after initialization and after clockFrequency = CLK_GetClockFreq() line.
Could anyone help me out? Where I am doing wrong?
Thanks!!!
2021-07-07 11:54 AM
Hello @vshah
you can refer to STM8L package available on st.com:
where you can find examples (GPIO Toggle) on STM8L Eval board.
Hope this would help you!
Regards,
Amira
2021-07-17 4:09 AM
Hi Amira,
Actually I had already gone through it and it was not working for me. The above code is written with help of "standard peripheral library" package only.
Regards,
Viren
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.