cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to move data from a text file into the DMA. (in CubeIDE)

PPowe.1
Associate II

I have a text file full of values that I want to send to the DAC via the DMA. Is it possible to get the data through the DMA? I have tried opening the file using fopen and reading in the data to an array, and then passing the array to the DMA, but have encountered issues (not sure if it's because I'm using the IDE, but I keep getting a NULL pointer).

If this isn't possible, what would be the best way to get the values to the DAC?

6 REPLIES 6

Well the DAC of the not-specified-STM32 is not going to accept ASCII text in any form

You'd need to process the data into 16-bit words (HALF WORD), in a buffer, and use DMA+TIM+DAC to pace their output from the buffer.

For dual DAC you'd need to interleave pairs of 16-bits words and read/write the 32-bit values from the array into a common DAC register.

fopen() implies some OS support. Most STM32 related stuff you'll need FATFS tied to an SDIO/SDMMC device or USB MSC Host

That would likely use f_open(), f_read(), etc.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

Take it one step at a time. First try to load data from a file and make sure you understand that. Then try to use the DAC and make sure that's working. Then add DMA to the DAC. Then tie it all together.

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

So, I know how to load data from a file in C-code when it's not within the CubeIDE (I'm assuming there are permission errors that are preventing me from opening my file, which I can figure out on my end). I also know how to send values from an array to the DAC via the DMA. I am currently trying to tie it all together and that's where my issue lies. The goal of this project is to generate a ramp using the DAC based on values generated in a text file. I was told that I should be able to read in the values through the DMA and then pass them through to the DAC so as to avoid taking up CPU processing. However, I want to make sure that this 'direct' method of reading in values from a text file to an array and then to the DAC via the DMA is viable or even the most efficient way to do so.

My apologies, the board I am using is an H743ZI2.

Where "is" this file?

You can't open a file on the host system, and I'm pretty sure you don't have semi-hosting done in a way that would work.

On a NUCLEO-H743ZI2 you'd likely need to attach an SD card socket to the SDMMC, and implement SDMMC + FATFS

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

The file exists on my computers hard drive.

I've started looking into using an SD card and it looks promising. Thank-you!