cancel
Showing results for 
Search instead for 
Did you mean: 

Low Layer DMA DAC does not start

GIkar
Associate III

Hello,

i try for moths to get a wave file from SD to the DAC.

I the ST LL_DAC_ADC_project description stands.

#############################################

 LL_DAC_EnableDMAReq(DAC1, LL_DAC_CHANNEL_1); // enable DMA for Channel1

 LL_DAC_Enable(DAC1, LL_DAC_CHANNEL_1); //enable Channel on DAC

 LL_DMA_ConfigAddresses(DMA1, LL_DMA_CHANNEL_7 , (uint32_t)dacbuf, LL_DAC_DMA_GetRegAddr(DAC1, LL_DAC_CHANNEL_1, LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED ), LL_DMA_DIRECTION_MEMORY_TO_PERIPH );

 LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_7, DACBUFSIZE );

 LL_DMA_EnableDoubleBufferMode(DMA1, LL_DMA_CHANNEL_7);

 LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_7); // This command is not existing

#############################################

I try it on my own with this startup

#############################################

 LL_DAC_EnableDMAReq(DAC1, LL_DAC_CHANNEL_1); // enable DMA for Channel1

 LL_DAC_Enable(DAC1, LL_DAC_CHANNEL_1); //enable Channel on DAC

 LL_DMA_ConfigAddresses(DMA1, LL_DMA_STREAM_5 , (uint32_t)&DAC_Buff, LL_DAC_DMA_GetRegAddr(DAC1, LL_DAC_CHANNEL_1, LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED ), LL_DMA_DIRECTION_MEMORY_TO_PERIPH );

 LL_DMA_SetDataLength(DMA1, LL_DMA_STREAM_5, DACBUFSIZE );

 LL_DMA_EnableStream(DMA1, LL_DMA_STREAM_5); 

 LL_DMA_EnableIT_HT(DMA1, LL_DMA_STREAM_5);

 LL_DMA_EnableIT_TC(DMA1, LL_DMA_STREAM_5 );

#############################################

It compiles correct but in my function the interrupt never happens

char wave_playback(const char *FileName)

{

 FRESULT res;                            

 FIL file;                                  

 UINT cnt;                                 

 res = f_open( &file, FileName, FA_READ );  

 if(res) return 1;

 res = f_lseek(&file,0x2c);                 

 if(res) return 2;

 f_read (&file,&DAC_Buff[0],512,&cnt);     

 if(res) return 3;

 TIM6->CR1 |= TIM_CR1_CEN;                  

 while(1)

 {

       volatile ITStatus it_st;  

       it_st = RESET;

   while(it_st == RESET) {  

   it_st =   LL_DMA_IsActiveFlag_HT5(DMA1);       

   }

   f_read (&file,&DAC_Buff[0],256,&cnt);  

   LL_DMA_ClearFlag_HT5(DMA1);

   //DMA_ClearFlag(DMA1_Stream5, DMA_FLAG_HTIF5);

   //ToDo clear all flags in the DMA_LIFCR and DMA_HIFCR registers before starting a new transfer

    if(cnt<256)break;                     

    it_st = RESET;

    while(it_st == RESET) {  

    it_st = LL_DMA_IsActiveFlag_TC5(DMA1);

    }

    f_read (&file,&DAC_Buff[256],256,&cnt); 

    LL_DMA_ClearFlag_TC5(DMA1);

    if(cnt<256)break;                

 }

 TIM6->CR1 &= ~TIM_CR1_CEN;   

 f_close(&file);                            

 return 0;                                 

}

Timer Settings are:

####################################################

static void MX_DAC_Init(void)

