2024-01-10 11:15 PM
hi, i m using STM32H7 and have running SPI using interrupt transmittng and receiving from external ADC, now i m contemplating using DMA for SPI transmit and receive, but was not able to get any data reponse from the ADC. could anyone kindly advise any sample code on SPI DMA normal or circular mode? I have code the following functions, what be inside the DMAReceiveCpltDMA callback functions? should i create another callback for DMATxCpltDMA ?
spi_tx(t_data)
spi_rx_tx(data)
DMAReceiveCplt(DMA_HandleTypeDef *hdma)
2024-01-10 11:35 PM - edited 2024-01-10 11:41 PM
Hi,
first set the two dma channels , rx + tx , in Cube as circular , enable callbacks .
then..
HAL_DMA_Init(&hdma_spi1_rx);
HAL_DMA_Init(&hdma_spi1_tx);
fresult = HAL_SPI_Receive_DMA(&hspi1, ESPinbuf , (sizeof(ESPinbuf))); // ESP input-loop start
fresult = HAL_SPI_Transmit_DMA(&hspi1, ....);
Then in callbacks use data & set data ...btw why send data stream to ADC ? is useful ?
2024-01-10 11:44 PM
System requirement for external ADC.. what should i code inside the callback function? anyone sample working code to start with?
2024-01-11 12:04 AM - edited 2024-01-11 12:05 AM
> what should i code inside the callback function?
what you want to do . I dont know what you need to send to the adc... , you didnt tell even which adc,
but in rx half- and full- callbacks you have to use the data block , = copy to an array for FFT or ... I dont know what you want to do .
So "sample working code" for --- what ?
2024-01-11 12:09 AM
for spi_tx function i need to send 0480 hex to ADC, for spi_rx function i need to read back what ADC transmit ...O.. there is another rx half full callback? what should code inside the rx half full? i need an workng sample code on spi dma, cos i m a student using STM for the first time..
2024-01-11 12:23 AM
TI ADC TLV1570
2024-01-11 12:51 AM
ADC TLV1570 -- May i ask, why you connect a 8 channel 1 Msample 10bit adc to a cpu, that has about 20adc channels on 2 or 3 adcs with 12 ...16bit and with > 3 Msample speed ? To learn something ? ( what ??)
>there is another rx half full callback?
Exactly.
Seems, you have no plan, whats going on in the circular dma... or double buffer dma.
Search for circular dma and double buffer dma , read about ... then decide, what you want to do with the data - and then do it.
>i need an workng sample code
look on git - there is almost everything.
2024-01-11 04:59 AM
Hi anyone can advise sample code on SPI DMA using stm32cubeMX not register.
2024-01-11 06:07 AM - edited 2024-01-11 06:08 AM
> Hi anyone can advise sample code on SPI DMA using stm32cubeMX not register.
Use the Example Selector in STM32CubeMX to find SPI DMA examples. They are there.