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

DivByZero in I2S PDM Mode (IDFGH-7261) #8850

Closed
IgorTrud opened this issue Apr 27, 2022 · 1 comment
Closed

DivByZero in I2S PDM Mode (IDFGH-7261) #8850

IgorTrud opened this issue Apr 27, 2022 · 1 comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@IgorTrud
Copy link

Environment

  • Development Kit: [LILIGO-Watch V3]
  • Module or chip used: [ESP32]
  • IDF version ESP-IDF v5.0-dev-2586-ga82e6e63d9
  • Build System: [idf.py]
  • Compiler version [xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0]
  • Operating System: [Linux]
  • Using an IDE?: [No]
  • Power Supply: [USB+Battery]

Problem Description

i2s_set_pdm_rx_down_sample have a bug in clock calculations

int i2s_num = 0; // i2s port number
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_PDM | I2S_MODE_RX,
.sample_rate = 16000,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
.dma_desc_num = 8,
.dma_frame_num = 512, //was: 1024
.use_apll = false,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 // Interrupt level 1, default 0
};

i2s_pin_config_t pin_config = {
.bck_io_num = I2S_PIN_NO_CHANGE,
.ws_io_num = 0,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = 2
};

i2s_driver_install(i2s_num, &i2s_config, 0, NULL); //install and start i2s driver
i2s_set_pin(i2s_num, &pin_config);
i2s_set_clk(I2S_NUM_0, 16000, I2S_BITS_PER_SAMPLE_16BIT, I2S_CHANNEL_MONO);

i2s_set_pdm_rx_down_sample(0,I2S_PDM_DSR_16S); <---- FAILS HERE !!


(2871) I2S: DMA Malloc info, datalen=blocksize=1024, dma_desc_num=8
I (2872) I2S: I2S0, MCLK output by GPIO0
Guru Meditation Error: Core 0 panic'ed (IntegerDivideByZero). Exception was unhandled.

Core 0 register dump:
PC : 0x400fe212 PS : 0x00060830 A0 : 0x800fe3e9 A1 : 0x3ffbd120
0x400fe212: i2s_calculate_pdm_rx_clock at /home/igor/Projects/esp/esp-idf/components/driver/i2s.c:705

A2 : 0x00000000 A3 : 0x3ffbd180 A4 : 0x00060820 A5 : 0x3fffd70a
A6 : 0x7ff00000 A7 : 0x7fcc5f0a A8 : 0x00000000 A9 : 0x3ffd73c4
A10 : 0x00000000 A11 : 0x00060823 A12 : 0x00000000 A13 : 0x3ffbd000
A14 : 0x00000034 A15 : 0x3ffbd000 SAR : 0x0000001b EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x400029ac LEND : 0x400029cb LCOUNT : 0x00000000

Backtrace:0x400fe20f:0x3ffbd1200x400fe3e6:0x3ffbd150 0x400fe460:0x3ffbd180 0x400ff444:0x3ffbd1b0 0x400ff61a:0x3ffbd1e0 0x400da212:0x3ffbd210 0x400d7d82:0x3ffbd2d0 0x4016a947:0x3ffbd350 0x40094641:0x3ffbd370
0x400fe20f: i2s_calculate_pdm_rx_clock at /home/igor/Projects/esp/esp-idf/components/driver/i2s.c:703 (discriminator 1)
0x400fe3e6: i2s_calculate_clock at /home/igor/Projects/esp/esp-idf/components/driver/i2s.c:768
0x400fe460: i2s_set_clock_legacy at /home/igor/Projects/esp/esp-idf/components/driver/i2s.c:1007
0x400ff444: i2s_set_clk at /home/igor/Projects/esp/esp-idf/components/driver/i2s.c:1058 (discriminator 4)
0x400ff61a: i2s_set_pdm_rx_down_sample at /home/igor/Projects/esp/esp-idf/components/driver/i2s.c:1136 (discriminator 2)
0x400da212: audio_start at /home/igor/Projects/esp/espwatch/build/../main/audio.c:333
0x400d7d82: app_main at /home/igor/Projects/esp/espwatch/build/../main/espwatch.c:172

@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 27, 2022
@github-actions github-actions bot changed the title DivByZero in I2S PDM Mode DivByZero in I2S PDM Mode (IDFGH-7261) Apr 27, 2022
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new Resolution: NA Issue resolution is unavailable labels May 24, 2022
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, fix on master branch is available at 94d7ae0, and we will also backport the fix to release/4.4, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

3 participants