-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use U8g2 with STM32 #356
Comments
I think you have to implement the other delay functions also: |
Many thanks to you olikraus |
:) |
I use OLED(SSD1306 12864), can you send your whole project to me for reference? thank you!my email: |
Is there any detailed tutorial how to use ST7920 and STM32 with u8g2? I was trying to use these "issue-guides", but when I call: u8g2_Setup_st7920_s_128x64_1(&u8g2, U8G2_R0, u8x8_byte_4wire_sw_spi, u8g2_gpio_and_delay_stm32); - I'm out of RAM. Old version (u8glib) works fine, but I need UTF-8 fonts from new version. Without calling setup function: With it: |
maybe you did not activate the gcc linker garbage collector. |
I was trying to add --gc-sections in Linker parameters, but got this error: |
Usually options are: |
Looks like I cannot enable garbage collection in Keil5 linker... |
Keil uses ARM Compiler Toolchain and it has option --remove, that works the same as --gc-sections, but it changed nothing :( 12.118 --remove, --no_remove Enables or disables the removal of unused input sections from the image. |
Main problem were static uint8_t buf[x] variables in u8g2_d_memory.c. I commented out all of them and created a global one in that file. Here is step by step guide how to run ST7920 with STM32 in Keil 5 using HAL:
|
Hi rokk0, I've try to follow the steps you've described, but still i'm not be able to write nothing!, i'm using STM32F070-nucleo board, here is my code /* Includes ------------------------------------------------------------------*/ // LCD 128x64 uint8_t count = 0; GPIO_InitTypeDef GPIO_InitStruct; uint8_t lcd_refresh_time = 1; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /** HAL_Init(); /* Configure LED2 /
u8g2_Setup_st7920_128x64_f(&u8g2, U8G2_R0, u8g2_InitDisplay(&u8g2); HAL_Delay(100); u8g2_ClearDisplay(&u8g2); //u8g2_ClearBuffer(&u8g2); /* Infinite loop */
} uint8_t u8g2_gpio_and_delay_stm32(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
} uint8_t u8x8_byte_4wire_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) switch(msg)
} /**
/**
/* No HSE Oscillator on Nucleo, Activate PLL with HSI as source / /* Select PLL as system clock source and configure the HCLK, PCLK1 clocks dividers / Can you give a little help? |
I think you need to call u8g2_Setup_st7920_s_128x64_f, not u8g2_Setup_st7920_128x64_f. |
Hello, i want to use u8g2 with a STM32L432 via hardware SPI and a SH1106 OLED Display. I used the instruction from rokk0 to implement the code, but the Display shows nothing. Can anyone help? Here are the important functions: uint8_t u8x8_byte_4wire_hw_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) switch(msg) uint8_t u8g2_gpio_and_delay_stm32(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg,U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr) void draw(u8g2_t *u8g2) u8g2_SetFontMode(u8g2, 1); sprintf(string_1, "LCD refresh: %d ms", lcd_refresh_time); u8g2_SendBuffer(u8g2); Setup in the Main function: ` __HAL_SPI_ENABLE(&hspi1); u8g2_Setup_sh1106_128x64_noname_1(&u8g2, U8G2_R0, u8x8_byte_4wire_hw_spi, u8g2_gpio_and_delay_stm32); Periodical call of "draw(&u8g2);" in the loop |
Hi, breezer15 All your code seen ok to me, my display has the ks0108 controller, but using his setup didn't work. It just worked using the u8g2_Setup_st7920_s_128x64_f(&u8g2, U8G2_R0, Now is all working! |
Hi, I follow your instruction using Nucleo-F746ZG. My setup is as follow. I would like to know the following information from you.
Please help me check. I don't know what wrong with it. Thanks. Regards, |
Probably I can not support here as library author. I do not what HAL_SPI_Transmit does. |
I think the issue is due to Signal Level. STM32F logic level is 3.3 V and
ST7920 requires 5V x 0.7=3.7V. Let me verify it with level shifter.
Thanks
…On Sun, Nov 25, 2018 at 1:38 AM olikraus ***@***.***> wrote:
Probably I can not support here as library author. I do not what
HAL_SPI_Transmit does.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#356 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AL_62AZfVx_iooCTVbk0KX7jyH4mkusKks5uyYQTgaJpZM4PUU0v>
.
|
Dear Olikraus, ST7920 LCD doesn't show properly. I don't know what is wrong. Please give me some suggestion. /* Includes ------------------------------------------------------------------*/ /* USER CODE BEGIN Includes / /* Private variables ---------------------------------------------------------*/ SPI_HandleTypeDef hspi1; /* USER CODE BEGIN PV / /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP / /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals / u8g2_Setup_st7920_s_128x64_f(&u8g2, U8G2_R0, u8x8_byte_4wire_hw_spi, u8g2_gpio_and_delay_stm32); /* USER CODE END 2 */ /* Infinite loop / /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } } /** RCC_OscInitTypeDef RCC_OscInitStruct;
__HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
if (HAL_PWREx_EnableOverDrive() != HAL_OK)
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); /* SysTick_IRQn interrupt configuration */ /* SPI1 init function */ /* SPI1 parameter configuration*/ } /** Configure pins as GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ /*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */ /*Configure GPIO pin : LCD_RST_Pin */ /*Configure GPIO pin : LCD_CS_Pin */ /*Configure GPIO pin : LCD_DC_Pin */ } /* USER CODE BEGIN 4 */ ////////////////////// FOR HW SPI ///////////////////////////////////// switch(msg) uint8_t u8g2_gpio_and_delay_stm32(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg,U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr) void draw(u8g2_t *u8g2) // u8g2_SetFontMode(u8g2, 1); // sprintf(string_1, "LCD refresh: %d ms", 100); u8g2_SendBuffer(u8g2); /**
#ifdef USE_FULL_ASSERT
/**
/**
/************************ (C) COPYRIGHT STMicroelectronics *END OF FILE/ |
I do not know the STM32 specific API nor did I wrote the code (additionally you didn't use proper code tags here). Moreover I do not have time to debug this. If you did not wrote the glue code between u8g2 and STM32, then maybe try to find the person who wrote this code. I can only check the hardware with you (wiring, signal levels) with you. Did you add proper signal level converters here? |
Dear Olikraus, I change the following and it is working now. I don't need the level shifter as well. Thanks. void u8g2_Setup_st7920_s_128x64_f(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb) |
Hi rokko, Thanks alot |
Hi,
U8g2 is the great library for LCD and i want to use it with my stm32f4 board. I was use LCD with ST7920 chip. I done the setup for my stm with #179 and u8g2setupc. But the LCD keeping show some strange characters.
I'm new to stm and u8g2. So many thanks for helps.
Here my config
PA1 - CLK - E
PA2 - SPI data - R/W
PA3 - RST - RST
PA4 - CS - PSB
PA5 - CD - RS
The text was updated successfully, but these errors were encountered: