TCA9535 I2C communication problem

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

TCA9535 I2C communication problem

Postby Jimis1 » Sat Oct 28, 2023 12:11 pm

Hi all.
I have connect the TCA9535 IO expander to my board with 2 pull-ups 4k7
I used the code from https://github.com/Gordon01/esp32-tca9535 to communicate with it
I can initialize it properly since I get no error but it seems that the ESP resets when I try to read the registers.

No interrupt is used , I have set the correct GPIO pins for SDA,SCL, address =23 for A0=A1=GND and 100kHz clock.

The fact that initialization doesn't return an error means that the HW is ok ?
Can someone understand what the problem is from the error message ?


I (0) cpu_start: App cpu up.
I (451) cpu_start: Pro cpu start user code
I (451) cpu_start: cpu freq: 160000000 Hz
I (451) cpu_start: Application information:
I (456) cpu_start: Project name: SmartHome
I (461) cpu_start: App version: 0.0.0.1
I (466) cpu_start: Compile time: Oct 28 2023 11:54:28
I (472) cpu_start: ELF file SHA256: b3417773d8d1be23...
I (478) cpu_start: ESP-IDF: v5.1.1
I (483) cpu_start: Min chip rev: v3.0
I (488) cpu_start: Max chip rev: v3.99
I (492) cpu_start: Chip rev: v3.1
I (497) heap_init: Initializing. RAM available for dynamic allocation:
I (505) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (510) heap_init: At 3FFB7990 len 00028670 (161 KiB): DRAM
I (517) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (523) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (529) heap_init: At 400967AC len 00009854 (38 KiB): IRAM
I (537) spi_flash: detected chip: gd
I (540) spi_flash: flash io: dio
I (547) app_start: Starting scheduler on CPU0
I (549) app_start: Starting scheduler on CPU1
I (549) main_task: Started on CPU0
I (559) main_task: Calling app_main()
JIM: checking state...
JIM: init Timer ...
JIM: checking MQTT state 1...
I (569) INIT: [APP] Startup..
I (569) INIT: [APP] Free memory: 280024 bytes
I (569) INIT: [APP] IDF version: v5.1.1
I (589) example_connect: Start example_connect.
I (609) wifi:wifi driver task: 3ffbf5d0, prio:23, stack:6656, core=0
I (619) wifi:wifi firmware version: ce9244d
I (619) wifi:wifi certification version: v7.0
I (619) wifi:config NVS flash: enabled
I (619) wifi:config nano formating: disabled
....
I (6709) [tca9535_i2c]: Initialization done
starting...!
reading IO expander...
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x400d6828 PS : 0x00060330 A0 : 0x800d6644 A1 : 0x3ffb9c10
0x400d6828: check_TCA9535 at F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/TCA9535/TCA9535_general.c:32

A2 : 0x00000030 A3 : 0x00000031 A4 : 0x3ffc6ff0 A5 : 0x00000000
A6 : 0x3ffc59f4 A7 : 0x3ffb3ed0 A8 : 0x800d6828 A9 : 0x3ffb9be0
A10 : 0x00000000 A11 : 0x3ffbb334 A12 : 0x3ffb9c10 A13 : 0x00000000
A14 : 0x3ffb9c10 A15 : 0x00000000 SAR : 0x00000017 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000030 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
0x4000c2e0: memcpy in ROM

0x4000c2f6: memcpy in ROM



Backtrace: 0x400d6825:0x3ffb9c10 0x400d6641:0x3ffb9c30 0x400d62a1:0x3ffb9c60 0x40151f6f:0x3ffb9c90 0x4008c619:0x3ffb9cc0
0x400d6825: check_TCA9535 at F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/components/TCA9535/TCA9535_general.c:32

0x400d6641: check_inputs at F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/main/general.c:43

0x400d62a1: app_main at F:/_Jim/Programming/ESP32_codes/SmartHome/SmartHome_OTA_MQTT_basic/main/main.c:164

0x40151f6f: main_task at C:/Applications/Programming/ESP/esp-idf/components/freertos/app_startup.c:208 (discriminator 13)

0x4008c619: vPortTaskWrapper at C:/Applications/Programming/ESP/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

MicroController
Posts: 1706
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: TCA9535 I2C communication problem

Postby MicroController » Sat Oct 28, 2023 2:28 pm

Can someone understand what the problem is from the error message ?
Core 0 panic'ed (StoreProhibited).
...
TCA9535_general.c:32
...
0x4000c2e0: memcpy in ROM
Apparently somewhere around line 32 in TCA9535_general.c an invalid pointer is passed around to which some code then tries to copy some data.

Who is online

Users browsing this forum: Bing [Bot] and 111 guests