RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

dmitrij999
Posts: 64
Joined: Sat Mar 02, 2019 8:06 pm

RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby dmitrij999 » Sat Mar 02, 2019 8:20 pm

I'm trying to get info from RDA5807M but ESP32 return i2c null address error. I tried to change addresses for sequential and random addresses, increase timeout but it has no effect. Arduino I2C scanner finds RDA's addresses.

My project in the attachment.

The log:

Code: Select all


ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5840
ho 0 tail 12 room 4
load:0x40078000,len:9188
load:0x40080000,len:6084
0x40080000: _WindowOverflow4 at C:/msys32/home/dmitr/esp/esp-idf/components/freertos/xtensa_vectors.S:
1779

entry 0x4008032c
0x4008032c: _KernelExceptionVector at ??:?

I (30) boot: ESP-IDF v3.1.3-dirty 2nd stage bootloader
I (30) boot: compile time 22:44:01
I (30) boot: Enabling RNG early entropy source...
I (35) boot: SPI Speed      : 40MHz
I (39) boot: SPI Mode       : DIO
I (43) boot: SPI Flash Size : 4MB
I (47) boot: Partition Table:
I (51) boot: ## Label            Usage          Type ST Offset   Length
I (58) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (73) boot:  2 factory          factory app      00 00 00010000 00100000
I (80) boot:  3 storage          Unknown data     01 82 00110000 000f0000
I (88) boot: End of partition table
I (92) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2faf0 (195312) map
I (169) esp_image: segment 1: paddr=0x0003fb18 vaddr=0x3ffc0000 size=0x004f8 (  1272) load
I (170) esp_image: segment 2: paddr=0x00040018 vaddr=0x400d0018 size=0xa50cc (676044) map
0x400d0018: _flash_cache_start at ??:?

I (413) esp_image: segment 3: paddr=0x000e50ec vaddr=0x3ffc04f8 size=0x029f0 ( 10736) load
I (417) esp_image: segment 4: paddr=0x000e7ae4 vaddr=0x40080000 size=0x00400 (  1024) load
0x40080000: _WindowOverflow4 at C:/msys32/home/dmitr/esp/esp-idf/components/freertos/xtensa_vectors.S:
1779

I (420) esp_image: segment 5: paddr=0x000e7eec vaddr=0x40080400 size=0x131b0 ( 78256) load
I (472) boot: Loaded app from partition at offset 0x10000
I (472) boot: Disabling RNG early entropy source...
I (473) cpu_start: Pro cpu up.
I (476) cpu_start: Starting app cpu, entry point is 0x400810cc
0x400810cc: call_start_cpu1 at C:/msys32/home/dmitr/esp/esp-idf/components/esp32/cpu_start.c:232

I (0) cpu_start: App cpu up.
I (487) heap_init: Initializing. RAM available for dynamic allocation:
I (494) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (500) heap_init: At 3FFD32E8 len 0000CD18 (51 KiB): DRAM
I (506) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (512) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (519) heap_init: At 400935B0 len 0000CA50 (50 KiB): IRAM
I (525) cpu_start: Pro cpu start user code
I (207) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (436) SPIFFS: Initializing SPIFFS
I (516) SPIFFS: Partition size: total: 896321, used: 0
I (516) I2S: DMA Malloc info, datalen=blocksize=240, dma_buf_count=6
I (516) I2S: PLL_D2: Req RATE: 44100, real rate: 44642.000, BITS: 16, CLKM: 14, BCK: 8, MCLK: 11289966
.924, SCLK: 1428544.000000, diva: 64, divb: 11
I (526) BT_AV: I2C initialized successfully!
E (536) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
null address error
E (546) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
null address error
E (1556) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
 null address error
E (1556) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
 null address error
E (2566) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
 null address error
E (2566) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
 null address error
I (3576) BTDM_INIT: BT controller compile version [3828e65]

I (3576) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
W (3576) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (3746) phy: phy_version: 4008, c9ae59f, Jan 25 2019, 16:54:06, 0, 2
I (4386) BT_AV: Модуль инициализирован!
E (4386) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
 null address error
E (4396) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c
 null address error
I (5406) BT_AV: FM RSSI = 0


Hardware: ESP32-WROOM
ESP-IDF version: 3.1.3
Attachments
a2dp_sink.7z
(10.61 MiB) Downloaded 492 times

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby WiFive » Mon Mar 04, 2019 1:38 am

I think that error means you passed a null pointer to one of the i2c functions. If you check return codes and add error logging you will be able to figure out where that happens.

dmitrij999
Posts: 64
Joined: Sat Mar 02, 2019 8:06 pm

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby dmitrij999 » Mon Mar 04, 2019 8:38 pm

WiFive wrote:
Mon Mar 04, 2019 1:38 am
I think that error means you passed a null pointer to one of the i2c functions. If you check return codes and add error logging you will be able to figure out where that happens.
I defined addrrsses in private.h

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby WiFive » Tue Mar 05, 2019 3:25 am

It is not related to i2c address. It means memory address of a bad pointer.

dmitrij999
Posts: 64
Joined: Sat Mar 02, 2019 8:06 pm

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby dmitrij999 » Wed Mar 06, 2019 11:15 am

