Page 1 of 1

SH1122 Library

Posted: Fri Jul 07, 2023 10:52 am
by zeynep01
Hi, I have a problem with SH1122 display. I can't find any library on ESP-IDF and I couldn't write new library. I found STM-HAL library and I tested with my SH1122 board, It works. I changed STM-HAL library for ESP-IDF but It doesn't work and I can't fix. How I can fix ?

this is my main.c
  1. #include <stdio.h>
  2. #include "sh1122.h"
  3. void app_main(void) {
  4.   spi_master_init();
  5.   Display_Init();
  6.   Display_SetOrienation(OLED_DISP_NORMAL);
  7.   Frame_DrawRectangle(2, 2, OLED_WIDTH - 2, OLED_HEIGHT - 2, Display_Color.Gray_15);
  8.   Frame_printf(5, 5, FONTID_6X8M, Display_Color.Gray_03, LEFT, TOP, "Hello World! This is left top alignment");
  9.   Frame_printf(OLED_WIDTH / 2, OLED_HEIGHT / 2, FONTID_32F, Display_Color.Gray_05, CENTER, CENTER, "0123");
  10.   Display_SendFrame();
  11. }
this is sh1122.c bloc
  1. #define OLED_WIDTH 256
  2. #define OLED_HEIGHT 64
  3. void Display_Init(void){
  4.     SH1122_Reset();
  5.     SH1122_ClearRAM();
  6.     SH1122_DisplayPower(OLED_POWER_ON);
  7.     vTaskDelay(100 / portTICK_PERIOD_MS);
  8. }
  9. static void SH1122_ClearRAM(void){
  10.     uint8_t ScreenBuf[OLED_WIDTH * OLED_HEIGHT / 2] = {0};
  11.     SH1122_WriteData(ScreenBuf, OLED_WIDTH * OLED_HEIGHT / 2);
  12. }
  13. void SH1122_WriteData(const uint8_t *pData, size_t DataLen){
  14.     gpio_set_level(PIN_NUM_CS, 0);
  15.     gpio_set_level(PIN_NUM_DC, 1);
  16.     spi_transaction_t t;
  17.     if (DataLen > 0){
  18.         memset(&t, 0, sizeof(t));
  19.         t.length = DataLen * 8; // Length in bits
  20.         t.tx_buffer = pData;    // Data to send
  21.         spi_device_transmit(spi, &t);
  22.     }
  23.     gpio_set_level(PIN_NUM_CS, 1);
  24. }

and this is my error


Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xd (SPI_FAST_FLASH_BOOT)
Saved PC:0x403805bc
0x403805bc: esp_restart_noos_dig at C:/Users/zeynepdicle/esp/esp-idf/components/esp_system/esp_system.c:64 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x16a0
load:0x403cc710,len:0x968
load:0x403ce710,len:0x2e78
entry 0x403cc710
I (24) boot: ESP-IDF v5.0.1 2nd stage bootloader
I (24) boot: compile time 12:15:37
I (24) boot: chip revision: v0.4
I (26) boot.esp32c3: SPI Speed : 80MHz
I (31) boot.esp32c3: SPI Mode : DIO
I (35) boot.esp32c3: SPI Flash Size : 4MB
I (40) boot: Enabling RNG early entropy source...
I (45) boot: Partition Table:
I (49) boot: ## Label Usage Type ST Offset Length
I (56) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (71) boot: 2 factory factory app 00 00 00010000 00100000
I (79) boot: End of partition table
I (83) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0c0a8h ( 49320) map
I (99) esp_image: segment 1: paddr=0001c0d0 vaddr=3fc8a400 size=00ce8h ( 3304) load
I (100) esp_image: segment 2: paddr=0001cdc0 vaddr=40380000 size=03258h ( 12888) load
I (110) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=1a464h (107620) map
I (133) esp_image: segment 4: paddr=0003a48c vaddr=40383258 size=07030h ( 28720) load
I (141) boot: Loaded app from partition at offset 0x10000
I (142) boot: Disabling RNG early entropy source...
I (153) cpu_start: Pro cpu up.
I (162) cpu_start: Pro cpu start user code
I (162) cpu_start: cpu freq: 160000000 Hz
I (162) cpu_start: Application information:
I (165) cpu_start: Project name: sh1122
I (170) cpu_start: App version: 1
I (174) cpu_start: Compile time: Jul 7 2023 12:15:13
I (180) cpu_start: ELF file SHA256: a9425af73c1acf6e...
Warning: checksum mismatch between flashed and built applications. Checksum of built application is 15074427abd4b6bada8067db6057ff8cf84d17037889ad45d10f0c5b82bd082d
I (186) cpu_start: ESP-IDF: v5.0.1
I (191) cpu_start: Min chip rev: v0.3
I (196) cpu_start: Max chip rev: v0.99
I (200) cpu_start: Chip rev: v0.4
I (205) heap_init: Initializing. RAM available for dynamic allocation:
I (212) heap_init: At 3FC8FF30 len 0004C7E0 (305 KiB): DRAM
I (219) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (225) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
I (232) spi_flash: detected chip: generic
W (236) spi_flash: Detected flash size > 16 MB, but access beyond 16 MB is not supported for this flash model yet.
I (248) spi_flash: flash io: dio
I (252) cpu_start: Starting scheduler.
I (256) gpio: GPIO[7]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (256) gpio: GPIO[5]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (266) gpio: GPIO[6]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (376) SPI_TASK: SPI HOST_ID=1
I (376) SPI_TASK: spi_bus_initialize=0
I (376) SPI_TASK: spi_bus_add_device=0

