用PIC16F1773实现DA时,参考电压选择的是VDD和VSS,即5V和0V,实际出来的值在2.5V和3.78V之间。这是为什么?
DA初始化如下:
//OE1: DAC Voltage Output Enable bit
//1 = DACx voltage level is also an output on the DACxOUT1 pin
//0 = DACx voltage level is disconnected from the DACxOUT1 pin
DAC1CON0bits.OE1 = 1;
//OE2: DAC Voltage Output Enable bit
//1 = DACx voltage level is also an output on the DACxOUT2 pin
//0 = DACx voltage level is disconnected from the DACxOUT2 pin
DAC1CON0bits.OE2 = 0;
//PSS<1:0>: DAC Positive Source Select bits
//11 = Reserved. Do not use.
//10 = FVR_buffer2
//01 =VREF+ pin
//00 =VDD
DAC1CON0bits.PSS = 0b00;
//NSS<1:0>: DAC Negative Source Select bit
//1 = VREF-
//0 =VSS
DAC1CON0bits.NSS = 0b0;
DAC1CON1 = 0;
DAC1CON0bits.EN = 1; //DAC1 enable,RA2
在1毫米中断执行:
u8 temp = 255;
DAC1CON1 = temp;
DACLDbits.DAC1LD = 1;
结果:
temp=0,da输出2.5V
temp=255.da输出3.78V
为什么不是0~5V? |