Skip to content
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

Programming with ESP-IDF results in invalid handle for TCA9554 driver #403

Open
1 task done
karunt opened this issue Oct 10, 2024 · 2 comments
Open
1 task done
Labels

Comments

@karunt
Copy link

karunt commented Oct 10, 2024

Board

Qualia ESP32-S3

Hardware Description

Qualia ESP32-S3 board, equipped with PCA9554 I/O extender, connected to 3.4" 480x480 RGB565 TFT (no touchscreen) LCD (https://www.adafruit.com/product/5825#description), driven by ST7701 panel driver.

IDE Name

VSCode with Espressif-IDF extension

Operating System

Windows 11

Description

Begin code with trying to generate handle for TCA9554 extender. But code crashes and reboots after producing invalid handle error. Following errors are produced:

E (416) i2c: i2c_master_cmd_begin(1478): i2c driver not installed
E (426) tca9554: write_direction_reg(133): Write direction reg failed
E (436) tca9554: reset(151): Write dir reg failed
E (436) tca9554: esp_io_expander_new_i2c_tca9554(81): Reset failed
E (446) io_expander: esp_io_expander_set_dir(35): Invalid handle
E (446) io_expander: esp_io_expander_set_level(63): Invalid handle

Why do I get an invalid handle error for the I/O expander?

Schematics of Qualia ESP32-S3, I/O expander and LCD attached.
AdaFruit Qualia Board Connections to ESP32-S3

Sketch

#define ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_NEW    (0x3F)
#define EXAMPLE_LCD_IO_RGB_VSYNC        42
#define EXAMPLE_LCD_IO_RGB_HSYNC        41
#define EXAMPLE_LCD_IO_RGB_DE           2
#define EXAMPLE_LCD_IO_RGB_PCLK         1
#define EXAMPLE_LCD_IO_RGB_DATA0        40
#define EXAMPLE_LCD_IO_RGB_DATA1        39
#define EXAMPLE_LCD_IO_RGB_DATA2        38
#define EXAMPLE_LCD_IO_RGB_DATA3        0
#define EXAMPLE_LCD_IO_RGB_DATA4        45
#define EXAMPLE_LCD_IO_RGB_DATA5        48
#define EXAMPLE_LCD_IO_RGB_DATA6        47
#define EXAMPLE_LCD_IO_RGB_DATA7        21
#define EXAMPLE_LCD_IO_RGB_DATA8        14
#define EXAMPLE_LCD_IO_RGB_DATA9        13
#define EXAMPLE_LCD_IO_RGB_DATA10       12
#define EXAMPLE_LCD_IO_RGB_DATA11       11
#define EXAMPLE_LCD_IO_RGB_DATA12       10
#define EXAMPLE_LCD_IO_RGB_DATA13       9
#define EXAMPLE_LCD_IO_RGB_DATA14       46
#define EXAMPLE_LCD_IO_RGB_DATA15       3

#define EXAMPLE_LCD_IO_SPI_CS           (IO_EXPANDER_PIN_NUM_5)
#define EXAMPLE_LCD_IO_SPI_SCL          (IO_EXPANDER_PIN_NUM_4)
#define EXAMPLE_LCD_IO_SPI_SDA          (IO_EXPANDER_PIN_NUM_12)
#define EXAMPLE_LCD_IO_RST              (IO_EXPANDER_PIN_NUM_6)
#define EXAMPLE_PIN_NUM_BK_LIGHT        (IO_EXPANDER_PIN_NUM_9)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL   1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL  !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL

static const char *TAG = "display_example";

IRAM_ATTR static bool rgb_lcd_on_vsync_event(esp_lcd_panel_handle_t panel, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx)
{
    return lvgl_port_notify_rgb_vsync();
}

void display_start()
{
  esp_io_expander_handle_t io_expander_tft = NULL;
  esp_io_expander_new_i2c_tca9554(I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_NEW, &io_expander_tft);
  esp_io_expander_set_dir(io_expander_tft, IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, IO_EXPANDER_OUTPUT);
  esp_io_expander_set_level(io_expander_tft, IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, 0);

//More code follows, but upon flashing, code fails to go past the esp_io_expander_set_level function above
}

Other Steps to Reproduce

No response

I have checked existing issues, README.md and ESP32 Forum

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@karunt karunt added Status: Awaiting triage Type: Bug Something isn't working labels Oct 10, 2024
@github-actions github-actions bot changed the title Programming with ESP-IDF results in invalid handle for TCA9554 driver Programming with ESP-IDF results in invalid handle for TCA9554 driver (BSP-562) Oct 10, 2024
@karunt karunt changed the title Programming with ESP-IDF results in invalid handle for TCA9554 driver (BSP-562) Programming with ESP-IDF results in invalid handle for TCA9554 driver Oct 10, 2024
@tore-espressif
Copy link
Collaborator

The first line of your log says

E (416) i2c: i2c_master_cmd_begin(1478): i2c driver not installed

have you installed the I2C driver with i2c_driver_install()

@karunt
Copy link
Author

karunt commented Oct 11, 2024

Thanks for catching that. I have now done that and the code is moving forward, but still aborting at a different point, probably unrelated to this driver. But another question - the readme document calls for setting pins 0 and 1 direction to output and levels to low. What's the purpose for doing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants