2017-06-09 03:31 AM
hello
I'm using a STM32F405RG LQFP64 with an oscillator of 8mhz I configured all clock up to max speed using HSE as PLLSRC and PLLCLK as SYSCLK src all looks good on cubemx config and generated code looks good too
/**Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4;
RCC_OscInitStruct.PLL.PLLN = 168;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 7;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
but when i dig in HAL_RCC_OscConfig() it looks that 'HSI config' section is exiting on error
/*----------------------------- HSI Configuration --------------------------*/
if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI)
{
/* Check the parameters */
assert_param(IS_RCC_HSI(RCC_OscInitStruct->HSIState));
assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct->HSICalibrationValue));
/* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */
if((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_HSI) ||\
((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_PLL) && ((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLCFGR_PLLSRC_HSI)))
{
/* When HSI is used as system clock it will not disabled */
if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON))
{
return HAL_ERROR;
}
/* Otherwise, just the calibration is allowed */
else
{
/* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/
__HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->HSICalibrationValue);
}
}
else { /* Check the HSI State */ if((RCC_OscInitStruct->HSIState)!= RCC_HSI_OFF) { /* Enable the Internal High Speed oscillator (HSI). */ __HAL_RCC_HSI_ENABLE();it falls into error because it checks RCC_FLAG_HSIRDY before configuring HSI and as HSI is default clock src at reset it's always ready
I want to disable HSI so logicaly RCC_OscInitStruct->HSIState is set to RCC_HSI_OFF (by defaut)
and as the set of HSI config comes after it's never disable
to make it work I can just remove RCC_OSCILLATORTYPE_HSI in RCC_OscInitStruct.OscillatorType it will keep HSI ON but it select correctly HSE, PLL SRC, and SYSCLK source
I dont want to say it's a mistake in HAL and I'm pretty sure I made something wrong but I already use Cube MX on other stm32F mcu (cortex M3 and M4 and others) and It's the first time I have this type of issue
if some one can see what I did wrong I would be nice
thank's for any idea
ps : I put my cubemx '.ioc' file in attachement if it helps
2017-06-09 03:44 AM
Hi
olivier.gaste
,You are using an old CubeMx version with limitation
in the clock configuration and t
his has been corrected.I advise you to upgrade to the last version CubeMx 4.0
Thanks
Imen
2017-06-09 06:53 AM
YEAAAAA !!!
tank's a lot Imen D !! once again you saved my life !!
I updated the cubeMx and It looks to work at least for RCC
I needed to rebuild totaly the IOC config because automatic import of old versioned IOC file looks to dead lock project files generation
but it's not a big issue
thank's again
2017-06-09 07:55 AM
Hi
olivier.gaste
,You are welcome
To usean old .ioc project, you should first EDIT the .ioc file and REMOVE theRCC.OscillatorType that you don't need:
E.g: Remove this line
RCC.OscillatorTypeHSI=RCC_OSCILLATORTYPE_HSI
Then re-generate the project and this will resolve your problem.
Regards
Imen