cancel
Showing results for 
Search instead for 
Did you mean: 

ADC with DMA and LwIP TCP: Interrupt Conflicts

DaniBros
Associate II

Hi everyone.
I am developing an application on STM32H723ZGT6, I am trying to connect LwIP with ADC at DMA and also an SPI.
So these three things are my main componenets that I am running on FreeRTOS.
1: At SPI I want to transmit multiple commands at 60kB/s and These commands are different and I need to toggle multiple pins after sending each command to get updated response. Thats why I am running a task at 100000 ticks per second.
2: I am fetching the response of sensor on ADC so that means I have to run ADC as faster as possible. For that reason I am driving my ADC at DMA. 
3: Similarly I have to send this response on Ethernet using TCP protocol So I am running LwIP stack on third task that create TCP port bind and transmit and receive Data.
Currently, I'm encountering an issue where the SPI runs smoothly without DMA enabled. However, as soon as I enable ADC with DMA, the system halts.

Interestingly, disabling DMA interrupts allows both components to function smoothly. However, whenever I connect or disconnect the LwIP Ethernet port, the DMA stops working altogether

Following is the implementation of CubeMX.
This is NVIC Table of my current imlpementation.

NVIC Table.png

 Following is ADC NVIC Part

NVIC Table 2.png

 These are the task configuration of my implementation.

Task Priorities.png

 

Any help regarding this issue will be appreciated.

5 REPLIES 5
TDK
Guru

> Currently, I'm encountering an issue where the SPI runs smoothly without DMA enabled. However, as soon as I enable ADC with DMA, the system halts.

Sounds like your ADC-based DMA interrupts are happening too often. How often are they occurring? Perhaps slow down the sample rate and/or use a larger buffer size.

If you feel a post has answered your question, please click "Accept as Solution".
DaniBros
Associate II

@TDK Thank you for your response. I've increased the buffer size to 10 and extended the sampling time from 2.5 cycles to 12.5 cycles. My ADC clock is running at 48MHz, and I'm using a prescaler of 1. However, even after increasing the buffer size, only 4 out of 10 indexes are consistently being filled, while the other indexes are being ignored most of the time.
Additionally, when a TCP client connects to the board, the DMA transfer halts, although upon checking the ADC data register (DR), it continues to provide values continuously.

 

Slow them down even more. By a factor of 100.

If you feel a post has answered your question, please click "Accept as Solution".

I have increase sampling time from 12.5 to 245 ticks but still the updating response of buffer is very slow while Data register is still updating at normal speed.
This only happens when I connect the client to my TCP server (STM32).

Sounds like your chip is just not as fast as you want it to be with the code that you have.

This is going to be a code issue/solution. You can give ADC processing a higher priority if you want it to run more often than the TCP code, perhaps process within the interrupt if it's high priority and quick enough. But there is no magic solution to running two codes at once. It sounds like this is an RTOS project. Context switching will have a cost, and keep in mind only one thing runs at a given time.

Hard to give more specific advice without seeing the code you're using.

If you feel a post has answered your question, please click "Accept as Solution".