i2c_param_config(753): i2c clock choice is invalid, please check flag and frequency
Posted: Fri Oct 04, 2024 7:41 am
Hello everybody,
I am working on a project where I need to do 2 things simultaniously. The first one is listening to a digital potentiometer (DP) in slave mode to get or set the wiper value. The other task is retrieving a raw data from a CAN (HX711) and corvert it into a weight value. I am using GPIO25 and 26 for the HX711 and >GPIO14 and 27 for the digital pot.
For now, both things are working well when separated, but here is the issue.
I am working with the hx711 library from https://github.com/UncleRus/esp-idf-lib ... 11/default
where the descriptor initialisation is has below
For the digital potentiometers, am using AD5245 IC https://www.mouser.fr/datasheet/2/609/A ... 601824.pdf
and I am actually using a library from https://github.com/UncleRus/esp-idf-lib ... 02/default
with this initialisation setup
I have a IC_FREQ_HZ of 400kHz and I know I don't have the same for the hx711 device. Do I have to change the i2C frequency to match the IC with the smallest one?
The other issue is that when I try to run my software
where
I first call the hx711 initilization then the descriptor for the DP and set to 0 the wiper position. But I get this log :
So i decided to check the ad5245_init function that is here
And I don't understand which frequency set the ad5245 descriptor configuration. I don't think the issue has something to deal with any king of flag, but I am not really sure.
I am using a ESP32E for this project. I can assure that separated, both devices work fine.
Thank by advance.
I am working on a project where I need to do 2 things simultaniously. The first one is listening to a digital potentiometer (DP) in slave mode to get or set the wiper value. The other task is retrieving a raw data from a CAN (HX711) and corvert it into a weight value. I am using GPIO25 and 26 for the HX711 and >GPIO14 and 27 for the digital pot.
For now, both things are working well when separated, but here is the issue.
I am working with the hx711 library from https://github.com/UncleRus/esp-idf-lib ... 11/default
where the descriptor initialisation is has below
Code: Select all
esp_err_t hx711_init(hx711_t *dev)
{
CHECK_ARG(dev);
gpio_config_t conf = {
.pin_bit_mask = BIT(dev->dout),
.mode = GPIO_MODE_INPUT,
.pull_up_en = 0,
.pull_down_en = 0,
.intr_type = GPIO_INTR_DISABLE
};
CHECK(gpio_config(&conf));
conf.pin_bit_mask = BIT(dev->pd_sck);
conf.mode = GPIO_MODE_OUTPUT;
CHECK(gpio_config(&conf));
CHECK(hx711_power_down(dev, false));
return hx711_set_gain(dev, dev->gain);
}
and I am actually using a library from https://github.com/UncleRus/esp-idf-lib ... 02/default
with this initialisation setup
Code: Select all
esp_err_t ad5245_init_desc(i2c_dev_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)
{
dev->port = port;
dev->addr = addr;
dev->cfg.sda_io_num = sda_gpio;
dev->cfg.scl_io_num = scl_gpio;
#if HELPER_TARGET_IS_ESP32
dev->cfg.master.clk_speed = I2C_FREQ_HZ;
#endif
return i2c_dev_create_mutex(dev);
}
The other issue is that when I try to run my software
Code: Select all
static void call_global_configuration_functions_system(i2c_dev_t *dev){
fflush(stdout);
initialization_test_phase(NULL); //Call the UART initialization communication function and the setting GPIO functions.
spiffs_config(); //Initialization of the partitions
//Initialization of I2C communication for the HX711s
ESP_ERROR_CHECK(hx711_init(&hx711_dev));
// Init i2cdev library
ESP_ERROR_CHECK(i2cdev_init());
first_use_potentiometer(&dev);
// timer_creation(&timer_handler_wait_before_starting,false, &check_first_conf,3000); //Don't send anything if timer isn't deleted
}
Code: Select all
esp_err_t first_use_potentiometer(i2c_dev_t *dev){
//Initialization of the other I2C bus
ESP_ERROR_CHECK(ad5245_ready_to_use(&dev,AD5245_ADDR_0));
// Read wiper position of driving motor
ESP_ERROR_CHECK(ad5245_get_wiper_pos(&dev,pot_positions.driving_pot));
// Write wiper position of driving motor
ESP_ERROR_CHECK(ad5245_set_wiper_pos(&dev,ZERO_POS,true));
//Free the buffer
ESP_ERROR_CHECK(ad5245_free_desc(&dev));
Code: Select all
I (27) boot: ESP-IDF v5.0.6-dirty 2nd stage bootloader
I (27) boot: compile time 15:11:35
I (27) boot: Multicore bootloader
I (31) boot: chip revision: v3.0
I (35) boot.esp32: SPI Speed : 40MHz
I (39) boot.esp32: SPI Mode : DIO
I (44) boot.esp32: SPI Flash Size : 4MB
I (49) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (57) boot: ## Label Usage Type ST Offset Length
I (65) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (72) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (80) boot: 2 factory factory app 00 00 00010000 00100000
I (87) boot: 3 storage Unknown data 01 82 00110000 00100000
I (95) boot: End of partition table
I (99) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0d934h ( 55604) map
I (127) esp_image: segment 1: paddr=0001d95c vaddr=3ffb0000 size=01fb4h ( 8116) load
I (131) esp_image: segment 2: paddr=0001f918 vaddr=40080000 size=00700h ( 1792) load
I (134) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=2df78h (188280) map
I (210) esp_image: segment 4: paddr=0004dfa0 vaddr=40080700 size=0dc90h ( 56464) load
I (240) boot: Loaded app from partition at offset 0x10000
I (240) boot: Disabling RNG early entropy source...
I (252) cpu_start: Multicore app
I (252) cpu_start: Pro cpu up.
I (252) cpu_start: Starting app cpu, entry point is 0x40081388
0x40081388: call_start_cpu1 at C:/Users/CorentinLEROY/esp/v5.0.6/esp-idf/components/esp_system/port/cpu_start.c:147
I (242) cpu_start: App cpu up.
I (270) cpu_start: Pro cpu start user code
I (270) cpu_start: cpu freq: 160000000 Hz
I (270) cpu_start: Application information:
I (275) cpu_start: Project name: mybrouette
I (280) cpu_start: App version: 2462eed-dirty
I (286) cpu_start: Compile time: Sep 4 2024 11:26:37
I (292) cpu_start: ELF file SHA256: 8122a54156b85591...
I (298) cpu_start: ESP-IDF: v5.0.6-dirty
I (303) cpu_start: Min chip rev: v0.0
I (308) cpu_start: Max chip rev: v3.99
I (313) cpu_start: Chip rev: v3.0
I (318) heap_init: Initializing. RAM available for dynamic allocation:
I (325) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (331) heap_init: At 3FFB2C20 len 0002D3E0 (180 KiB): DRAM
I (337) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (343) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (350) heap_init: At 4008E390 len 00011C70 (71 KiB): IRAM
I (357) spi_flash: detected chip: generic
I (361) spi_flash: flash io: dio
W (365) spi_flash: Detected size(16384k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
I (379) app_start: Starting scheduler on CPU0
I (383) app_start: Starting scheduler on CPU1
I (383) main_task: Started on CPU0
I (393) main_task: Calling app_main()
I (393) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (403) gpio: GPIO[17]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (413) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (543) gpio: GPIO[26]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (543) gpio: GPIO[25]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
Value of ADDR : 45
E (563) i2c: i2c_param_config(753): i2c clock choice is invalid, please check flag and frequency
ESP_ERROR_CHECK failed: esp_err_t 0x102 (ESP_ERR_INVALID_ARG) at 0x400d7572
0x400d7572: ad5245_ready_to_use at C:/Users/CorentinLEROY/Documents/Brouette/Code/mybrouette/components/ad5245/ad5245.c:128 (discriminator 1)
file: "./components/ad5245/ad5245.c" line 128
func: ad5245_ready_to_use
expression: ad5245_init(&dev)
abort() was called at PC 0x400874f3 on core 0
0x400874f3: _esp_error_check_failed at C:/Users/CorentinLEROY/esp/v5.0.6/esp-idf/components/esp_system/esp_err.c:47
Code: Select all
esp_err_t ad5245_ready_to_use(i2c_dev_t *dev, uint8_t address){
// Zero device descriptor
memset(&dev, 0, sizeof(dev));
// Initialize i2c device descriptor
printf("Value of ADDR : %d\n\r", address);
ESP_ERROR_CHECK(ad5245_init_desc(&dev, address,0, CONFIG_EXAMPLE_I2C_MASTER_SDA, CONFIG_EXAMPLE_I2C_MASTER_SCL));
// Initialize potentiometer
ESP_ERROR_CHECK(ad5245_init(&dev));
return ESP_OK;
}
I am using a ESP32E for this project. I can assure that separated, both devices work fine.
Thank by advance.