XC2000 SSC SPI EEPROM issue on receive

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.
Jeroenveer
Level 1
Level 1
First reply posted First question asked Welcome!

Hi,

I have been trying to get the SPI working on a XC2734 chip to read a eeprom.
Problems i have is with receiving the data, the RBUF always stays 0x00 and never changes.

Check data with a scope and on the MISO input line i see data and it is changing on different address reads.
But RBUF always returns 0x00.

P10.0 Data input MISO
P10.1 Data output MOSI
P10.2 Clock
P10.8 CS

 

void EEPROM_test()
{

char recValue = '0';

U0C0_PCRL = 0x0F4F;

P10_OMRH = 0x0100; // P10.8 CS Output Low

U0C0_SCTRH = 0x071F; // Sets frame length on 4 byte


vSendData1(0x03);

vSendData1(0x01);
vSendData1(0xD0);

vSendData1(0xFF);

recValue = uwGetData();
//recValue = U0C0_RBUF;

P10_OMRH = 0x0001; // P10.8 CS Output High

}

 

void vSendData1(uword uwData)
{

U0C0_TBUF00 = uwData; // load transmit buffer register
while(!(U0C0_PSR & 0x1000)); // wait until tx buffer indication flag is set
U0C0_PSCR |= 0x1000; // clear transmit buffer indication flag

}

 

uword uwGetData(void)
{
while(!((U0C0_PSR & 0x8000) || (U0C0_PSR & 0x4000)));

U0C0_PSCR |= 0xC000; // clear alternate receive indication flag & receive indication flag
return U0C0_RBUF; // return receive buffer register
}

0 Likes
3 Replies
vatchnechur
Level 1
Level 1
First reply posted First question asked Welcome!

When I read data, usually I send 0xFF before reading the data, because needs to send the clock command. Have you tried it ? 

0 Likes

Thanks for the reply!

I send command, address and a dummy byte.
On the scope i see that the eeprom is responding with data but it is not getting into the RBUF.

vSendData1(0x03);

vSendData1(0x01);
vSendData1(0xD0);

vSendData1(0xFF);

Would you want to share the code you use to setup spi and read the eeprom?

0 Likes
lock attach
Attachments are accessible only for community members.

Sorry for my delay. I've attached the file.

Hope this can help you

0 Likes