{

 /* USER CODE BEGIN DAC_Init 0 */

 /* USER CODE END DAC_Init 0 */

 LL_DAC_InitTypeDef DAC_InitStruct = {0};

 LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

 /* Peripheral clock enable */

 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DAC1);

 LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);

 /**DAC GPIO Configuration 

 PA4  ------> DAC_OUT1

 PA5  ------> DAC_OUT2

 */

 GPIO_InitStruct.Pin = LL_GPIO_PIN_4|LL_GPIO_PIN_5;

 GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;

 GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;

 LL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 /* DAC DMA Init */

 /* DAC1 Init */

 LL_DMA_SetChannelSelection(DMA1, LL_DMA_STREAM_5, LL_DMA_CHANNEL_7);

 LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_STREAM_5, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);

 LL_DMA_SetStreamPriorityLevel(DMA1, LL_DMA_STREAM_5, LL_DMA_PRIORITY_LOW);

 LL_DMA_SetMode(DMA1, LL_DMA_STREAM_5, LL_DMA_MODE_CIRCULAR);

 LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_STREAM_5, LL_DMA_PERIPH_NOINCREMENT);

 LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_STREAM_5, LL_DMA_MEMORY_INCREMENT);

 LL_DMA_SetPeriphSize(DMA1, LL_DMA_STREAM_5, LL_DMA_PDATAALIGN_HALFWORD);

 LL_DMA_SetMemorySize(DMA1, LL_DMA_STREAM_5, LL_DMA_MDATAALIGN_HALFWORD);

 LL_DMA_DisableFifoMode(DMA1, LL_DMA_STREAM_5);

 /* DAC2 Init */

 LL_DMA_SetChannelSelection(DMA1, LL_DMA_STREAM_6, LL_DMA_CHANNEL_7);

 LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_STREAM_6, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);

 LL_DMA_SetStreamPriorityLevel(DMA1, LL_DMA_STREAM_6, LL_DMA_PRIORITY_LOW);

 LL_DMA_SetMode(DMA1, LL_DMA_STREAM_6, LL_DMA_MODE_CIRCULAR);

 LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_STREAM_6, LL_DMA_PERIPH_NOINCREMENT);

 LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_STREAM_6, LL_DMA_MEMORY_INCREMENT);

 LL_DMA_SetPeriphSize(DMA1, LL_DMA_STREAM_6, LL_DMA_PDATAALIGN_HALFWORD);

 LL_DMA_SetMemorySize(DMA1, LL_DMA_STREAM_6, LL_DMA_MDATAALIGN_HALFWORD);

 LL_DMA_DisableFifoMode(DMA1, LL_DMA_STREAM_6);

 /* USER CODE BEGIN DAC_Init 1 */

 // LL_DMA_SetMemory1Address(DMA1, LL_DMA_STREAM_5, (uint32_t)&DAC_Buff);

 //LL_DMA_SetPeriphAddress(DMA1, LL_DMA_STREAM_5, (uint32_t)(DAC_BASE + 0x10));

 /* USER CODE END DAC_Init 1 */

 /** DAC channel OUT1 config

 */

 DAC_InitStruct.TriggerSource = LL_DAC_TRIG_EXT_TIM6_TRGO;

 DAC_InitStruct.WaveAutoGeneration = LL_DAC_WAVE_AUTO_GENERATION_NONE;

 DAC_InitStruct.OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE;

 LL_DAC_Init(DAC, LL_DAC_CHANNEL_1, &DAC_InitStruct);

 /** DAC channel OUT2 config

 */

 LL_DAC_Init(DAC, LL_DAC_CHANNEL_2, &DAC_InitStruct);

 /* USER CODE BEGIN DAC_Init 2 */

 /* USER CODE END DAC_Init 2 */

}

####################################################

Does anybody knows what to do because I am coplitly lost at this point.

1 REPLY 1
Digimorf
Associate III

Hello,

this post is a bit old, so in case you haven't solved yet, you missed the TRIG enabler:

LL_DAC_EnableTrigger(DAC, LL_DAC_CHANNEL_1);
LL_DAC_EnableTrigger(DAC, LL_DAC_CHANNEL_2);

I hope tihs help.