cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX v4.24.0 - STM32F1 GPIO LL - LED blinking fails

Posted on January 22, 2018 at 23:26

Hi,

Excited by the LL support added to the F1 line I generated simple project for STM32F103C8 board where the PC13 is connected to a LED: HSE enabled, PC13 Push-Pull output.

Generated GPIO initialization code seems to be fine:

static void MX_GPIO_Init(void)

{

  LL_GPIO_InitTypeDef GPIO_InitStruct;

  /* GPIO Ports Clock Enable */

  LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOC);

  LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOD);

  LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);

  /**/

  LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin);

  /**/

  GPIO_InitStruct.Pin = LED_Pin;

  GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;

  GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;

  GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;

  LL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);

}

Added the blinking part:

/* USER CODE BEGIN WHILE */

  while (1)

  {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

        

        LL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);

    LL_mDelay(1000);

  }

  /* USER CODE END 3 */

But unfortunately the LED is not blinking.

---------------------------------------------------------

Entered Keil debuger, GPIOC and noticed that MODE13=0, so entered manually value 1 (MODE13=1) and the LED started blinking.

It seems that the LL GPIO driver is somewhat broken because the MODE is wrongly set.

The whole project is attached.

14 REPLIES 14
Imen.D
ST Employee
Posted on February 06, 2018 at 10:28

Hello

Golab.Bogdan

,

simon.010

,

We will take in charge to check and raise this issue internally to the appropriate team.

Thank you for highlighting this issue.

Best Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee
Posted on February 19, 2018 at 12:04

Hello,

This issue is confirmed for LL Gpio pins greater than 8 initialization with LL-Init() function and this will be fixed in the next release.

We propose thisfix for ll_gpio driver with LL_GPIO_Init function:

ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
{
 uint32_t pinmask = 0x00000000U;
 uint32_t pinpos = 0x00000000U;
 uint32_t currentpin = 0x00000000U;
 
 /* Check the parameters */
 assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
 assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
 assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
 assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
 
 /* ------------------------- Configure the port pins ---------------- */
 /* Initialize pinpos on first pin set */
 
 pinmask = (GPIO_InitStruct->Pin & 0x00FFFF00U) >> 8 ;
 pinpos = POSITION_VAL(pinmask);
/* Configure the port pins */
 while ((pinmask >> pinpos) != 0U)
 {
 /* skip if bit is not set */
 if ((pinmask & (1U << pinpos)) == 0U)
 {
 pinpos++;
 }
/* Get current io position */
 if(pinpos <8 )
 {
 currentpin = (0x00000101U << pinpos);
 }
 else
 {
 currentpin = ((0x00010001U << (pinpos-8)) | 0x04000000U);
 }
 
 if (currentpin)
 {
 /* Pin Mode configuration */
 LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
 
 /* Pull-up Pull down resistor configuration*/
 LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
 
 if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
 {
 /* Check Output mode parameters */
 assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
/* Output mode configuration*/
 LL_GPIO_SetPinOutputType(GPIOx, currentpin, GPIO_InitStruct->OutputType);
/* Speed mode configuration */
 LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
 }
}
 pinpos++;
 }
 return (SUCCESS);
}

Hope this is helpful for you.

Kind Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on March 16, 2018 at 19:20

Just tested a STM32VLDIscovery board and the issue still exists in CubeMX 4.25.0 with the v1.6.0 HAL/LL drivers.

Posted on March 19, 2018 at 17:07

Just tested STM32CubeF1 Firmware patch Package V1.6.1 - GPIO works fine.

Imen.D
ST Employee
Posted on March 22, 2018 at 09:52

Hello,

We would inform you that the new patch of STM32CubeF1 Firmware package V1.6.1 is released to fix this issue.

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen