2011-03-16 10:02 AM
Waveplayer with STM3210E-Eval
2011-05-17 05:28 AM
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);
2011-05-17 05:28 AM
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 Achim2011-05-17 05:28 AM
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 {..
2011-05-17 05:28 AM
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