将原子哥 USB声实验中的PWM输出换成DAC输出后 声音有很大噪声是什么原因,有谁遇到过吗?
改动如下代码
void TIM7_IRQHandler(void)
{
if (TIM_GetITStatus(TIM7, TIM_IT_Update) != RESET)
{
LED1=!LED1;
if ((Out_Data_Offset < In_Data_Offset) && ((u8)(MUTE_DATA) == 0))
{
//TIM4->CCR1=Stream_Buff[Out_Data_Offset]; //¸Ä±ä
WM DACμÄÖμ
DAC_SetChannel1Data(DAC_Align_8b_R, Stream_Buff[Out_Data_Offset]);
Out_Data_Offset++;
}
}
TIM_ClearITPendingBit(TIM7, TIM_IT_Update );
}
在工程中添加 void Dac1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
DAC_InitTypeDef DAC_InitType;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE ); //ê1ÄüPORTAí¨μàê±Öó
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE ); //ê1ÄüDACí¨μàê±Öó
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; // ¶Ë¿úÅäÖÃ
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //Ä£Äaêäèë
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_4) ;//PA.4 êä3ö¸ß
DAC_InitType.DAC_Trigger=DAC_Trigger_None;
DAC_InitType.DAC_WaveGeneration=DAC_WaveGeneration_None;
DAC_InitType.DAC_LFSRUnmask_TriangleAmplitude=DAC_LFSRUnmask_Bit0;
DAC_InitType.DAC_OutputBuffer=DAC_OutputBuffer_Disable ;
DAC_Init(DAC_Channel_1,&DAC_InitType);
DAC_Cmd(DAC_Channel_1, ENABLE); //ê1ÄüDAC1
DAC_SetChannel1Data(DAC_Align_8b_R, 0);
}
一周热门 更多>