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.

MSPM0C1104: SPI Recieve Problem

Part Number: MSPM0C1104

Tool/software:

I have been using SPI RTC on SPI 0 , I am transmitting data on one of the register of RTC , and then reading that register,I am getting proper waveform of the data correctly at POCI pin , but when reading the RX_DATA buffer i am getting 0XFF data in the variable when debugging with XDS110

  ihave been using     SPI_RX_data  = DL_SPI_receiveData8(SPI_0_INST);   

Pls help

  • What did you transmit to get the RX data? SPI can only receive as part of a transmit. Your device may have a dummy NOP byte that is used for the peripheral to send data.

  •  SPI_RX_data  = DL_SPI_receiveData8(SPI_0_INST); 

    I suspect you aren't waiting for the exchange (Tx/Rx) to complete. Try instead something like:

     SPI_RX_data  = DL_SPI_receiveDataBlocking8((SPI_0_INST); 

    I'm just guessing at the context here, but it will probably look something like:

    DL_SPI_transmitDataBlocking8(SPI_0_INST, register_read); // Request
    DL_SPI_transmitDataBlocking8(SPI_0_INST, 0xFF); // Dummy byte to receive value
    (void)DL_SPI_receiveDataBlocking8(SPI_0_INST); // Read and throw away Request Rx
    SPI_RX_data  = DL_SPI_receiveDataBlocking8(SPI_0_INST); // Capture register value

  • As per the above i was not impleminting    (void)DL_SPI_receiveDataBlocking8(SPI_0_INST); // Read and throw away Request Rx

    in my code, Now i am able to read the Data from SPI , BUt now after to read sequence the data is getting shifted .

  • I have observe that when I write the SPI periphrial once and then i tried to read the SPI Peripherial first time it is not read properly and then it when continuos read then it read properly . Anything to be writeen in the code after the Write data is completed.

  • Is the data shifted bit-wise or byte-wise? 

    For bit-wise:

    1) Make sure your SCK polarity and phase (CPOL/CPHA) match the RTC's. This would be in the RTC datasheet.

    2) Long wires can introduce propagation delay. I've seen bit-shift/bit-smear with 12cm wires at 6MHz. Try slowing your SPI down.

    For byte-wise:

    1) With the SPI, every Tx byte generates an Rx byte (as seen above). You need to account for each one to maintain the correspondence.

  • it is shifted Byte wise.   should i have to read the Receive buffer by using  SPI_RX_data  = DL_SPI_receiveDataBlocking8(SPI_0_INST);  and dump the data ???

  • after every Tx byte

  • Usually, yes.