2019-10-04 01:20 AM
Hi,
I am trying to develop a simple example program to control the 3 User LED's in the nucleo-144 board.
Part number - STM32L4R5ZI
I have configured the following clock settings and BSP for the LED's.
Clock Settings:
/* Enable MSI oscillator and configure the PLL to reach the max system frequency (120 MHz)
when using MSI oscillator as PLL clock source. */
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_LSI| RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; /* 4MHz */
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 60;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) == HAL_OK)
{
/* Enable MSI in PLL mode */
HAL_RCCEx_EnableMSIPLLMode();
}
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
/* To avoid undershoot due to maximum frequency, select PLL as system clock source */
/* with AHB prescaler divider 2 as first step */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
{
return FAILURE:
}
I hope the clock settings are fine.
Out of the 3 user LED's Red(PortB ; GPIO_PIN_14)and Green(PORT C ; GPIO_PIN_7) are working as expected, but BLUE LED(PortB ; GPIO_PIN_7) is not working.
Any clue would be of great help.
Thanks & Regards,
Shanmathi
2019-10-04 04:47 AM
It works fine with the example code provided in stm32cube :|