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

ADC continuous_read example does not work with EXAMPLE_READ_LEN = 4096 (IDFGH-10109) #11385

Closed
3 tasks done
xing-w opened this issue May 11, 2023 · 1 comment
Closed
3 tasks done
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@xing-w
Copy link

xing-w commented May 11, 2023

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.2-dev-503-g17451f1fb3

Operating System used.

Windows

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

PowerShell

Development Kit.

ESP32S3

Power Supply used.

USB

What is the expected behavior?

With EXAMPLE_READ_LEN = 256, it prints out ADC values from two channels. Similar to the following one:
image

What is the actual behavior?

With EXAMPLE_READ_LEN = 4096 (or larger), it doesn't print out any ADC values.
image

Steps to reproduce.

  1. Go to folder exp-idf\exmaples\peripherals\adc\continuous_read\main\continuous_read_main.c
  2. Change line 33 to #define EXAMPLE_READ_LEN 4096
  3. Change line 59 to .max_store_buf_size = EXAMPLE_READ_LEN *2, (.max_store_buf_size can be any value larger than .conv_frame_size. Here just use EXAMPLE_READ_LEN *2 for example).
  4. Change line 92 and 93 to uint8_t* result =malloc(EXAMPLE_READ_LEN); ( memset initialization doesn't work with such big number)
  5. idf.py build
  6. Flash & monitor

Debug Logs.

PS C:\esp\esp-idf\examples\peripherals\adc\continuous_read> idf.py -p COM4 -b 115200 monitor
Executing action: monitor
Running idf_monitor in directory C:\esp\esp-idf\examples\peripherals\adc\continuous_read
Executing "C:\esp\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe C:\esp\esp-idf\tools/idf_monitor.py -p COM4 -b 115200 --toolchain-prefix xtensa-esp32s3-elf- --target esp32s3 C:\esp\esp-idf\examples\peripherals\adc\continuous_read\build\continuous_read.elf --force-color -m 'C:\esp\Espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe' 'C:\esp\esp-idf\tools\idf.py' '-p' 'COM4' '-b' '115200'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM4 instead...
--- idf_monitor on \\.\COM4 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0xb (SPI_FAST_FLASH_BOOT)
Saved PC:0x403785fa
0x403785fa: esp_cpu_wait_for_intr at C:/esp/esp-idf/components/esp_hw_support/cpu.c:121

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x16f4
load:0x403c9700,len:0x4
load:0x403c9704,len:0xbfc
load:0x403cc700,len:0x2efc
entry 0x403c9904
I (18) boot: ESP-IDF v5.2-dev-503-g17451f1fb3 2nd stage bootloader
I (18) boot: compile time May 10 2023 14:06:08
I (19) boot: Multicore bootloader
I (23) boot: chip revision: v0.1
I (27) boot.esp32s3: Boot SPI Speed : 80MHz
I (32) boot.esp32s3: SPI Mode       : DIO
I (36) boot.esp32s3: SPI Flash Size : 16MB
I (41) boot: Enabling RNG early entropy source...
I (47) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (65) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00100000
I (80) boot: End of partition table
I (84) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0b964h ( 47460) map
I (101) esp_image: segment 1: paddr=0001b98c vaddr=3fc92400 size=02930h ( 10544) load
I (104) esp_image: segment 2: paddr=0001e2c4 vaddr=40374000 size=01d54h (  7508) load
I (111) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=1b548h (111944) map
I (138) esp_image: segment 4: paddr=0003b570 vaddr=40375d54 size=0c60ch ( 50700) load
I (155) boot: Loaded app from partition at offset 0x10000
I (156) boot: Disabling RNG early entropy source...
I (167) cpu_start: Multicore app
I (167) cpu_start: Pro cpu up.
I (167) cpu_start: Starting app cpu, entry point is 0x4037536c
0x4037536c: call_start_cpu1 at C:/esp/esp-idf/components/esp_system/port/cpu_start.c:154

I (0) cpu_start: App cpu up.
I (186) cpu_start: Pro cpu start user code
I (186) cpu_start: cpu freq: 160000000 Hz
I (186) cpu_start: Application information:
I (189) cpu_start: Project name:     continuous_read
I (194) cpu_start: App version:      v5.2-dev-503-g17451f1fb3
I (201) cpu_start: Compile time:     May 10 2023 14:05:15
I (207) cpu_start: ELF file SHA256:  a43ee340b980e823...
I (213) cpu_start: ESP-IDF:          v5.2-dev-503-g17451f1fb3
I (219) cpu_start: Min chip rev:     v0.0
I (224) cpu_start: Max chip rev:     v0.99
I (229) cpu_start: Chip rev:         v0.1
I (234) heap_init: Initializing. RAM available for dynamic allocation:
I (241) heap_init: At 3FC955B0 len 00054160 (336 KiB): DRAM
I (247) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
I (254) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (260) heap_init: At 600FE010 len 00001FF0 (7 KiB): RTCRAM
I (267) spi_flash: detected chip: winbond
I (271) spi_flash: flash io: dio
I (275) sleep: Configure to isolate all GPIO pins in sleep state
I (282) sleep: Enable automatic switching of GPIO sleep configuration
I (289) app_start: Starting scheduler on CPU0
I (294) app_start: Starting scheduler on CPU1
I (294) main_task: Started on CPU0
I (304) main_task: Calling app_main()
I (304) EXAMPLE: adc_pattern[0].atten is :0
I (314) EXAMPLE: adc_pattern[0].channel is :2
I (314) EXAMPLE: adc_pattern[0].unit is :0
I (324) EXAMPLE: adc_pattern[1].atten is :0
I (324) EXAMPLE: adc_pattern[1].channel is :3
I (334) EXAMPLE: adc_pattern[1].unit is :0
I (334) gpio: GPIO[3]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (344) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0

More Information.

Here are the diff summary:

diff --git a/examples/peripherals/adc/continuous_read/main/continuous_read_main.c b/examples/peripherals/adc/continuous_read/main/continuous_read_main.c
index dfbdc84a63..2c0da8b005 100644
--- a/examples/peripherals/adc/continuous_read/main/continuous_read_main.c
+++ b/examples/peripherals/adc/continuous_read/main/continuous_read_main.c
@@ -30,7 +30,7 @@
 #define EXAMPLE_ADC_GET_DATA(p_data)        ((p_data)->type2.data)
 #endif

-#define EXAMPLE_READ_LEN                    256
+#define EXAMPLE_READ_LEN                    4096

 #if CONFIG_IDF_TARGET_ESP32
 static adc_channel_t channel[2] = {ADC_CHANNEL_6, ADC_CHANNEL_7};
@@ -56,7 +56,7 @@ static void continuous_adc_init(adc_channel_t *channel, uint8_t channel_num, adc
     adc_continuous_handle_t handle = NULL;

     adc_continuous_handle_cfg_t adc_config = {
-        .max_store_buf_size = 1024,
+        .max_store_buf_size = EXAMPLE_READ_LEN *2,
         .conv_frame_size = EXAMPLE_READ_LEN,
     };
     ESP_ERROR_CHECK(adc_continuous_new_handle(&adc_config, &handle));
@@ -89,8 +89,8 @@ void app_main(void)
 {
     esp_err_t ret;
     uint32_t ret_num = 0;
-    uint8_t result[EXAMPLE_READ_LEN] = {0};
-    memset(result, 0xcc, EXAMPLE_READ_LEN);
+    // uint8_t result[EXAMPLE_READ_LEN] = {0};
+    uint8_t* result =malloc(EXAMPLE_READ_LEN);

     s_task_handle = xTaskGetCurrentTaskHandle();

@xing-w xing-w added the Type: Bug bugs in IDF label May 11, 2023
@github-actions github-actions bot changed the title ADC continuous_read example does not work with EXAMPLE_READ_LEN = 4096 ADC continuous_read example does not work with EXAMPLE_READ_LEN = 4096 (IDFGH-10109) May 11, 2023
@espressif-bot espressif-bot added Status: Opened Issue is new Status: In Progress Work is in progress and removed Status: Opened Issue is new labels May 11, 2023
@Icarus113
Copy link
Collaborator

Icarus113 commented May 15, 2023

@xing-w Thanks for the report and the reproduce steps. This can be reproduced locally, will let you know the progress.

(If you want a temp workaround, simply set the conv_frame_size to a value which is equal or smaller than 4092)

@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed labels May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants