I'm exacute the following steps in order to read the part number from the cc250
1. send opcode 06h WREN to enable the wriy\te option
2. send opcode 02h WRITE with header byte 0xff00 ( partnumber address 0x30 and read bit 1 and burst access bit 1) to the cc250
3. send opcode 05h READ
4. reset the data register and try to read the data
as you've probably understood it doesn't work
The following is my code
Any help is more than appreciated !!!!
Int16 spi_test( ) {
spi_init( );/* Initialize the SPI interface */
spirom_reset_chipcon(CC2500_SRES);
spirom_read_from_chipcon( CC2500_PARTNUM | CC2500_READ_BURST, ( Uint32 )rx, 1 );
}
void
/* Reset Counter value */
SYS_PRCNTR = 0x04;
/* Reset SPI Module */
SYS_PRCNTRLR = 0x00ff;
for
(i=0;i<100;i++) {;}
/* Init SPI Pins: Enable SPICLK,RX,TX & CS0 */
SYS_EXBUSSEL =(0x6<<12);
//SPI init
SPI_SPICC2 = (0<<15);
// Reset SPI
SPI_SPICC1 = 0x0031;
// 2MHz input clock
SPI_SPIDC1 = 0x0000;
//cs1 active low
spi_init( ){
Int16 i;
SPI_SPICC2 = (1<<15);
while((SPI_SPISR1 & 0x0001) != 0) {};
return;
}
void
//flen bit total number of characters in frame
i = SPI_SPIDR2;
// Dummy read
/* Spirom access cycle */
for(i = 0; i < len; i++)
{
SPI_SPIDR2 = buf[i] << 8;
//spidat2 hols the most significant word
SPI_SPIDR1 = 0x0000;
//spidat1 hols the most significant word
SPI_SPICR2 = 0x103A;
//set chip select 1 set clen - 8-bit words (must set to req len-1), cmd write(2) bits of spicmd2
while((SPI_SPISR1 & 0x0002) == 0) {};
//check fc(frame complete) bit of spistat1
}
/* Wait for transfer to complete */
while((SPI_SPISR1 & 0x0001) != 0) {};
//loop while busy bit is on
}
void
//flen bit total number of characters in frame
i = SPI_SPIDR2;
// Dummy read
/* Spirom access cycle */
for(i = 0; i < len; i++)
{
SPI_SPIDR2 = 0x0000;
//spidat2 hols the most significant word
SPI_SPIDR1 = 0x0000;
//spidat1 hols the most significant word
SPI_SPICR2 = 0x1039;
//set clen - 8-bit words (must set to req len-1), cmd read(1) bits of spicmd2
while((SPI_SPISR1 & 0x0002) == 0) {};
//check fc(frame complete) bit of spistat1
buf[i] = SPI_SPIDR2 & 0xff;
//read spidat2 into buf
}
/* Wait for transfer to complete */
while((SPI_SPISR1 & 0x0001) != 0) {};
//loop while busy bit is on
// EVM5515_waitusec(100);
}
void
{
/* Issue WPEN */
spirombuf[0] = spirom_CMD_WREN; spi_write(spirombuf, 1);
/* issue write cmd */
spirombuf[0] = spirom_CMD_WRITE;
spirombuf[1] = ( Uint16 )( tx >> 8 );
spirombuf[2] = ( Uint16 )( tx );
spi_write(spirombuf, 3 );
/* issue write cmd */
//spirombuf[0] = spirom_CMD_WRDI;
//spi_write(spirombuf, 1);
}
void
spirombuf[0] = spirom_CMD_WREN;
spi_write(spirombuf, 1);
/* issue write cmd */
spirombuf[0] = spirom_CMD_WRITE;
spirombuf[1] = ( Uint16 )( tx >> 8 );
spirombuf[2] = ( Uint16 )( tx );
spi_write(spirombuf, 3 );
spirombuf[0] = spirom_CMD_READ;
spi_write(spirombuf, 1);
read_from_chipcon(spirombuf,1);
}
spirom_read_from_chipcon(Uint16 tx, Uint32 rx, Uint32 length){
spirom_reset_chipcon(Uint16 tx) read_from_chipcon(Uint16 *buf, Uint16 len)
{
Uint16 i;
SPI_SPICR1 = 0x0000 | len - 1;
spi_write(Uint16 *buf, Uint16 len){
Uint16 i;
SPI_SPICR1 = 0x0000 | len - 1;