This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

spi write procedure

Other Parts Discussed in Thread: CC2500

I'm working with TI EVM5515 and TI transceiver cc2500.

I can read the cc2500 registers but can't write into them

can someone tell me what's wrong with the following write procedure?

Int8 SPI_write_reg (SPI_HwMode cs, Uint16 addr, Uint16* writedReg)
{
 Uint16  spiStatusReg;
 volatile Uint16  spiBusyStatus;
 volatile Uint16  spiWcStaus;
 Uint16 cmdBuffer[3];
 int     fnCnt;
 Int8    status_byte;


    cmdBuffer[0] = addr;
    cmdBuffer[1] = writedReg[0];


 CSL_FINS(CSL_SPI_REGS->SPICMD1, SPI_SPICMD1_FLEN, 1);

 for(fnCnt = 0; fnCnt < 2; fnCnt++)
 {
       CSL_SPI_REGS->SPIDR2 = (Uint16)(cmdBuffer[fnCnt] <<0x08);
       CSL_SPI_REGS->SPIDR1 = 0x0000;

       CSL_SPI_REGS->SPICMD2 = (cs << CSL_SPI_SPICMD2_CSNUM_SHIFT)|
                                                               (SPI_WORD_LENGTH_8 << CSL_SPI_SPICMD2_CLEN_SHIFT)|
                                                               (CSL_SPI_SPICMD2_CMD_WRITE); 

   do
    {
         spiStatusReg = CSL_SPI_REGS->SPISTAT1;
         spiBusyStatus = (spiStatusReg & CSL_SPI_SPISTAT1_BSY_MASK);
         spiWcStaus = (spiStatusReg & CSL_SPI_SPISTAT1_CC_MASK);
    }while((spiBusyStatus == CSL_SPI_SPISTAT1_BSY_BUSY) &&(spiWcStaus != CSL_SPI_SPISTAT1_CC_MASK));
 }
 status_byte = (Int8)CSL_FEXT(CSL_SPI_REGS->SPIDR1,SPI_SPIDR1_DATA)&0x00FF;
 return (status_byte);

}
 

 

Thanks

 

Talmor