2007-05-29 05:08 AM
Why can't I read data from the SPI slave device?
2011-05-17 03:08 AM
I used upsd3354D with TC72(Microchip) , the SPITXD and SPICLK works well. But, I can't READ any byte from the slave device, the SPIRXD keeps high all the time.
e.g. Read the TC72 ID (0x54), but I read 0xFF. unsigned char ReadTemperID(void) { unsigned char t_id; P1_7=1; while (SPISTAT & SPI_BUSY_FLAG); //Waiting if SPI is busy SPICON0|=RE; while (!(SPISTAT & SPI_TI_FLAG)); //Waiting if SPI transfer is full SPITDR=0x00; //Send 0x02 to select temper MSB byte while (!(SPISTAT & SPI_TRANSMIT_END_FLAG)); while (!(SPISTAT & SPI_RI_FLAG)); SPITDR=SPI_Dummy; //Provide read clock by sending a dummy byte while (!(SPISTAT & SPI_TRANSMIT_END_FLAG)); //Waiting if SPI transfer is full while (!(SPISTAT & SPI_RI_FLAG)); //Waiting if SPI receiver is empty t_id=SPIRDR; //Read data from SPIRDR register SPICON0&=(~RE); //Disable SPI receiver P1_7=0; return(t_id); //Return data received }2011-05-17 03:08 AM
I actually have the same problem with the 24LC640. Even when I attempt to read the internal registry I get 0xFF.