Skip to content

Commit 2d4298d

Browse files
committed
adc: reduce latency
1 parent c5a5f1e commit 2d4298d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Firmware/FFBoard/Src/cppmain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ unsigned long getRunTimeCounterValue(void){
130130
return micros();
131131
}
132132

133-
#else
133+
#else // For HW_ESP32S2
134134
static const char *TAG = "cppmain";
135135
void cppmain()
136136
{
@@ -164,7 +164,7 @@ void cppmain()
164164
updateLeds();
165165
//external_spi.process();
166166
// taskYIELD(); // Change task if higher priority task wants to run
167-
vTaskDelay(pdMS_TO_TICKS(10));
167+
vTaskDelay(1);
168168
// ESP_LOGI(TAG, "run");
169169
}
170170
}

Firmware/Targets/ESP32S2/main/glue.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static void continuous_adc_init(uint16_t adc1_chan_mask, uint16_t adc2_chan_mask
404404
{
405405
#define GET_UNIT(x) ((x>>3) & 0x1)
406406
adc_digi_init_config_t adc_dma_config = {
407-
.max_store_buf_size = 1024,
407+
.max_store_buf_size = channel_num * 4 * 2,
408408
.conv_num_each_intr = channel_num * 4 * 2,
409409
.adc1_chan_mask = adc1_chan_mask,
410410
.adc2_chan_mask = adc2_chan_mask,
@@ -413,8 +413,8 @@ static void continuous_adc_init(uint16_t adc1_chan_mask, uint16_t adc2_chan_mask
413413

414414
adc_digi_configuration_t dig_cfg = {
415415
.conv_limit_en = 0,
416-
.conv_limit_num = 250,
417-
.sample_freq_hz = 2 * 1000,
416+
.conv_limit_num = adc_dma_config.conv_num_each_intr,
417+
.sample_freq_hz = 1 * 1000,
418418
.conv_mode = ADC_CONV_SINGLE_UNIT_1,
419419
.format = ADC_DIGI_OUTPUT_FORMAT_TYPE1,
420420
};
@@ -452,7 +452,9 @@ HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, ui
452452
// while (1)
453453
// {
454454
// uint8_t c=0;
455-
// getAnalogBuffer(NULL, &c);
455+
// uint32_t *p = getAnalogBuffer(NULL, &c);
456+
// ESP_LOGI(TAG, "%d, %d, %d", p[0], p[1], p[2]);
457+
// vTaskDelay(10);
456458
// }
457459

458460
return HAL_OK;

0 commit comments

Comments
 (0)