could anyone please help with some sample code for a tlv2556? I am using Keil and C so if the code is in C that would be most helpful. I have done some code of my own and it does read the channel (all other inputs are grounded), but it is not at all stable. Any help would be greatly appreciated. I am enclosing a schematic and some of my code.

// initialize the a2d
readCh(0xFC);
// start the second time
TR0 = 1;
ET0 = 1; // enable timer 0 int
EA = 1;
CS=1;
CLK = 0;
// show we're alive
send_string("TLV2556 V1.0 07/19/11",1);
// Begin program loop
while(1)
{
if( clock_flag ) {
clock_flag = 0;
getChan();
}
// if something received in serial port
if( cmd_complete ) processCommand();
}
}
void getChan()
{
readCh(0x50);
sprintf(st,"chan 5 = %3.3f",dBits * MV_PER_BIT);
send_string(st,1);
}
// *************************************************
// T L V 2 5 5 6 R E L A T E D F U N C T I O N S
// *************************************************
void myWait(uchar cnt)
{
uchar i;
for(i=0;i<cnt;cnt++) _nop_();
}
void readCh( uchar cmd )
{
uchar c2,i;
CS = 0; // clear CS and CLK
CLK = 0;
dBits = 0; // start with zero
myWait(50); // wait for CS to settle
for( i=1;i<13;i++)
{
if( i < 9) // 1st 8 clks shift in new control byte
{
c2 = _crol_(cmd,i); // rotate left to access MSB
c2 &= 0x01; // mask all but LSB
if( c2 == 0x01 ) D_IN = 1;
if( c2 == 0x00 ) D_IN = 0;
}
else
D_IN = 1; // keeping hi reduces noise to a2d
CLK = 1; // set CLK to shift in bits
myWait(10);
// now read the new a2d data
if( D_OUT == 1 ) dBits |= 0x0001;
else if( D_OUT == 0) dBits |= 0x0000;
CLK = 0;
//myWait(15);
if( i < 12 ) dBits <<= 1; // slide bit to left to prepare for next bit
}
CS = 1;
while( EOC == 0 );
//myWait(30);
}