2023-10-20 05:53 AM
I wanted to use DAC with DMA with TIM5 being the trigger. my problem is that it does not correctly display the audio,
I mean the original audio is like 10 seconds, I first tried to do the transfer by the CPU so that for every interrupt generated by the TIM5, I wrote a code in the callback function to transfer one byte from audio to DAC. and here is the result waveform:
it was like 11-second audio. but anyways, I think the DAC outputted the audio correctly, but when I made the DMA handle this, here was the result:
it seems like it doesn't wait for any update event from TIM5 but rather keeps changing the DAC output with the next byte from audio as fast as possible and so the result audio is like 1.6 seconds, so any guesses where could the problem be?
I tried to change my TIM5 frequency by changing period, clock division but nothing changes
2023-10-20 06:33 AM
There are examples of using TIM to trigger DMA/DAC in the CubeMX repository. Take a look at those and compare your code.
2023-10-20 11:41 AM
2023-10-21 01:58 PM
This just shows for the millionth time that firmware code cannot be written without reading the reference manual.
As for how to solve it... What would you do, if you had to transfer a terabyte of data? Wait until there is a microcontroller with a terabyte of RAM? And what about a continuous stream? The answer is obvious - you split the data into packets. And you implement a double buffering - while one of the packets is played, the other one is read/processed or otherwise prepared for playback.