本帖最后由 lai832 于 2012-6-11 13:08 编辑
while(1)
{
/* Times_Out(0x30);
while(Time_Out_Flag)
{
LED_Main();
Times_Out(0);
}*/
LED_Main();
Head_Main();
// if (x > 10) //加这个,改变更新速度,结果波形的频率变了,,,更新快,频率高
// {
DA_Main();
// x = 0;
Head_Data[2] = DAC_GetDataOutputValue(DAC_Channel_1);;
// }
// x++;
/* if (x == 0)
{
if (y == 100000)
x = 1;
else
y++;
} else
{
if (y == -100000)
x = 0;
else
y--;
}
Head_Data[0] = y / 10;*/
}
void DA_Main(void)
{
DA_Data();
DA_Update_Out();
}
注:DA_Data();有点复杂,
在DA_Update_Out()里直接输出固定值了..
void DA_Update_Out(void)
{
// DAC_SetDualChannelData(DAC_Align_12b_R, DA_Buffer[1],DA_Buffer[0]);
DAC_SetDualChannelData(DAC_Align_12b_R, 2047,2047);
//?????ÒªÑÓʱ·ñ????????????????????????????????????????????????????????????????????
DAC_DualSoftwareTriggerCmd(ENABLE);
//SPI¸üÐÂ
// DA_SPI_Send();
}
这是DA初始化:
void DA_ST_Init(void)
{
DA_RCC_Conf();
DA_GPIO_Conf();
DAC_InitTypeDef DAC_InitStructure;
// DA_Time_Conf();
//DAC Configuration
DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software; /////DAC_Trigger_T2_TRGO;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None; //ÎÞ
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
//DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bits11_0;
//DAC channel1 Configuration
DAC_Init(DAC_Channel_1, &DAC_InitStructure); //³õʼ»¯
//DAC channel2 Configuration
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
// Enable DAC Channel1: Once the DAC channel1 is enabled, PA.04 is
// automatically connected to the DAC converter.
DAC_Cmd(DAC_Channel_1, ENABLE);
// Enable DAC Channel2: Once the DAC channel2 is enabled, PA.05 is
// automatically connected to the DAC converter.
DAC_Cmd(DAC_Channel_2, ENABLE);
/****************************看这下面的 *******************************/
// ÉèÖÃÊý¾Ý,Set DAC dual channel DHR12RD register
DAC_SetDualChannelData(DAC_Align_12b_R, 2047 , 2047);
// DAC_SetDualChannelData(DAC_Align_12b_R, DA1_Calib[2] , DA0_Calib[2]); //ÓÒ¶ÔÆë,DA2,DA1Öµ,Êä³ö°ëÖµ
DAC_DualSoftwareTriggerCmd(ENABLE);//ʹÄÜÈí¼þ´¥·¢,¸üÐÂDACµÄÖµÒ»´Î
} |