stm32f4 DAC DMA interrupt help

455 views
Skip to first unread message

Alex Norman

unread,
Mar 3, 2016, 10:59:57 AM3/3/16
to dorkbotpd...@googlegroups.com
Its been a while since I've worked with an arm, I have a stm32f4 discovery board
and I'm trying to get DMA->DAC half & complete transfer interrupts going so that
I can dynamically load the buffer sent to the DAC [and do synthesis].

I've slopped some code from the internet together here:
https://github.com/x37v/fml/blob/arm/arm/dac.cpp

Which generates a tone DAC1's output [pin A4] via DMA transfers from a buffer,
but I cannot seem to get the half transfer or transfer complete interrupts to
fire [DMA_IT_HT, DMA_IT_TC]. I am getting interrupts, when see what it is,
hitting a breakpoint in DMA1_Stream5_IRQHandler, I seem I'm getting TEIF6 and
DMEIF6 which are stream 6 transfer error and stream 6 direct mode error flags
respectively. I'm not sure why I'm getting stream 6 errors there but.. I'm
kinda flailing right now anyways.

Anyone have any insights they can share?

Thanks,
Alex

signature.asc

Philip Odom

unread,
Mar 3, 2016, 2:43:45 PM3/3/16
to dorkbotpd...@googlegroups.com
I took a quick look. Not sure what the issue is—are you getting output from the DAC, but not interrupts?

Only thing I saw: since you’re using circular mode, you should have M2M disabled:

DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

You don’t have that in your code, and since you’re not zeroing the init structure, there’s a chance it’s set to enable or something invalid. I compared it to some old code I have for playing audio, and your code is very similar minus that.

(or, since it’s c++, I think you could change your declaration to DMA_InitTypeDef DMA_INIT={};)

-Philip

--
You received this message because you are subscribed to the Google Groups "dorkbotpdx-blabber" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dorkbotpdx-blab...@googlegroups.com.
To post to this group, send email to dorkbotpd...@googlegroups.com.
Visit this group at https://groups.google.com/group/dorkbotpdx-blabber.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Alex Norman

unread,
Mar 3, 2016, 4:01:14 PM3/3/16
to dorkbotpd...@googlegroups.com
On 0, Philip Odom <podo...@gmail.com> wrote:
> I took a quick look. Not sure what the issue is—are you getting output from the DAC, but not interrupts?

I do get output and interrupts [those 2 error interrupts] but not the ones I
want :)

>
> Only thing I saw: since you’re using circular mode, you should have M2M disabled:
>
> DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

Alright, I'll check that out when I get home, thanks!!!

>
> You don’t have that in your code, and since you’re not zeroing the init
> structure, there’s a chance it’s set to enable or something invalid. I
> compared it to some old code I have for playing audio, and your code is very
> similar minus that.
>
> (or, since it’s c++, I think you could change your declaration to DMA_InitTypeDef DMA_INIT={};)

Cool, I'll do that too [or zero it out somehow].

-Alex
signature.asc

Alex Norman

unread,
Mar 3, 2016, 8:52:16 PM3/3/16
to dorkbotpd...@googlegroups.com
looks like my DMA_InitStructure doesn't have that DMA_M2M entry.... and zeroing
out the DMA init fields didn't resolve the problem :(

On 0, Philip Odom <podo...@gmail.com> wrote:
signature.asc

Alex Norman

unread,
Mar 29, 2016, 12:36:20 AM3/29/16
to dorkbotpd...@googlegroups.com
Sidelined the project for a bit, turns out I was looking for the wrong flag..

I was testing DMA_IT_HTIF0 and DMA_IT_TCIF0.. working now :

void DMA1_Stream5_IRQHandler(void)
{
/* Test on DMA Stream Half Transfer interrupt */
if (DMA_GetITStatus(DMA1_Stream5, DMA_IT_HTIF5)) {
/* Clear DMA Stream Half Transfer interrupt pending bit */
DMA_ClearITPendingBit(DMA1_Stream5, DMA_IT_HTIF5);
/* Add code to process First Half of Buffer */
}

/* Test on DMA Stream Transfer Complete interrupt */
if (DMA_GetITStatus(DMA1_Stream5, DMA_IT_TCIF5)) {
/* Clear DMA Stream Transfer Complete interrupt
* pending bit */
DMA_ClearITPendingBit(DMA1_Stream5,
DMA_IT_TCIF5);
/* Add code to process Second Half of Buffer
* */
signature.asc
Reply all
Reply to author
Forward
0 new messages