Hello everyone, I failed to collect external AD values in real time with ESP32 SPI slave. If you have relevant experience, any relevant information and suggestions may be helpful. Thank you!
ESP32 is used as SPI slave machine to collect external AD data in real time. Every certain time, the data source is converted and sends an interrupt signal to ESP through DRDY pin. After detecting the interrupt, ESP reads AD value in real time through SPI in time. The output time of AD data is only about 32us, and the interrupt delays the response. When the interrupt function is executed in processing the interrupt, the AD data has been output. If the data cannot be processed in a timely manner, the value of spi_slave_transmit read is 0xFF
Use oscilloscope capture waveform, external AD clock pin and data output pin waveform normal. The oscilloscope checks the waveform and finds that the interrupt response (when spi_slave_transmit is called) lags behind the DRDY external interrupt. For example, normally SPI should be read immediately after ①, but the actual waveform is processed and read SPI after ②. External interrupt According to call spi_slave_transmit collect AD value, oscilloscope check waveform found interrupt response (call spi_slave_transmit) lag DRDY external interrupt, for example, normal should read SPI immediately after ①, the actual waveform is processed after ② interrupt read SPI.
So far I've tried
1 Directly call spi_slave_transmit in the GPIO interrupt function. As a result, panic restarts
2 Create a binary semaphore, read_data_task, and release the semaphore xSemaphoreGiveFromISR(semaphore_handle, &xHigherPriorityTaskWoken) in the interrupt function. Spi_slave_transmit is called after blocking to get signal until it gets signal
3 Create read_datA_task, suspend the current task after reading SPI, and resume the task in xTaskResumeFromISR(xHandle)
How can I modify the code to reduce this lag time?
ESP32 SPI slave,Failed to collect external AD value in real time during interrupt
Who is online
Users browsing this forum: No registered users and 82 guests