Skip to main content
ALevc.1
Associate III
May 12, 2020
Solved

BSP_AUDIO_OUT_Play ends up in Default_Handler

  • May 12, 2020
  • 2 replies
  • 1163 views

Hello,

I try to play a sound using stm32h747i_discovery_audio.c. Initialization goes well

void CAudioController::AudioOutInit()
{
 BSP_AUDIO_Init_t audioOutInit;
 
 if (!audioOutInitDone_)
 {
 audioOutInit.Device = AUDIO_OUT_DEVICE_HEADPHONE;
 audioOutInit.ChannelsNbr = 2;
 audioOutInit.SampleRate = AUDIO_FREQUENCY_44K;
 audioOutInit.BitsPerSample = AUDIO_RESOLUTION_16B;
 audioOutInit.Volume = 50;
 if (BSP_AUDIO_OUT_Init(0, &audioOutInit)!=BSP_ERROR_NONE)
 {
 while(1);
 }
 audioOutInitDone_ = true;
 }
}

But first call BSP_AUDIO_OUT_Play call

BSP_AUDIO_OUT_Play(0,playBuf,1024);

ends up in the default handler. It is a bit strange but while debugging the program jumps to the default handler either from

HAL_DMA_Start_IT

call or from

__HAL_SAI_ENABLE_IT(hsai, SAI_InterruptFlag(hsai, SAI_MODE_DMA));

inside BSP_AUDIO_OUT_Play().

The BSP_AUDIO_OUT_Init() initializes Sai and DMA.

Does anybody have a hint in which direction to look for the root cause?

Best Regards,

Anton

This topic has been closed for replies.
Best answer by TDK

Read the VECTACTIVE bits to determine which IRQ it wants to be in. Subtract 16 from that value to find the IRQn_Type. Chances are that IRQ is not implemented and is defaulting to Default_Handler.

IRQn_Type irq_handler = (IRQn_Type) ((SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) - 16);

2 replies

TDK
TDKBest answer
May 13, 2020

Read the VECTACTIVE bits to determine which IRQ it wants to be in. Subtract 16 from that value to find the IRQn_Type. Chances are that IRQ is not implemented and is defaulting to Default_Handler.

IRQn_Type irq_handler = (IRQn_Type) ((SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk) - 16);

"If you feel a post has answered your question, please click ""Accept as Solution""."
ALevc.1
ALevc.1Author
Associate III
May 13, 2020

Thanks for the hint! I saw that it was DMA2_Stream1 interrupt. I didn't really know what to do with it and just forwarded to the bsp audio handler. Surprisingly it worked. If any other stm newbie has the same problem here is the solution:

void DMA2_Stream1_IRQHandler(void)
{
 
 BSP_AUDIO_OUT_IRQHandler(0);
 
}