Daniel Rogers

Weird compiler problem.

Discussion created by Daniel Rogers on Nov 18, 2007
Latest reply on Nov 19, 2007 by CrasyCat
I have this code in my program for reading SPI port.
uchar SPI_Proc (SPI_PORT Port, uchar cValue)
  volatile uchar cData;
  while (!(*Port.pSPISR & SPI_TEF));                // Wait for SPTEF set
  *Port.pSPIDR = cValue; 
  while (!(*Port.pSPISR & SPI_IF));                 // Wait for SPIF set
  cData = *Port.pSPIDR;                        
  cSPI_Data = cData;                                       // load value into global location.
  return cData;

I have two lines calling this routine one after the other.

  cData = SPI_Proc(AD7730_Port,bComm);   // this line returns 0x30 which is correct.
  cData = SPI_Proc(AD7730_Port,bComm);   // this line also returns 0x30 but should be 0x80.

if I read cSPI_Data (global value) after the secound line it is equal to 0x80.

Therefore the secound SPI_Proc is not returning the data. Why???? Its reading the correct data but not returning it.