2739 views|7 replies

1452

Posts

1

Resources
The OP
 

[NUCLEO-L452RE Review] +OLED screen display driver [Copy link]

This post was last edited by jinglixixi on 2020-12-21 16:06

The NUCLEO-L452RE development board has relatively few peripherals. In order to facilitate human interaction, the first thing to consider is to equip it with a display screen to facilitate information observation.

In order to occupy less system resources, a two-color OLED screen with an I2C interface is used here . Considering that the NUCLEO-L452RE development board is equipped with an Arduino interface, the OLED screen is placed on the Arduino interface for use, so that the problem can be solved without connecting wires.

The connection relationship between the OLED screen and the MCU is:

SCL---PA5

SDA---PA6

The statement that controls the high and low levels of the related pins is defined as:

#define OLED_SCLK_Set() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,GPIO_PIN_SET)

#define OLED_SCLK_Clr() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5,GPIO_PIN_RESET)

#define OLED_SDIN_Set() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,GPIO_PIN_SET)

#define OLED_SDIN_Clr() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6,GPIO_PIN_RESET)

The function to implement pin output function configuration is:

void GPIO_OLED_INIT(void)
{
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Mode= GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pin = GPIO_PIN_5;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 
GPIO_InitStruct.Pin = GPIO_PIN_6;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}

The auxiliary display function is:

void IIC_Start()
{
OLED_SCLK_Set();
OLED_SDIN_Set();
OLED_SDIN_Clr();
OLED_SCLK_Clr();
}

void IIC_Stop()
{
OLED_SCLK_Set();
OLED_SDIN_Clr();
OLED_SDIN_Set();
}

void IIC_Wait_Ack()
{
OLED_SCLK_Set();
OLED_SCLK_Clr();
}

The string display functions involved are:

void OLED_ShowString(u8 x,u8 y,u8 *chr,u8 Char_Size)
{
  unsigned char j=0;
  while (chr[j]!='\0')
  {   
            OLED_ShowChar(x,y,chr[j],Char_Size);
    x+=8;
    if(x>120){x=0;y+=2;}
    j++;
  }

}

The main program to achieve the display effect shown in the figure below is:

int main(void)
{
HAL_Init();
SystemClock_Config();
GPIO_OLED_INIT();
OLED_Init();
OLED_Clear();
OLED_ShowString(8,2,"STM32L452",16);
OLED_ShowString(8,4,"OLED TEST",16);
OLED_ShowCHinese(80,2,9);
OLED_ShowCHinese(96,2,10);
OLED_ShowCHinese(112,2,11);
while (1);
}

OLED screen display effect

With the display function of the OLED screen, it will be more convenient to realize an electronic clock with RTC later.

This post is from stm32/stm8

Latest reply

This LCD is more fun if it is bigger   Details Published on 2020-12-22 13:27
 

1w

Posts

204

Resources
From 4
 

ST NUCLEO-L452RE review

Summary post: https://en.eeworld.com/bbs/thread-1151850-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测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 

20

Posts

0

Resources
2
 

Did you copy it?

This post is from stm32/stm8

Comments

What does it mean?  Details Published on 2020-12-20 23:12
 
 

1452

Posts

1

Resources
3
 

What does it mean?

This post is from stm32/stm8
 
 
 

20

Posts

0

Resources
5
 

Wrong model?

This post is from stm32/stm8

Comments

Haha, the two boards arrived at the same time, so they can be used together to run programs.  Details Published on 2020-12-21 15:58
 
 
 

1452

Posts

1

Resources
6
 
zhd posted on 2020-12-21 15:08 The model is wrong?

Haha, the two boards arrived at the same time, so they can be used together to run programs.

This post is from stm32/stm8
 
 
 

1237

Posts

66

Resources
7
 

This LCD is more fun if it is bigger

This post is from stm32/stm8

Comments

I'll get a 2.2-inch display next time.  Details Published on 2020-12-22 14:57
 
 
 

1452

Posts

1

Resources
8
 
dql2016 posted on 2020-12-22 13:27 This LCD will be more fun if it is bigger

I'll get a 2.2-inch display next time.

This post is from stm32/stm8
 
 
 

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