1049 views|3 replies

16

Posts

0

Resources
The OP
 

[Evaluation of STM32L452Nucleo-64] Module testing by lighting up LEDs and OLEDs [Copy link]

1. Light up an LED lamp
Software programming often starts with outputting "Hello World". In embedded development, we often start learning by lighting up a running light. However, due to the limited onboard resources, there is only one green LED lamp on the Nucleo development board. Here we use lighting up this LED lamp as an example to develop the first program. First, the configuration of Cube is shown in the figure below, which is the initial configuration without modification.


Enter the code in while(1)

HAL_GPIO_TogglePin(GPIOA,LD4_Pin);
HAL_Delay(1000);


The green LED light will flash every second. After compiling, you can download the demonstration video as follows

2cb61de732ea018baecfe9bf6b2de912

2. OLED module test

OLED is a commonly used intuitive display module for programming. Here we introduce the use of I2C for OLED configuration on STM32L452RE. First, the configuration of Cube is shown in the figure below.

After generating the bottom layer, we also need to introduce three files: oled.c, oled.h, and oledfont.h. Those who often develop must be familiar with them, so I won't go into details here. I use a four-pin oled screen to connect GND to ground and VCC to 3.3V. Here, I configure the I2C2 channel, so SCL connects to PB10 and SDA connects to PB11. After connecting, I wrote a test code for testing.

int main(void)

{

/* USER CODE BEGIN 1 */

u8 t=0;

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */

SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_USART2_UART_Init();

MX_I2C2_Init();

/* USER CODE BEGIN 2 */

OLED_Init();

OLED_ShowString(0,0,"STM32L452",24);

OLED_ShowString(0,24, "0.96' OLED TEST",16);

OLED_ShowString(0,40,"ATOM 2023/9/17",12);

OLED_ShowString(0,52,"ASCII:",12);

OLED_ShowString(64,52,"CODE:",12);

OLED_Refresh_Gram();

t=' ';

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */

OLED_ShowChar(36,52,t,12);

OLED_ShowNum(94,52,t,3,12);

OLED_Refresh_Gram();

t++;

if(t>'~')t=' ';

HAL_Delay(500);

/* USER CODE BEGIN 3 */

}

/* USER CODE END 3 */

}

The test results are as follows

It should be noted that the output pins are changed when using different I2C channels. STM32L452RE can configure four I2Cs, of which I2C1 corresponds to PA9 and PA10, I2C2 corresponds to PB10 and PB11, I2C3 corresponds to PC0 and PC1, and I2C3 corresponds to PB6 and PB7. After configuration, find the corresponding pins. If the pins on the board are not fully marked, please refer to the figure below.

This post is from stm32/stm8

Latest reply

Ok, thanks for sharing!   Details Published on 2023-9-25 18:41
 

7452

Posts

2

Resources
2
 

Who provides the OLED_ShowString library?

This post is from stm32/stm8

Comments

This is a function in oled.c that I use. I often use these three files for reference.   Details Published on 2023-9-23 22:19
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 

16

Posts

0

Resources
3
 
freebsder posted on 2023-9-19 17:19 Who provided the OLED_ShowString library?

This is a function in oled.c that I use. I often use these three files for reference.

oledfont.h (39.61 KB, downloads: 1)

oled.h (1.16 KB, downloads: 1)

oled.c (8.28 KB, downloads: 1)

This post is from stm32/stm8

Comments

Ok, thanks for sharing!  Details Published on 2023-9-25 18:41
 
 

7452

Posts

2

Resources
4
 
A fragrant durian published on 2023-9-23 22:19 This is a function in the oled.c I use. I often use these three files for reference

Ok, thanks for sharing!

This post is from stm32/stm8
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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