cancel
Showing results for 
Search instead for 
Did you mean: 

Interface the ST7567 GLCD with STM32G0B1RC26

Berlin-raj123
Associate III

Hi,

    I am trying to interface a graphical LCD (ST7567) with the STM32G0B1RCT6 using the U8g2 library and a software SPI interface. I have the U8g2 driver, but I don't know how to configure the ST7567 driver with the STM32G0B1RCT6. I will attach the graphical LCD ST7567. Can anyone help me?

2 REPLIES 2
SofLit
ST Employee

Hello,

You've already asked a similar question in this thread and you accepted it.

Could you please clarify what is going on?

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
OKrau.1
Associate

I have created an example code for u8g2 and the STM32G0 controller: stm32g031/u8g2_test_8 at main · olikraus/stm32g031 · GitHub

You need to specify the desired display here: https://github.com/olikraus/stm32g031/blob/b2424031633993d6fc16a2eb8c0b365e91190194/u8g2_test_8/u8g2_test_8.c#L251

Available displays for the ST7567 are listed here: https://github.com/olikraus/u8g2/wiki/u8g2setupc#st7567-jlx12864 

My example code is for I2C. To use SPI, you need to change the code here: https://github.com/olikraus/stm32g031/blob/b2424031633993d6fc16a2eb8c0b365e91190194/u8g2_test_8/u8x8cb.c#L86-L114

Instead you need to listen to the following messages (see https://github.com/olikraus/u8g2/wiki/Porting-to-new-MCU-platform#template-for-the-gpio-and-delay-callback)

case U8X8_MSG_GPIO_SPI_CLOCK:
if ( arg_int == 0 ) GPIOA->BSRR = GPIO_BSRR_BR2 /* atomic clr PA2 */
else GPIOA->BSRR = GPIO_BSRR_BS_2; /* atomic set PA2 */
break;
case U8X8_MSG_GPIO_SPI_DATA:
break;
case U8X8_MSG_GPIO_DC: // DC (data/cmd, A0, register select) pin: Output level in arg_int
break;
case U8X8_MSG_GPIO_RESET: // Reset pin: Output level in arg_int
break;

In the above example I assigned clock port to PA2. Code for the other messages will be similar except for a different port. Of course you could also use the HAL statements.

Finally you need to tell u8g2 to use SW-SPI:

https://github.com/olikraus/stm32g031/blob/b2424031633993d6fc16a2eb8c0b365e91190194/u8g2_test_8/u8g2_test_8.c#L251

It could look like this:

 

u8g2_Setup_st7567_jlx12864_f(&u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8x8_gpio_and_delay_stm32g0)

 

Oliver