2018-01-22 02:26 PM
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.
Solved! Go to Solution.
2018-02-19 03:04 AM
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.
2018-01-23 10:27 PM
DAHMEN.IMEN
How to reproduce:
If you want to make PC13 and PC15 outputs:
GPIO_InitStruct.Pin = LED_Pin|LL_GPIO_PIN_15;
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(GPIOC, &GPIO_InitStruct);You can see that CRL is configured by the LL:
instead of CRH:
so when you try to fix it you use:
GPIOC->CRH = 0x24244444;
Can you consider it a bug?
2018-02-01 02:08 AM
I wonder if this issue was confirmed by the ST?
2018-02-01 06:53 AM
Hello
Golab.Bogdan
,There is an
interesting note
described in the datasheet, please check this:'
PC13, PC14 and PC15 are supplied through the power switch. Since the switch only sinks a limited amount of current (3 mA), the use of GPIOs PC13 to PC15 in output mode is limited: the speed should not exceed 2 MHz with a maximum load of 30 pF and these IOs must not be used as a current source (e.g. to drive an LED).
'
Best Regards
Imen
2018-02-01 07:14 AM
This issue is not about LED blinking - it's about wrong pin setup...
2018-02-01 07:25 AM
Checked the schematic:
I=(3.3V-1.6V)/510ohm ~ 3.3mA so I am sure it won't break the MCU.
Anyway, I was complaining about wrong port setup (I guess for pins 8-15) of the port GPIOC. But i believe it also applies to other GPIOX.
Instead of setting up pins 8-15, the pins 0-7 are configured.
2018-02-01 06:57 PM
https://community.st.com/0D50X00009XkhPcSAJ
.I'm afraid it hit me too, withF4 variant. What a nuisance.
-- pa
2018-02-01 11:22 PM
HAL works fine - output is alive
LL is affected and requires a fix - in this case (PC13): GPIOC->CRH = 0x24244444;
That's why I think it's a bug AND lack of consistency (HAL vs LL).
If they do not to configure a pin as an output they shall not add the following lines in the generated code:
&sharpdefine LED_Pin LL_GPIO_PIN_13
LL_GPIO_ResetOutputPin(LED_GPIO_Port, LED_Pin);
But the did, what is against the intention of prohibiting the PC13 as an output AND it is not consistent with HAL where all works fine.
2018-02-01 11:33 PM
Yes, the link yo are pointing is exactly the same as I observed. Nice catch - I have not found it myself.
2018-02-02 07:02 AM
See