cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F769I-DISCO ADC and DAC with DMA not working correctly

MTrev.2
Associate II

goodAfternoon,

I am making a TouchGFX project that needs to use the DAC and ADC present on the discovery board using the DMA.

Does the STM32F769I-DISCO TouchGFX code have something that makes so that the DMA doesn't work correctly by default? If so what should I change/add in the TouchGFX code so that the DMA starts working normally?

I made some code in an STM32CubeIDE project and the ADC and DAC work normally.

When I put the same code on the TouchGFX program the ADC callback gives wrong vaiues and the DAC doesn't change value (it has a lookup table of a sinus and is triggered by a timer), I should see a sinus...

If more code is needed just ask, I will gladly write it here if it makes it easier to understand the problem.

Here is the screen that should start the DAC and a screen of part of the MPU settings (generated by touchGFX).

After some tinkering I think the problem is due to the fact that the D-Cache and I-CAche are active and the memory layout with MPU done by TouchGFX. I can't understand how to change the parameters so to make the DMA work correctly with the buffers i create. Did someone had this issue and tried to solve it?

Thankyou for the kind help

-Marco

7 REPLIES 7
TDK
Guru

Make sure sine_val is located in memory accessible by the DMA.

You will also need to clean cache prior to starting the DMA.

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

Hi, thankyou for the reply. 🙂

I checked il the buffer is in a place where the DMA can access it. Its in the SRAM1 address 0x20000180 in the .bss, looking at the system architecture of the board both DMA1 and DMA2 have access to it.

I also tried to turn off both the caches and disable memory protection. Nothing changes. It's still not able to write or read from the buffer.

I also tried to clean and invalidate the cache but it gives no results.

Do you have any other idea on what the issue might be?

If I try to do this in a normal project without freeRTOS and TouchGFX with all the same parameters for the DMA ADC, DAC and trigger event timers everything works as expected....

I will keep trying to search whats the problem but it seems I have tried everything my knowledge can allow.

Ciao @MTrev.2​ , ho avuto lo stesso problema? hai risolto? ti ho mandato un messaggio.

Ciao Riccardo, si ho risolto. Il generatore di codice dall'.ioc di STM inizializzava in modo incorretto il DMA, in particolare mi succedeva che il generatore automatico mettesse l’init del DMA dopo l’init degli ADC il che impediva all’ADC di funzionare correttamente.

Esempio di codice da controllare:

/* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_CRC_Init();
  MX_DSIHOST_DSI_Init();
  MX_LTDC_Init();
  MX_FMC_Init();
  MX_QUADSPI_Init();
  MX_DMA2D_Init();
  MX_I2C4_Init();
  MX_I2C1_Init();
  MX_DMA_Init(); //<--- Posizione che funziona, deve stare prima dell'init degli adc...
  MX_ADC1_Init();
  MX_ADC2_Init();
  MX_ADC3_Init();
   
  MX_DAC_Init();
  MX_TIM8_Init();
  MX_USART1_UART_Init();
  MX_TIM1_Init();
  MX_TIM7_Init();
  //MX_DMA_Init(); // <- Posizione che non funziona...
  MX_TIM5_Init();
  MX_TouchGFX_Init();

fammi sapere se questo è il problema e se te lo dovesse risolvere,

Saluti e un augurio di buona programmazione,

Funziona! incredibile dopo tutte le ore che ho perso a leggere codice 😂 mamma mia grazie!

Hi, I have the same problem, when touch gfx is running, DAC doesn't work!

Can you tell me what should I do?

I need DAC and USART for my project.

Thanks!

The problem was that in the init functions generated by the Cube Ide placed the dma_init after the Dac_init.

Swapping them worked.