Question
SysTick - STM32F429ZI
Posted on June 08, 2014 at 20:46
Hi, i'm trying to make a led toggle every second with SysTick but it's not working. The toggle occurs every 3 secs more or less. I also tried to do it with timers but i can't get the frequency right. However in the SysTick example provided in ''STM32Cube_FW_F4_V1.1.0'' the Led's toggle when they have to. I'm clearly having problems when i tried to develope all the code by myself but i can't see the source of error. I think the problem is the clock source configuration but all seem fine to me. I hope someone can help me.
Heres the code:#include ''stm32f4xx.h''
#include ''stm32f4xx_conf.h''
RCC_ClocksTypeDef RCC_ClockFreq;
static
void
LED(
void
);
static
void
Delay(uint16_t);
uint16_t delay=0;
uint16_t count=0;
uint8_t source=0;
void
SysTick_Handler(
void
)
{
count++;
}
int
main(
void
){
LED();
source=RCC_GetSYSCLKSource ();
RCC_GetClocksFreq(&RCC_ClockFreq);
SysTick_Config(SystemCoreClock/1000);
SysTick_CLKSourceConfig (SysTick_CLKSource_HCLK);
GPIO_ToggleBits(GPIOG,GPIO_Pin_14);
while
(1){
GPIO_ToggleBits(GPIOG,GPIO_Pin_13);
Delay(1000);
}
}
/******************************************************************************/
void
LED(
void
){
GPIO_InitTypeDef GPIO_InitStructure;
// LED Port Info
// Enable the port clock
RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOG, ENABLE);
// Prepare the port info
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14;
// Line 12
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
// As Output
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
// Push-pull
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
// At 100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
// Without pull-up-down
// Initialize the port
GPIO_Init (GPIOG, &GPIO_InitStructure);
}
/******************************************************************************/
void
Delay(uint16_t delay){
count=0;
while
(count<delay){}
}
SYSCLK = 180MHz = HCLK.
I'm using Keil uVision 5.
Thanks
#frequency #stm32f429i #solved #systick #!psychic