Skip to main content
Visitor II
October 4, 2019
Question

Unable to enable/disable/toggle BLUE LED in STM32L4R5ZI board.

  • October 4, 2019
  • 3 replies
  • 2485 views

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

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    October 4, 2019

    Please check MB1312 schematic and STM32L4R5 datasheet, and if necessary the BOM for Nucleo 144 STM32L4R5 , to check on what pin the blue LED is.

    SP.3Author
    Visitor II
    October 4, 2019

    Hi Mike,

    I have checked with the schematic.

    It is PB7 for Blue LED. Also mentioned in Board_Drawing_en.DM00368330.pdf

    0690X000009k29SQAQ.png

    SB171 is open and SB172 is closed in the development kit.

    0690X000009k298QAA.png

    Technical Moderator
    October 4, 2019

    Maybe If you have SMPS version of the board, aka NUCLEO-L4R5ZI-P.

    It may be connected to PB6 instead.

    SP.3Author
    Visitor II
    October 4, 2019

    Checked with the board. It is NUCLEO-L4R5ZI not NUCLEO-L4R5ZI-P.

    But I tried now PB6 instead of PB7, still blue LED is not blinking.

    Graduate II
    October 4, 2019

    Show the code configuring and blinking the LED, it will be a lot more enlightening than the clock code.​

    Technical Moderator
    October 4, 2019

    #define PINB_LED_B GPIO_PIN_6