XC2000 SPI always receiving 0xFF

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

cross mob
Not applicable
Hi I'm working with xc2060n and spi u1c0_rbuf gives me always 0xff.
I checked u1c0_psr for receive flag and it set before I read rbuf.
So I'm guessing communication is working. sending flag also checked and it seems working fine.
Would it be different if I starting to use FIFO? the program I need is good enough with single shot mode.

I initialize U1C0_SSC as below.

U1C0_FDRL = ((uword)2 << 14)|(1 << 0)
U1C0_BRGL = (15 << 10)|(1 << 8)|(0 << 6)|(0 << 4)|(0 << 3)|(0 << 0)
U1C0_BRGH = (uword)(2 << 14)|(0 << 13)|(3 << 0)
U1C0_DX0CR = 0x0013;
U1C0_INPRL = 0x0000; // no interupt
U1C0_INPRH = 0x0000;
U1C0_SCTRL = 0x0103;
U1C0_SCTRH = 0x0F0F;
U1C0_TCSRL = 0x0500;
U1C0_TCSRH = 0x0000;
U1C0_PCRL = ((15 << 8)|(1 << 6)|(0 << 4)|(1 << 3)|(1 << 2)|(1 << 1)|(1 << 0));
U1C0_PCRH = 0x000f1
U1C0_PSR |= 0x2000;
U1C0_CCR = 0x0001;

And sending and receving as below

U2C0_PSCR |= 0x1000; // clear transmit buffer indication flag
U2C0_TBUF00 = 0x00; // load transmit buffer register
while(!(U2C0_PSR & 0x1000)); // wait until tx buffer indication flag is set

while(!((U2C0_PSR & 0x8000) || (U2C0_PSR & 0x4000)));
uwTemp = U2C0_RBUF;
U2C0_PSCR |= 0xC000; // clear alternate receive indication flag & receive indication flag

I gets 0xFF for SCTRH.WLE=7 and 0xFFFF for SCTRH.WLE=F obviously.

Any suggestion will be appreciated.
Thanks.
0 Likes
0 Replies