ESP32的I2S_ADC_DAC速率不一样
Posted: Fri Jan 21, 2022 3:52 am
IDF版本5.0,硬件ESP32
我在components\driver\i2s.c里增加2个变量
volatile int i2s_rx_count = 0;
volatile int i2s_tx_count = 0;
在static void IRAM_ATTR i2s_intr_handler_default(void *arg)中
在if ((status & I2S_INTR_OUT_EOF) && p_i2s->tx) 中i2s_tx_count++;
在if ((status & I2S_INTR_IN_SUC_EOF) && p_i2s->rx) 中i2s_rx_count++;
然后在examples\peripherals\i2s\i2s_adc_dac的main中注释了xTaskCreate(adc_read_task, "ADC read task", 2048, NULL, 5, NULL);防止该线程影响测试,
在i2s_adc_enable(EXAMPLE_I2S_NUM);后每隔一秒打印一次i2s_tx_count和i2s_rx_count
I (1351) ad/da: i2s_rx_count = 31
I (1351) ad/da: i2s_tx_count = 31
I (2351) ad/da: i2s_rx_count = 62
I (2351) ad/da: i2s_tx_count = 62
I (3351) ad/da: i2s_rx_count = 93
I (3351) ad/da: i2s_tx_count = 94
I (4351) ad/da: i2s_rx_count = 124
I (4351) ad/da: i2s_tx_count = 125
I (5351) ad/da: i2s_rx_count = 155
I (5351) ad/da: i2s_tx_count = 156
I (6351) ad/da: i2s_rx_count = 186
I (6351) ad/da: i2s_tx_count = 187
I (7351) ad/da: i2s_rx_count = 217
I (7351) ad/da: i2s_tx_count = 219
I (8351) ad/da: i2s_rx_count = 248
I (8351) ad/da: i2s_tx_count = 250
I (9351) ad/da: i2s_rx_count = 279
I (9351) ad/da: i2s_tx_count = 281
I (10351) ad/da: i2s_rx_count = 310
I (10351) ad/da: i2s_tx_count = 312
I (11351) ad/da: i2s_rx_count = 341
I (11351) ad/da: i2s_tx_count = 344
I (12351) ad/da: i2s_rx_count = 372
I (12351) ad/da: i2s_tx_count = 375
I (13351) ad/da: i2s_rx_count = 403
I (13351) ad/da: i2s_tx_count = 406
I (14351) ad/da: i2s_rx_count = 434
I (14351) ad/da: i2s_tx_count = 438
I (15351) ad/da: i2s_rx_count = 465
I (15351) ad/da: i2s_tx_count = 469
I (16351) ad/da: i2s_rx_count = 496
I (16351) ad/da: i2s_tx_count = 500
I (17351) ad/da: i2s_rx_count = 527
I (17351) ad/da: i2s_tx_count = 531
I (18351) ad/da: i2s_rx_count = 558
I (18351) ad/da: i2s_tx_count = 563
I (19351) ad/da: i2s_rx_count = 589
I (19351) ad/da: i2s_tx_count = 594
I (20351) ad/da: i2s_rx_count = 620
I (20351) ad/da: i2s_tx_count = 625
I (21351) ad/da: i2s_rx_count = 651
I (21351) ad/da: i2s_tx_count = 657
I (22351) ad/da: i2s_rx_count = 682
I (22351) ad/da: i2s_tx_count = 688
RX和TX的计数差距随时间增加会误差越大,
如果在I2S_basic中测试RX和TX的计数就没有误差,偶尔误差1应该是打印的间隔误差
我在components\driver\i2s.c里增加2个变量
volatile int i2s_rx_count = 0;
volatile int i2s_tx_count = 0;
在static void IRAM_ATTR i2s_intr_handler_default(void *arg)中
在if ((status & I2S_INTR_OUT_EOF) && p_i2s->tx) 中i2s_tx_count++;
在if ((status & I2S_INTR_IN_SUC_EOF) && p_i2s->rx) 中i2s_rx_count++;
然后在examples\peripherals\i2s\i2s_adc_dac的main中注释了xTaskCreate(adc_read_task, "ADC read task", 2048, NULL, 5, NULL);防止该线程影响测试,
在i2s_adc_enable(EXAMPLE_I2S_NUM);后每隔一秒打印一次i2s_tx_count和i2s_rx_count
I (1351) ad/da: i2s_rx_count = 31
I (1351) ad/da: i2s_tx_count = 31
I (2351) ad/da: i2s_rx_count = 62
I (2351) ad/da: i2s_tx_count = 62
I (3351) ad/da: i2s_rx_count = 93
I (3351) ad/da: i2s_tx_count = 94
I (4351) ad/da: i2s_rx_count = 124
I (4351) ad/da: i2s_tx_count = 125
I (5351) ad/da: i2s_rx_count = 155
I (5351) ad/da: i2s_tx_count = 156
I (6351) ad/da: i2s_rx_count = 186
I (6351) ad/da: i2s_tx_count = 187
I (7351) ad/da: i2s_rx_count = 217
I (7351) ad/da: i2s_tx_count = 219
I (8351) ad/da: i2s_rx_count = 248
I (8351) ad/da: i2s_tx_count = 250
I (9351) ad/da: i2s_rx_count = 279
I (9351) ad/da: i2s_tx_count = 281
I (10351) ad/da: i2s_rx_count = 310
I (10351) ad/da: i2s_tx_count = 312
I (11351) ad/da: i2s_rx_count = 341
I (11351) ad/da: i2s_tx_count = 344
I (12351) ad/da: i2s_rx_count = 372
I (12351) ad/da: i2s_tx_count = 375
I (13351) ad/da: i2s_rx_count = 403
I (13351) ad/da: i2s_tx_count = 406
I (14351) ad/da: i2s_rx_count = 434
I (14351) ad/da: i2s_tx_count = 438
I (15351) ad/da: i2s_rx_count = 465
I (15351) ad/da: i2s_tx_count = 469
I (16351) ad/da: i2s_rx_count = 496
I (16351) ad/da: i2s_tx_count = 500
I (17351) ad/da: i2s_rx_count = 527
I (17351) ad/da: i2s_tx_count = 531
I (18351) ad/da: i2s_rx_count = 558
I (18351) ad/da: i2s_tx_count = 563
I (19351) ad/da: i2s_rx_count = 589
I (19351) ad/da: i2s_tx_count = 594
I (20351) ad/da: i2s_rx_count = 620
I (20351) ad/da: i2s_tx_count = 625
I (21351) ad/da: i2s_rx_count = 651
I (21351) ad/da: i2s_tx_count = 657
I (22351) ad/da: i2s_rx_count = 682
I (22351) ad/da: i2s_tx_count = 688
RX和TX的计数差距随时间增加会误差越大,
如果在I2S_basic中测试RX和TX的计数就没有误差,偶尔误差1应该是打印的间隔误差