cancel
Showing results for 
Search instead for 
Did you mean: 

Waveplayer with STM3210E-Eval

elgerta
Associate II
Posted on March 16, 2011 at 18:02

Waveplayer with STM3210E-Eval

4 REPLIES 4
Posted on May 17, 2011 at 14:28

Maybe someone has an idea which point I've looked over.

 

Attached the important files which are changed.

 

Unless I missed it, you have no time base initialization for TIM6

Like the TIM_PrescalerConfig or TIM_TimeBaseInit

  /* TIM6 Configuration */

  TIM_PrescalerConfig(TIM6, 0xF, TIM_PSCReloadMode_Update);

  TIM_SetAutoreload(TIM6, 0xFF);

  /* TIM6 TRGO selection */

  TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);

OR

  /* TIM6 Configuration */

  /* Time base configuration */

  TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);

  TIM_TimeBaseStructure.TIM_Period = 0x19;

  TIM_TimeBaseStructure.TIM_Prescaler = 0x0;

  TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;

  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);

  /* TIM6 TRGO selection */

  TIM_SelectOutputTrigger(TIM6, TIM_TRGOSource_Update);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
elgerta
Associate II
Posted on May 17, 2011 at 14:28

Okay TIM6 is working now with related frequency of the wave file.

But I've still some problem of understanding.

The stm32f10x_it.c has a DMA IRQ handler but seems not enabled.

On the other side, inside the loop while (WaveDataLength) of the functions

WavePlayerMenu_Start() at waveplayer.c, the DMA1_Channel3->CCR will be set with 0x00 and 0x2091 which means channel enable but transfer interrupt is disabled.

And I can't follow the code of TIM6_DAC_IRQHandler().

For me not clear to use only Wavebuffer??

    DAC_SetChannel1Data(DAC_Align_8b_R, Wavebuffer[wavecounter++]);

    if (wavecounter == 511)

    {

      wavecounter = 0;

      DFS_ReadFile(&fiwave, sector, Wavebuffer, &var, SECTOR_SIZE);

    }

Maybe the guy from ST can give some explanations.

Regards

Achim

Posted on May 17, 2011 at 14:28

If it is interrupt driven, you could use Wavebuffer or whatever you want. I'd personally use a ping-pong construct, and get more data in the foreground.

The wavecounter is also wrong.

    DAC_SetChannel1Data(DAC_Align_8b_R, Wavebuffer[wavecounter++]);

    if (wavecounter == 512) // Not 511

    {

..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
elgerta
Associate II
Posted on May 17, 2011 at 14:28

Maybe I'm wrong but the flowchart of the demo shows a sequence like ping-pong with two different buffers which are transfered via DMA.

Due to this I don't understand the code of

void TIM6_DAC_IRQHandler(void)

{

  if (TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET)

  {

    /* Set DAC Channel1 DHR register */

    DAC_SetChannel1Data(DAC_Align_8b_R, Wavebuffer[wavecounter++]);

    if (wavecounter == 511)

    {

      wavecounter = 0;

      DFS_ReadFile(&fiwave, sector, Wavebuffer, &var, SECTOR_SIZE);

    }

 

    /* If we reach the WaveDataLength of the wave to play */

    if (Decrement_WaveDataLength() == 0)

    {

      /* Stop wave playing */

      WavePlayer_Stop();

    }

    /* Clear TIM6 update interrupt */

    TIM_ClearITPendingBit(TIM6, TIM_IT_Update);

  }

}

where the transfer is via a single buffer.

And this in addition of the ping-pong at waveplayer.c

It seems wrong??

Regards

Achim