Other Parts Discussed in Thread: MSP430F5438A, CC2420, STRIKE
hi,
i'm trying to implement a communication protocol for the MSP430F5438A via the USCI B0 SPI interface (imposed) as part of my uni project. i might have just found out the reason why the communication's not working, though i'm not that sure that i can find the right solution, which is why i'm counting on your help.
now i have the read and write functions (using CCSv4) as follows, and while debugging, the UCB0TXBUF changes when I write into it (though not exactly what i expected), whereas the UCB0RXBUF remains at 0xFF from start to finish, which explains why i've never been able read anything, from the RAM to the FIFO (i'm trying to implement it with CC2420).
when i try to read via the spi, normally one sends 0x00 to the TX buffer. the UCB0RXBUF, though, is always at 0xFF, which is why the RX interrupt flag's always returns 1, which in turn explains why I always get a 0xFF reading.
void spi_write (UINT8 byte)
{
UCB0TXBUF = byte;
while ( UCB0STAT & UCBUSY );
}
UINT8 spi_read (void)
{
UINT8 val;
UCB0TXBUF = 0x00;
while ( UCB0STAT & UCBUSY );
while ( (!(UCRXIFG & UCB0IFG)) );
val = UCB0RXBUF;
return val;
}
for example, to read from the RAM, i have:
void cc2420_read_ram (UINT8* p, UINT16 a, UINT8 c)
{
UINT8 i;
CS_enable();
spi_write( CC2420_RAM_ACCESS | (a & 0x7F) );
spi_write( ( (a >> 1) & 0xC0 ) | CC2420_RAM_READ_ACCESS );
for (i=0; i<c; i++)
{
((UINT8*)(p))[i] = spi_read();
}
CS_disable();
}
i'm pretty sure about the address, so i doubt it comes from there. does it come from the initialization ? please help ! thanks !
VZ