Dear Sir,
I am not getting analog volgate variation at Vout-0,1,2,3 pin. always getting 0V. Please tell me the reason .Iam sharing my code tell me were is the problem,My ref voltage is +5V. IAm sharing my code kindly let me known where is the problem.
void write_dac_3byte(long add)
{
unsigned char i;
long temp;
// DelayMs(4);
for(i=24;i >=1;i--)
{
SPI_SCL=1;
temp=add;
temp =temp >> (i-1);
temp= temp & 0x01;
// send_hex(temp);
if(temp == 0x01)
{
SPI_SDO =1;
}
else
{
SPI_SDO =0;
}
SPI_SCL=0;
DelayMs(4);
}
}
/
//-------------------DAC WRITING -----------------------------------//
void DAC_write (void)
{
DAC_LATCH=0; // data are sending
MUX_SEL(5); //CS=0;
write_dac_3byte(0x00000000); // command register write were on byte 3 address is 0
write_dac_3byte(0x00012000); // monitor register write were on byte 3 address is 1 to select dac-1 = 2
write_dac_3byte(0x00057ff0); // dac input output register write were on byte 3 address is 5 to select dac-1= 00 GIVE dac DATA INPUT
write_dac_3byte(0x000900FF); // zero register write were on byte 3 address is 9 to addjust offset error +1.9922lsb
write_dac_3byte(0x000D007F); // gain register write were on byte 3 address is D to adjust gain error +7.9375lsb
PORTA=0xFF; // CS=1
DelayMs(10);
}
///////////////////////////////////MAIN FUNCTIO N ///////////////////////////
void main(void)
{
long DOR_BUFFER,FULL_BUFFER,OFF_BUFFER;
TRISA=0b00000000; // mux selection A,B,C output=0,STARt CONV,HYDRO_TEST;AC_MAG_GAIN=;
TRISB=0b11110000; // CHANNEL SELECTION A0-A3=0;ADC16_BUSY,X,Y,ZADC_DRDY=1
TRISC=0b11010000; // spi SDO,clk output=0,SDI input=1;TX=1;RX=1
ADCON1=0x86;
while(1)
{
DAC_write();
}
}