Help Me with Troubles about Reading MAX6675

Hello,all
I use the io-port of G2553 analog spi to read the temperature value of MAX6675,but I don’t know why it’s always zero here.My program is written according to the 51 routine. The hardwar--P2. connects DO. P2.1 connects CLK,P2.2 connects CS. This is the MAX6675 datasheet( http://www.kynix.com/uploadfiles/pdf8798/MAX6675ISA.pdf ) which you can find details from it such as timing sequence and the program is given below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
uint read_spi(void)//spi read 16 bits
{
  
  P2DIR &= ~BIT0;
  P2DIR |=BIT1+BIT2;

  P2OUT|=BIT2;//pull up CS begin to change
   __delay_cycles (524288); 
  P2OUT&=~BIT2;//Pull down CS begin to read
  P2OUT|=BIT1;//sck rising edge
  __delay_cycles (524288); 
  uchar i;
  uint data=0;
  for(i=0;i<16;i++);
  {P2OUT&=~BIT1;//sck dowing edge
__delay_cycles (524288); 
  if(P2IN&BIT0)// judge if receiving electric level
  {data<<=1;
   data=data+BIT0;
  }
  else data<<=1;
  P2OUT|=BIT1;//sck rising edge
  __delay_cycles (524288); 
  }
  data<<=1;
  data>>=4;
  
  return data ;
  }

Is it hardware problem or software problem ? Can you help me ?
Thanks in advance.
Topic archived. No new replies allowed.