各位大侠:
新唐nano130开发板的平台。12位DAC。基准电源电压,实测3.06V,跟它数字码2048,测量电压是1.53。这个没有什么问题。 可是我分别给了不同的数据,测试结果差的比较多,数据如下: 测的数据如下:300:0.3235V。500:0.4620V。800:0.6693V。1200:0.9460V。1500:1.1538V. 直接测板子的108引脚。例如跟定数字量为800。 (800/4095)*3.05=0.596.但是实际测量是0.669V。
代码如下:
void DAC_IRQHandler(void)
{
if(DAC->STS0 & DAC_STS_IFG) {
DAC->DATA0=800;//Increase value of output data
DAC_CLEAR_CH0_INTERRUPT; //Clear DAC interrupt
}
}
const uint8_t us = ((PCLK) / 1000000);
#define ECLK 6000000 // clock feed to timer int32_t main (void)
{ TIMER_Init(TIMER0, 11, 1000, TIMER_CTL_MODESEL_PERIODIC);//Set periodic mode and 1000 tick/second
/* Enable triggger event for DAC.*/
TIMER_ConfigTriggerEvent(TIMER0, TIMER_CTL_DACTEEN, TIMER_CTL_TIMEOUTTRGEN);
GCR->PC_L_MFP = (GCR->PC_L_MFP & ~PC6_MFP_MASK) | PC6_MFP_DA_OUT0; // Set GPC6 for DAC0
DAC_Init(); //Initiate DAC
DAC_SetRefVol(DAC_COMCTL_REFSEL_AVDD); //Set AVDD for reference voltage
DAC_SetDelayTime(0, us * 6, us * 2); //Initiate delay time
DAC_SetLoadSel(0, DAC_CTL_LSEL_TIMER0_CH0); //Set trigger source from timer 0
DAC_CH0_POWER_ON; //Turn on DAC power
while(DAC_GetState(0) != DAC_IDLE); // Wait for power stable
DAC_EnableInterrupt(0); //Enable interrupt
TIMER_Start(TIMER0);//Start timer
while(1);
} |