***ERROR*** A stack overflow in task main has been detected.
Core 0 register dump:
MEPC : 0x4038080c RA : 0x403842e8 SP : 0x3fc8b780 GP : 0x3fc8ac00
0x4038080c: panic_abort at C:/Users/zeynepdicle/esp/esp-idf/components/esp_system/panic.c:423

0x403842e8: __ubsan_include at C:/Users/zeynepdicle/esp/esp-idf/components/esp_system/ubsan.c:313

TP : 0x3fc8701c T0 : 0x4005890e T1 : 0x0000000f T2 : 0x00000001
S0/FP : 0x00000003 S1 : 0x80000004 A0 : 0x3fc8b798 A1 : 0x3c022224
A2 : 0x00000003 A3 : 0x3fc8b7c2 A4 : 0x00000001 A5 : 0x3fc90000
A6 : 0x00000000 A7 : 0x00000000 S2 : 0x00001881 S3 : 0x00000001
S4 : 0x00000000 S5 : 0x00000000 S6 : 0x00000000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x00000000 T4 : 0x00000000 T5 : 0x00000001 T6 : 0x00000000
MSTATUS : 0x00001801 MTVEC : 0x40380001 MCAUSE : 0x00000007 MTVAL : 0x00000000
0x40380001: _vector_table at ??:?

MHARTID : 0x00000000

Stack memory:
3fc8b780: 0x00000000 0x00000000 0x00000000 0x40386c76 0x00000008 0x00000008 0x452a2a2a 0x524f5252
0x40386c76: esp_startup_start_app_common at C:/Users/zeynepdicle/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/port_common.c:59

3fc8b7a0: 0x202a2a2a 0x74732041 0x206b6361 0x7265766f 0x776f6c66 0x206e6920 0x6b736174 0x69616d20
3fc8b7c0: 0x6168206e 0x65622073 0x64206e65 0x63657465 0x2e646574 0x00000000 0x00000000 0x00000000
3fc8b7e0: 0x00000000 0x3c0221e8 0x3fc92ffc 0x3c022210 0x00001881 0x80000004 0x3fc93cd8 0x40385f00
0x40385f00: vTaskSwitchContext at C:/Users/zeynepdicle/esp/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:3648

3fc8b800: 0x00000000 0x00000000 0x40383096 0x403869d8 0x4038020a 0x00000000 0x00000000 0x403801ee
0x40383096: esp_crosscore_isr at C:/Users/zeynepdicle/esp/esp-idf/components/esp_system/crosscore_int.c:49

0x403869d8: isr_skip_decrement at C:/Users/zeynepdicle/esp/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/portasm.S:88

0x4038020a: _interrupt_handler at ??:?

0x403801ee: _interrupt_handler at ??:?

3fc8b820: 0x60023000 0x40383e52 0x40383e5e 0x00000001 0x3fc8b834 0xffffffff 0x3fc93728 0x3fc93728
0x40383e52: systimer_ticks_to_us at C:/Users/zeynepdicle/esp/esp-idf/components/esp_hw_support/port/esp32c3/systimer.c:16

0x40383e5e: systimer_us_to_ticks at C:/Users/zeynepdicle/esp/esp-idf/components/esp_hw_support/port/esp32c3/systimer.c:21

