AD7321 w/ 89c51

Discussion in 'Programmer's Corner' started by daddypapa, Jul 7, 2012.

  1. daddypapa

    Thread Starter New Member

    Jul 7, 2012
    2
    0
    #include<reg51.h>
    sbit CS=P2^0;
    sbit SCLK=P2^1;
    sbit DIN=P2^2;
    sbit DOUT=P2^3;

    void delay()
    { int i;
    for(i=0;i<1200;i++)
    for(i=0;i<1200;i++)
    {}
    }


    void main()
    {

    unsigned char config= Value comes here ; //control register value(
    unsigned char x,z,out;
    while (1)

    {

    z=config;
    CS=0;
    for(x=0;x<17;x++)
    {
    SCLK=0;
    DIN=z;
    // delay();
    SCLK=1;
    //delay();
    z=z<<1;
    }
    CS=1;
    SCLK=0;
    CS=0;
    // delay();


    for(x=0;x<17;x++)
    {
    SCLK=1;
    //delay();
    SCLK=0;
    //delay();
    out=DOUT;
    z=z<<1;
    }
    CS=1;
    //data out at "OUT" variable;


    }
    }

    Please help me to correct my code for ad7321 ;)
     
  2. daddypapa

    Thread Starter New Member

    Jul 7, 2012
    2
    0
    Some one please reply ;I need help;its too urgency
     
Loading...