2019-04-13 05:00 AM
I am using the latest System Workbench on Nucleo to set up for experiments.
My code is as follows:
#define SYS_CLOCK_FREQ_50_MHZ 50
int main(void)
{
HAL_Init();
SystemClock_Config_HSE(SYS_CLOCK_FREQ_50_MHZ);
GPIO_Init();
UART2_Init();
TIMER2_Init();
...
The SystemClock_Config_HSE(...) is as follows:
void SystemClock_Config_HSE(uint8_t clock_freq)
{
RCC_OscInitTypeDef Osc_Init;
RCC_ClkInitTypeDef Clock_Init;
uint8_t flash_latency=0;
Osc_Init.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_HSI ;
Osc_Init.HSEState = RCC_HSE_ON;
Osc_Init.LSEState = RCC_LSE_ON;
Osc_Init.HSIState = RCC_HSI_ON;
Osc_Init.PLL.PLLState = RCC_PLL_ON;
Osc_Init.PLL.PLLSource = RCC_PLLSOURCE_HSE;
switch(clock_freq)
{
case SYS_CLOCK_FREQ_50_MHZ:
Osc_Init.PLL.PLLM = 4;
Osc_Init.PLL.PLLN = 50;
Osc_Init.PLL.PLLP = RCC_PLLP_DIV2;
Osc_Init.PLL.PLLQ = 2;
Osc_Init.PLL.PLLR = 2;
Clock_Init.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
Clock_Init.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
Clock_Init.AHBCLKDivider = RCC_SYSCLK_DIV1;
Clock_Init.APB1CLKDivider = RCC_HCLK_DIV2;
Clock_Init.APB2CLKDivider = RCC_HCLK_DIV1;
flash_latency = 1;
break;
case SYS_CLOCK_FREQ_84_MHZ:
<< These cases are not relevant here>>
default:
return ;
}
if (HAL_RCC_OscConfig(&Osc_Init) != HAL_OK)
{
Error_handler();
}
if (HAL_RCC_ClockConfig(&Clock_Init, flash_latency) != HAL_OK)
{
Error_handler();
}
/*Configure the systick timer interrupt frequency (for every 1 ms) */
uint32_t hclk_freq = HAL_RCC_GetHCLKFreq();
HAL_SYSTICK_Config(hclk_freq/1000);
/**Configure the Systick
*/
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
Now when I build, load the program and try running it in the debugger I see that it is stuck in an infinite loop in HAL_RCC_ClockConfig(...). Why did it go into the WWDG_IRQHandler()?
This EXACT same code runs fine under Keil MDK.
The version of System Workbench I am using is:
Any ideas? I tried it with a previous version of System Workbench and I have the same issue.
Thank you
Subu
Solved! Go to Solution.
2019-04-13 05:26 AM
Found out the this project was using an older version of the firmware package.
CubeMX was initially used to generate a skeleton/template and code was modified to be as shown above.
Once the project was redone using the latest CubeMX firmware, it all worked as it should.
Sorry for the noise on this forum.
Thank you
Subu
2019-04-13 05:26 AM
Found out the this project was using an older version of the firmware package.
CubeMX was initially used to generate a skeleton/template and code was modified to be as shown above.
Once the project was redone using the latest CubeMX firmware, it all worked as it should.
Sorry for the noise on this forum.
Thank you
Subu