官方的例子是搬移数据实现的.我看DataSheet说可以自动产生锯齿波,但是用下面的代码完全没有波形输出.要产生锯齿波,需要做哪些事情?
void main(void)
{
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_DAC, ENABLE);
TIM4_TimeBaseInit(TIM4_Prescaler_4,0xFF);
TIM4_SelectOutputTrigger(TIM4_TRGOSource_Update);
TIM4_Cmd(ENABLE);
DAC_Init(DAC_Channel_1,DAC_Trigger_T4_TRGO,DAC_OutputBuffer_Enable);
DAC_WaveGenerationCmd(DAC_Channel_1,DAC_Wave_Triangle,ENABLE);
DAC_SetTriangleWaveAmplitude (DAC_Channel_1,DAC_TriangleAmplitude_1023);
DAC_Cmd(DAC_Channel_1,ENABLE);
/* Infinite loop */
while (1)
{
}
}
|