WiFive wrote:
Tue Mar 05, 2019 3:25 am
It is not related to i2c address. It means memory address of a bad pointer.
I have no idea how to fix it :(

dmitrij999
Posts: 64
Joined: Sat Mar 02, 2019 8:06 pm

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby dmitrij999 » Sat Mar 09, 2019 1:58 pm

WiFive wrote:
Tue Mar 05, 2019 3:25 am
It is not related to i2c address. It means memory address of a bad pointer.
I compare my code with example code. Code from example:

Code: Select all

static esp_err_t i2c_example_master_read_slave(i2c_port_t i2c_num, uint8_t* data_rd, size_t size)
{
    if (size == 0) {
        return ESP_OK;
    }
    i2c_cmd_handle_t cmd = i2c_cmd_link_create();
    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, ( ESP_SLAVE_ADDR << 1 ) | READ_BIT, ACK_CHECK_EN);
    if (size > 1) {
        i2c_master_read(cmd, data_rd, size - 1, ACK_VAL);
    }
    i2c_master_read_byte(cmd, data_rd + size - 1, NACK_VAL);
    i2c_master_stop(cmd);
    esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
    i2c_cmd_link_delete(cmd);
    return ret;
}
my code:

Code: Select all

uint16_t getRegister(uint8_t reg) {
    uint16_t result;
	uint8_t h = 0;
	uint8_t l = 0;
	// Действуем по алгоритму, описанному в документации ESP-IDF
	i2c_cmd_handle_t cmd = i2c_cmd_link_create();
	i2c_master_start(cmd);
	i2c_master_write_byte(cmd, (RDA5807M_I2C_ADDR_RANDOM | WRITE_BIT), ACK_CHECK_EN);
	//i2c_master_write_byte(cmd, 0b00100010, ACK_CHECK_EN);
	i2c_master_write_byte(cmd, reg, ACK_CHECK_EN);
	i2c_master_stop(cmd);
	i2c_master_start(cmd);
	i2c_master_write_byte(cmd, (RDA5807M_I2C_ADDR_RANDOM | READ_BIT), ACK_CHECK_EN);
	//i2c_master_write_byte(cmd, 0b00100011, ACK_CHECK_EN);
	i2c_master_read_byte(cmd, h, ACK_VAL);
	i2c_master_read_byte(cmd, l, NACK_VAL);
	i2c_master_stop(cmd);
	esp_err_t ret = i2c_master_cmd_begin(i2c_port_num, cmd, 500 / portTICK_RATE_MS);
	i2c_cmd_link_delete(cmd);
	
	// Складываем два байта в слово и выдаем
	result = (uint16_t)h << 8;
	result |= l;
    return result;
};
What do I do wrong?

dmitrij999
Posts: 64
Joined: Sat Mar 02, 2019 8:06 pm

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby dmitrij999 » Sat Mar 09, 2019 3:42 pm

I did some changes in getRegister function. Its code:

Code: Select all

uint16_t getRegister(uint8_t reg) {
    uint16_t result;
	uint8_t h = 0;
	uint8_t l = 0;
	esp_err_t ret;
	ESP_LOGI(FM_TAG, "I2C number: %d", i2c_port_num);
	//vTaskDelay(500 / portTICK_RATE_MS);
	// Действуем по алгоритму, описанному в документации ESP-IDF
	i2c_cmd_handle_t cmd = i2c_cmd_link_create();
	i2c_master_start(cmd);
	i2c_master_write_byte(cmd, (RDA5807M_I2C_ADDR_RANDOM | WRITE_BIT), ACK_CHECK_EN);
	//i2c_master_write_byte(cmd, 0b00100010, ACK_CHECK_EN);
	i2c_master_write_byte(cmd, reg, ACK_CHECK_EN);
	//i2c_master_stop(cmd);
	//ret = i2c_master_cmd_begin(i2c_port_num, cmd, 500 / portTICK_RATE_MS);
	//i2c_cmd_link_delete(cmd);
	//vTaskDelay(30 / portTICK_RATE_MS);
	//ESP_LOGI(FM_TAG, "Write result: %d", ret);
	//cmd = i2c_cmd_link_create();
	i2c_master_start(cmd);
	i2c_master_write_byte(cmd, (RDA5807M_I2C_ADDR_RANDOM | READ_BIT), ACK_CHECK_EN);
	//i2c_master_write_byte(cmd, 0b00100011, ACK_CHECK_EN);
	i2c_master_read_byte(cmd, h, ACK_VAL);
	i2c_master_read_byte(cmd, l, NACK_VAL);
	i2c_master_stop(cmd);
	ret = i2c_master_cmd_begin(i2c_port_num, cmd, 500 / portTICK_RATE_MS);
	i2c_cmd_link_delete(cmd);
	vTaskDelay(1000 / portTICK_RATE_MS);
	ESP_LOGI(FM_TAG, "Read result: %d, H: %d, L: %d", ret, h, l);
	// Складываем два байта в слово и выдаем
	result = (uint16_t)h << 8;
	result |= l;
    return result;
};
I supposed that it prints I2C number, writes address and register, and gets data, and prints result. But result is:

Code: Select all

E (31321) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c null
 address error
E (31321) i2c: C:/msys32/home/dmitr/esp/esp-idf/components/driver/i2c.c:1077 (i2c_master_read_byte):i2c null
 address error
I (32331) FM: Read result: 263, H: 0, L: 0
I (32331) BT_AV: FM RSSI = 0
I (32831) FM: I2C number: 0


asweeney
Posts: 4
Joined: Wed Dec 05, 2018 12:52 pm

Re: RDA5807M gets i2c commands but ESP32 cannot read (i2c null address error)

Postby asweeney » Mon Sep 16, 2019 12:02 pm

Read needs to be called like this:

Code: Select all

i2c_master_read_byte(cmd, &h, ACK_VAL);

Who is online

Users browsing this forum: No registered users and 123 guests