2210 views|8 replies

501

Posts

4

Resources
The OP
 

[ST NUCLEO-U575ZI-Q Review] GPIO-lighting using HAL/LL library [Copy link]

Preface

We have built a development environment before. This article starts with the simplest GPIO lighting to experience the operation of HAL and LL libraries.

process

GPIO

Reference Manual, "13 General-purpose I/Os (GPIO)"

Pinout

From the schematic diagram, we can see that pins PG2 and PB7 correspond to LED3 and LED2, and the output high lights up the LED.

HAL/LL library

stm32u5xx_hal_gpio.c/h

stm32u5xx_ll_gpio.c/h

Macros need to be defined in projects using the HAL library

USE_HAL_DRIVER

Macros need to be defined in projects using the LL library

USE_FULL_LL_DRIVER

stm32u5xx_hal_conf.h

#define HAL_GPIO_MODULE_ENABLED The macro definition will include

Corresponding header file

#ifdef HAL_GPIO_MODULE_ENABLED

#include "stm32u5xx_hal_gpio.h"

#endif /* HAL_GPIO_MODULE_ENABLED */

The code of stm32u5xx_hal_gpio.c will compile

The HAL library only needs to include the total header file #include "stm32u575xx.h";

The LL library needs to include the corresponding module header file #include "stm32u5xx_ll_gpio.h".

GPIO Operation

The LL library is used here.

First, enable the corresponding clock and include the header file #include "stm32u5xx_ll_bus.h"

LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);

We can see the operation interface such as LL library from the corresponding header file

ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);

ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);

void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);

The total code is as follows

#include "stm32u575xx.h"

#include "stm32u5xx_ll_gpio.h"

#include "stm32u5xx_ll_bus.h"

void delay(uint32_t t)

{

volatile uint32_t timeout = t;

while(t--);

}

int main(void)

{

LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);

LL_GPIO_InitTypeDef GPIO_InitStruct;

//LL_GPIO_StructInit(&GPIO_InitStruct);

GPIO_InitStruct.Pin = LL_GPIO_PIN_7;

GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;

GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;

GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;

GPIO_InitStruct.Alternate = LL_GPIO_AF_0;

LL_GPIO_Init(GPIOB, &GPIO_InitStruct);

while(1)

{

delay(1000000ul);

LL_GPIO_TogglePin(GPIOB, 1u<<7);

}

}

After downloading the simulation, Yunxin can see the blue LED start to flash and can check the corresponding register of GPIO

Summarize

Thanks to the perfect library, operating peripherals is very simple and efficient, which STM does very well. It should be noted that the corresponding peripheral clock must be enabled before using the peripheral.

This post is from stm32/stm8

Latest reply

Review summary: Free application | ST NUCLEO-U575ZI-Q https://en.eeworld.com/bbs/thread-1228653-1-1.html   Details Published on 2023-1-12 09:41
 

6818

Posts

11

Resources
2
 
Why can't I turn on the PG2 light? Do I need any special configuration?
This post is from stm32/stm8

Comments

He only ordered pb7 here  Details Published on 2022-12-15 13:44
He only ordered pb7 here  Details Published on 2022-12-15 10:04
 
 

6062

Posts

4

Resources
3
 
lugl4313820 posted on 2022-12-14 22:28 Why can't I turn on the PG2 light? Do I need special configuration?

He only ordered pb7 here

This post is from stm32/stm8

Comments

Yeah.  Details Published on 2022-12-15 13:45
Yeah.  Details Published on 2022-12-15 12:43
 
 

6818

Posts

11

Resources
4
 
damiaa posted on 2022-12-15 10:04 He only clicked pb7 here

Yeah.

This post is from stm32/stm8
 
 
 

501

Posts

4

Resources
5
 
lugl4313820 posted on 2022-12-14 22:28 Why can't I turn on the PG2 light? Do I need special configuration?

[ST NUCLEO-U575ZI-Q Review] PGIOG port lighting problem - stm32/stm8 - Electronic Engineering World - Forum (eeworld.com.cn)

VDDIO2 needs to be configured

This post is from stm32/stm8
 
 
 

501

Posts

4

Resources
6
 
 

224

Posts

0

Resources
7
 

Thanks, I learned

The problem of lighting up the lamp forever, I found that it was very difficult to modify the routine and port the FreeRTOS small program

Finally, I found that the GPIO MODE, PULLUP, and PULLDOWN in CubeMX were not configured properly.

This post is from stm32/stm8
 
 
 

2

Posts

0

Resources
8
 

I'm studying recently, the tutorial is very good, I can say that I'm very attentive


This post is from stm32/stm8
 
 
 

1w

Posts

204

Resources
9
 

Review summary: Free application | ST NUCLEO-U575ZI-Q https://en.eeworld.com/bbs/thread-1228653-1-1.html

This post is from stm32/stm8
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list