3fc8b840: 0x00000000 0x3fc8b848 0xffffffff 0x3fc8b848 0x3fc8b848 0x00000000 0x3fc8b85c 0xffffffff
3fc8b860: 0x3fc8b85c 0x3fc8b85c 0x00000000 0x3fc8b870 0xffffffff 0x3fc8b870 0x3fc8b870 0x00000000
3fc8b880: 0x3fc8b884 0xffffffff 0x3fc8b884 0x3fc8b884 0x00000000 0x3fc8b898 0xffffffff 0x3fc8b898
3fc8b8a0: 0x3fc8b898 0x00000000 0x3fc8b8ac 0xffffffff 0x3fc8b8ac 0x3fc8b8ac 0x00000000 0x3fc8b8c0
3fc8b8c0: 0xffffffff 0x3fc8b8c0 0x3fc8b8c0 0x00000000 0x3fc8b8d4 0xffffffff 0x3fc8b8d4 0x3fc8b8d4
3fc8b8e0: 0x00000000 0x3fc8b8e8 0xffffffff 0x3fc8b8e8 0x3fc8b8e8 0x00000000 0x3fc8b8fc 0xffffffff
3fc8b900: 0x3fc8b8fc 0x3fc8b8fc 0x00000000 0x3fc8b910 0xffffffff 0x3fc8b910 0x3fc8b910 0x00000000
3fc8b920: 0x3fc8b924 0xffffffff 0x3fc8b924 0x3fc8b924 0x00000000 0x3fc8b938 0xffffffff 0x3fc8b938
3fc8b940: 0x3fc8b938 0x00000000 0x3fc8b94c 0xffffffff 0x3fc8b94c 0x3fc8b94c 0x00000000 0x3fc8b960
3fc8b960: 0xffffffff 0x3fc8b960 0x3fc8b960 0x00000000 0x3fc8b974 0xffffffff 0x3fc8b974 0x3fc8b974
3fc8b980: 0x00000000 0x3fc8b988 0xffffffff 0x3fc8b988 0x3fc8b988 0x00000000 0x3fc8b99c 0xffffffff
3fc8b9a0: 0x3fc8b99c 0x3fc8b99c 0x00000000 0x3fc8b9b0 0xffffffff 0x3fc8b9b0 0x3fc8b9b0 0x00000000
3fc8b9c0: 0x3fc8b9c4 0xffffffff 0x3fc8b9c4 0x3fc8b9c4 0x00000000 0x3fc8b9d8 0xffffffff 0x3fc8b9d8
3fc8b9e0: 0x3fc8b9d8 0x00000000 0x3fc8b9ec 0xffffffff 0x3fc8b9ec 0x3fc8b9ec 0x00000000 0x3fc8ba00
3fc8ba00: 0xffffffff 0x3fc8ba00 0x3fc8ba00 0x00000000 0x3fc8ba14 0xffffffff 0x3fc8ba14 0x3fc8ba14
3fc8ba20: 0x00000000 0x3fc8ba28 0xffffffff 0x3fc8ba28 0x3fc8ba28 0x00000000 0x3fc8ba3c 0xffffffff
3fc8ba40: 0x3fc8ba3c 0x3fc8ba3c 0x00000000 0x3fc8ba50 0xffffffff 0x3fc8ba50 0x3fc8ba50 0x00000002
3fc8ba60: 0x3fc8ba64 0xffffffff 0x3fc91e30 0x3fc92fcc 0x00000000 0x3fc8ba78 0xffffffff 0x3fc8ba78
3fc8ba80: 0x3fc8ba78 0x00000000 0x3fc8ba84 0x00000000 0x00000000 0x00000000 0x3fc8ba9c 0xffffffff
3fc8baa0: 0x3fc8ba9c 0x3fc8ba9c 0x00000000 0x3fc8bab0 0xffffffff 0x3fc8bab0 0x3fc8bab0 0x00000001
3fc8bac0: 0x00000001 0x00000000 0x0001ffff 0x00000000 0xb33fffff 0x00000000 0x00000000 0x3fc8bad8
3fc8bae0: 0x00000000 0x00000000 0x00000000 0x3fc8baf0 0xffffffff 0x3fc8baf0 0x3fc8baf0 0x00000000
3fc8bb00: 0x3fc8bb04 0xffffffff 0x3fc8bb04 0x3fc8bb04 0x00000001 0x00000001 0x00000000 0x0001ffff
3fc8bb20: 0x00000000 0xb33fffff 0x00000000 0x00000009 0x3fc90930 0x3fc90998 0x3fc90a00 0x00000000
3fc8bb40: 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 0x4200d842 0x00000000 0x00000000
0x4200d842: _cleanup_r at ??:?

3fc8bb60: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000



ELF file SHA256: a9425af73c1acf6e
Warning: checksum mismatch between flashed and built applications. Checksum of built application is 15074427abd4b6bada8067db6057ff8cf84d17037889ad45d10f0c5b82bd082d

Re: SH1122 Library

Posted: Sat Jul 08, 2023 3:31 am
by ESP_Sprite
***ERROR*** A stack overflow in task main has been detected.
Suggest you try allocating your main task more stack; you can do that in menuconfig.

Re: SH1122 Library

Posted: Mon Jul 10, 2023 9:24 am
by zeynep01
ESP_Sprite wrote:
Sat Jul 08, 2023 3:31 am
***ERROR*** A stack overflow in task main has been detected.
Suggest you try allocating your main task more stack; you can do that in menuconfig.

I fixed it with another method. thank you.