XC2000 SSC problem - SPI EEPROM

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Not applicable
Hello all.

I have tried to implement HOT_XE164FM_EEPROM example by my Easy kit_XC2331D-SK and Keil. The pins which I have used are as following:

P2.8 as CLK;
P2.4 as MOSI;
P2.10 as MISO;
P2.7 as CS.

Since I have checked in the training board schematic, these pins are connected to the AT25128 SPI EEPROM. But the program does not work!! The program code is as following:

char wriValue = 'a';
char recValue = '0';

U0C1_SCTRH = 0x0707; // Sets frame length on 2 byte
U0C1_SSC_vSendData1(0x06); // Enables write mode
U0C1_SCTRH = 0x070F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x01); // Sets status register ready to write
U0C1_SSC_vSendData1(0x02); // Resets array addresses protection

while( U0C1_SSC_uwGetData() ) // Waits till writing has ended
{
U0C1_SCTRH = 0x070F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x05); // Reads Status Register
U0C1_SSC_vSendData1(0x00);
}

// Writes data in EEPROM
U0C1_SCTRH = 0x0707; // Sets frame length on 1 byte
U0C1_SSC_vSendData1(0x06); // Enables write mode
U0C1_SCTRH = 0x071F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x02); // Introduction for WRITE
U0C1_SSC_vSendData1(0x02); // Introduction for WRITE
U0C1_SSC_vSendData1(0x00); // Memory of EEPROM
U0C1_SSC_vSendData1(0x00); // Memory of EEPROM
U0C1_SSC_vSendData1(wriValue); // Transmit data

while( U0C1_SSC_uwGetData() ) // Waits till writing has ended
{
U0C1_SCTRH = 0x070F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x05); // Reads Status Register
U0C1_SSC_vSendData1(0x00);
}

// Reads data out of EEPROM
U0C1_SCTRH = 0x071F; // Sets frame length on 8 byte
U0C1_SSC_vSendData1(0x03); // Enables read mode
U0C1_SSC_vSendData1(0x00); // Memory of EEPROM
U0C1_SSC_vSendData1(0x00); // Memory of EEPROM
U0C1_SSC_vSendData1(0x00);
U0C1_SCTRH = 0x070F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x05); // Reads Status Register
U0C1_SSC_vSendData1(0x00);
recValue = U0C1_SSC_uwGetData();

// Checks if wrote and receive data have the same value

if ( wriValue == recValue)
{
IO_vResetPin(IO_P10_2); // Sets LED connected to P10.2
IO_vResetPin(IO_P10_3); // Sets LED connected to P10.3
}

I have also attached my files. could any one help me regarding this problem?
0 Likes
2 Replies
Not applicable
Could any one help me pleas?
0 Likes
Not applicable
Dear all,
I have tried another source code which was presented in ap1612900_XE166_USIC application as following:

char wriValue = 'a';
char recValue = '0';

U0C1_PCRL = 0x0F4F;

// Write 'write enable'
U0C1_SCTRH = 0x0707; // Sets frame length on 1 byte
U0C1_SSC_vSendData1(0x06);
uwTmp=U0C1_RBUF;

U0C1_SCTRH = 0x070F; // Sets frame length on 2 byte
U0C1_SSC_vSendData1(0x05);
U0C1_SSC_vSendData1(0x00);

while ((U0C1_RBUF & 0x00FF) != 0x0002);

// Writes data in EEPROM
U0C1_SCTRH = 0x071F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x02);
U0C1_SSC_vSendData1(0x00);
U0C1_SSC_vSendData1(0x00);
U0C1_SSC_vSendData1(wriValue);

// Reads data out of EEPROM
U0C1_SCTRH = 0x071F; // Sets frame length on 4 byte
U0C1_SSC_vSendData1(0x03);
U0C1_SSC_vSendData1(0x00);
U0C1_SSC_vSendData1(0x00);
U0C1_SSC_vSendData1(0x00);
uwTmp=U0C1_RBUF;
recValue = U0C1_RBUF;

// Checks if wrote and receive data have the same value

if ( wriValue == recValue)
{
IO_vResetPin(IO_P10_2); // Sets LED connected to P10.2
IO_vResetPin(IO_P10_3); // Sets LED connected to P10.3
}

I have checked the signals on the SELO and SCLK pins and they are correct. But the signal on RXD pin of microcontroller is always high.
Could anyone help me to solve the problem?
0 Likes