2016-07-25 02:29 PM
Hi,
I am trying to stream a 1024 sample buffer to PWM in timer1 channel1 using circular DMA. But how will I control the speed of streaming from RAM to PWM at 44KHz? I couldn't find any option like triggering option like how we do in DAC over DMA and ADC over DMA. Is it possible to do the same way for PWM from RAM over DMA with every sample triggered by timer ?2016-07-25 03:40 PM
Seems like a Cross-Post/Duplicate, please don't do that, at the least cite the original post
The hardware is capable of doing this, you might have to play games with clock sources to hit specific frequencies. ie 72 MHz is not divisible by 44100 Hz with an integer.Can't help you with HAL issues, ask some of the protagonists for it.2016-07-26 01:56 AM
Reading from ADC via DMA is having timer trigger method so that the reading speed/rate can be controlled.
Same thing for writing from BUFFER to DAC via DMA. This is also having triggering mechanism. But I couldn't find any such option to control the rate of throwing data from buffer to PWM via DMA. But there is an API ''HAL_TIM_PWM_Start_DMA'' but I am confused how this is going to work without controlling the rate of transfer in case of a buffer transfer. Is it possible?2016-07-26 04:49 AM
Is it possible?
The problem is a software one, either it can work as provided, or you add/fix to get it to behave as desired.For audio, I'd use the same trigger for both ADC and DAC. For DMA you'd likely want a double buffer, although splitting a single buffer ping/pong style might also be viable.2016-07-26 07:36 AM
''either it can work as provided, or you add/fix to get it to behave as desired''
I couldn't understand this. :) Like how we do timer triggered DAC from buffer (let it be double or single buffer or what ever) to DAC peripheral, is there any way to do timer triggered PWM from buffer to PWM peripheral? This is what I means by ''is it possible'' because I couldn't find a way to trigger it. So in short, I would like to know if the hardware supports this feature or not.
2016-07-26 09:00 AM
I couldn't understand this. :)
It's software and you have control over ALL the source. How well you understand it, and how much you are willing to fix, change or adapt is something you have to own.You get to choose and write the software, I've already told you I think the HW is capable of the general task you have described in your threads.The DMA services the requests it gets.The ADC and DAC can be triggered by the same or different TIM.I like things which are a) Synchronous, and b) do not involve copying of data when it can be used in-place.
2016-07-27 12:42 AM
Hi Clive1,
I will make my question more clear/specific so that the answer can be either YES or NO. 1>Can we transfer a circular buffer of sine wave from memory to PWM via DMA ?
YES or NO ? (if NO, question ends here)
[ I think YES]
2>If YES, can we control the rate of transfer by any trigger mechanism ?
YES or NO ? [I don't know and I want to know]
----------------------------------------------------------------------------------------
If above answer is NO, then I can think of alternate methods in software.
From: clive1Posted: Tuesday, July 26, 2016 6:00 PMSubject: HAL_TIM_PWM_Start_DMA triggering with timer
I couldn't understand this. :)
It's software and you have control over ALL the source. How well you understand it, and how much you are willing to fix, change or adapt is something you have to own. You get to choose and write the software, I've already told you I think the HW is capable of the general task you have described in your threads. The DMA services the requests it gets. The ADC and DAC can be triggered by the same or different TIM. I like things which are a) Synchronous, and b) do not involve copying of data when it can be used in-place.
2016-07-27 01:23 AM
1 Yes, DMA may be performed to TIM ARR or CRRx registers, or those of the DAC. This may be triggered by those peripheral, or other sources.
2 Yes, DMA can be triggered by the specific TIM Update or CC, a TIM slaved to the original TIM, or one operating independently. The Reference Manual describes the associations. I'm not sure a simple yes/no answer explains anything. The simple answer was already that the HW was capable of these things, but that wasn't sufficient, twice.