Harlen Chen

9S08AW60  SPI 4Kb EERPOM   X5043/X5045

Discussion created by Harlen Chen on Jul 16, 2007
Latest reply on Jul 25, 2007 by Harlen Chen
I am using 9s08AW60 ' SPI module to connect with X5043 EEPROM.
But I can read anything from the EEPROM device?
The following is the Read Devide code:
#define CS PTED_PTED4
Void SPIInit(void)
  SPI1C1 = 0x00;                     
  SPI1C2 = 0x00;       //clear the control register                               
  SPI1BR = 0x04;   // set the Speed
  SPIS;                   //clear the status register
  SPI1C1 = 0x50;   //set the control register                                   
unsigned char ReadByte(unsigned char ADD)
unsigned char Temp;
while(! SPI1S_SPTEF ); SPI1D =0x03;     //send the Read command
while(! SPI1S_SPTEF ); SPI1D = ADD;   //send the address
while(!SPI1S_SPRF);  Temp = SPI1D;    // feedback the data of  address
CS = 1;
return Temp;
Very thank for your reply.