Logging stops working after i2c_new_master_bus()

raywo_esp
Posts: 4
Joined: Wed Dec 27, 2023 1:34 pm

Logging stops working after i2c_new_master_bus()

Postby raywo_esp » Tue Jan 02, 2024 4:09 pm

I am using an ESP32-C3-DevLit-M1 and try to speak to a sensor via I2C. In order to do that I create a new I2C master bus using

Code: Select all

esp_err_t i2c_new_master_bus(const i2c_master_bus_config_t *bus_config, i2c_master_bus_handle_t *ret_bus_handle);
imported from i2c_master.h. When I call this function the log stops working. There is one last truncated entry and nothing else is printed anymore. The program seem to work properly since it shows the correct behaviour. Nevertheless nothing is printed in the logs after that call. What am I doing wrong?

Log output:

Code: Select all

I (414) main_task: Started on CPU0
I (424) main_task: Calling app_main()
I (424) [BATHROOM_SENSOR]: Starting bath room app...
I (424) gpio: GPIO[5]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (434) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (444) gpio: GPIO[2]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
I (454) gpio: GPIO[2]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (464) [App]: Setting up the app...
I (464) [App]: └── Initializing I2C master bus...
I (474) gpio: GPIO[20]| InputEn: 1| OutputEn: 1| OpenDrain: 1| Pullup: 0| Pulldo
Code which call the I2C-function:

Code: Select all

void App::setup() {
    ESP_LOGI(TAG, "Setting up the app...");

    esp_err_t status = ESP_OK;

    status = i2c_master_init();
    if (status != ESP_OK) {
      ESP_LOGE(TAG, "└── Failed to initialize I2C master bus. Reason: %s", esp_err_to_name(status));
      esp_deep_sleep_start();
    }

    ESP_LOGI(TAG, "└── Initialized I2C master bus. Status: %d", status); // <- This is not printed anymore.
    
    // more code omitted
}
i2c_master_init():

Code: Select all

esp_err_t App::i2c_master_init() {
    ESP_LOGI(TAG, "└── Initializing I2C master bus...");

    i2c_master_bus_config_t config = {
        .i2c_port = -1, // auto select
        .sda_io_num = I2C_GPIO_SDA,
        .scl_io_num = I2C_GPIO_SCL,
        .clk_source = I2C_CLK_SRC_DEFAULT,
        .glitch_ignore_cnt = 7, // recommended
        .intr_priority = 0, // auto select
        .flags = {
            .enable_internal_pullup = 0,
        },
    };

    return i2c_new_master_bus(&config, &_i2c_bus_handle);
}

qu1j0t3
Posts: 3
Joined: Sun Feb 18, 2024 2:17 am

Re: Logging stops working after i2c_new_master_bus()

Postby qu1j0t3 » Sun Feb 18, 2024 2:19 am

I'm having a similar problem with a DevKitC v4. My program stops logging in the middle of a message, but the code still runs.

I don't have a solution yet.

nandishre
Posts: 4
Joined: Tue Apr 16, 2024 8:12 am

Re: Logging stops working after i2c_new_master_bus()

Postby nandishre » Tue Apr 16, 2024 8:16 am

i am using esp32 devkit, esp-idf , sdk=v5.2.1 , i too face similar issue, some times if i disable printf/esp_log it will work but some times not.
if i disable I2C it works fine, dont know what is the issue, need some solutions as no where seen any solutions for this issue

Who is online

Users browsing this forum: No registered users and 410 guests