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 problem on CC2430

I now have a working SPI connection but I think I have found a bug in the silicon. I am using a master SPI port sending data to a PIC32 at 1Mbps. I need to set CPHA to 1 (and MSB first) to talk to the PIC properly but when I do this, the 2430 only transmits 7 clock pulses instead of 8 after it has sent the first byte (I have a block send function which sends subsequent bytes in the USART TX complete ISR). When I set CPHA to 0, it does not do this, all 8 clock pulses are always sent.

As a temporary work around, I have found that putting a delay af about 2 SPI clock cycles into the TX ISR before the next transmit corrects the clock signal.

Anybody else come across this? Is there a better solution?

  • joma said:

    I now have a working SPI connection but I think I have found a bug in the silicon. I am using a master SPI port sending data to a PIC32 at 1Mbps. I need to set CPHA to 1 (and MSB first) to talk to the PIC properly but when I do this, the 2430 only transmits 7 clock pulses instead of 8 after it has sent the first byte (I have a block send function which sends subsequent bytes in the USART TX complete ISR). When I set CPHA to 0, it does not do this, all 8 clock pulses are always sent.

    As a temporary work around, I have found that putting a delay af about 2 SPI clock cycles into the TX ISR before the next transmit corrects the clock signal.

    Anybody else come across this? Is there a better solution?

    Based on your description, it sounds like you are not using the DMA functionality to send subsequent bytes to the USART running in SPI mode.  This is appropriate, as the CC2430 datasheet in Section 13.14.2.1 indicates that use of the UxGDR.CPHA bit = 1 requires polling of the UxCSR.TX_BYTE.

    Are you polling UxCSR.TX_BYTE==1 before writing the next byte to be transmitted?  See the paragraphs on the right side of the page in Section 13.14.2.1 of the CC2430 datasheet which discusses this.

     

    I would also suggest reviewing the Design Note DN113 CC111xFx CC243xFx CC251xFx SPI Interface (SWRA223) as it gives good illustrations of the USART when used in SPI mode.

  • Thanks Brandon. That explains why a delay was needed. I wasn't testing UxCSR.TX_BYTE.

    I have now moved to 4Mbps and at that speed, the ISR takes up so much time in proportion to the transmit time that neither a delay, nor polling UxCSR.TX_BYTE is needed. Shame I won't be able to use DMA as the pic won't sample on the first clock edge.