SPI CS pin going High and From Transceiving function data is not coming.

I am using nrf52840 and i am working on nrf connect sdk v2.6.0  in my overlay file SPI CS pin is low but it is going high between the communication.

Data is not receiving from the sensor using spi_transceive_dt() function but in logic analyzer the MISO and MOSI lines are working.

Please look into the below code and help me on this.

Parents
  • Hi,

     

    Your /CSN pin works as it should. Goes low when the transmission occurs, and back to idle level afterwards (ie. high level)

    You need to adjust your sampling frequency in the saleae logic application, looks like it is too low.

    Looks like you're sending one byte and receiving two. Can you share what you're sending and receiving?

     

    Kind regards,

    Håkon

  • In spi_transceive_dt() first byte is dummy as per document so 2nd byte Iam reading but 2nd byte also coming from sensor is zero

    when I increase SCLK frequency as 8 MHZ  it is showing like this and miso line is transmitting when CS pin is in high



    Iam sending the command and receiving the sensor value using transferSPI function 




    I am sending through uart values are not coming


    Thank you.

  • Hi,

     

    What are the settings in your Saleae Logic application? Because it seems like you're still sampling at a lower frequency than the SPIM is running on.

    Your clock line should look like channel 0 in this example trace:

     

    Kind regards,

    Håkon

  • Hi,
    These are the settings of logic analyzer 1Ms/s and hold off time is 100 m/s

    In logic analyzer when i sent 0x00(MOSI) the data receiving is 0x3E(MISO) correct

    But while printing the same on console i am getting 0x30 why and in  spi_transceive function sending data size is N means receiving data should be N+1 or not 
    below is my function please check

  • Hi,

     

    Madhu Mohan Reddy said:
    In logic analyzer when i sent 0x00(MOSI)

    0x00 is on the MISO line, according to your trace, while you are sending 0x20 0xFF (where FF is the number of registers to read)

     

    I would recommend that you check chapter 9.5.3.10 RREG: Read From Register in the datasheet for your connected sensor. This explains how you should interface the sensor.

     

    Kind regards,

    Håkon

  • Hi,

    can you please send the link of 9.5.3.10 i cant find and please check the transferSPI function is it correct or not

    Thank you in advance.

Reply Children
  • Google the sensor you have, and check the manufacturer website.

    You should be able to find the datasheet from there.

     

    Kind regards,

    Håkon

  • I am sending 0x20 and 0x01 and in MOSI line 0x20 0xFF,  0x01, 0xFF Coming why
    my RREG function below

  • Hi,

     

    If you look at the chapter I previously mentioned: Each transaction is 2 byte op_code, written from the nRF, and you will then get 'n' bytes returned based on the contents of the second byte sent. At this moment, you're writing 1 and reading 2 bytes twice, then clearing your /CSN pin.

     

    Kind regards,

    Håkon

  • when I write 1 byte it will come 1 byte 
    why I am asking in dev academy SPI lesson spi_transceive function transmit size is len  receive size is len + 1

    thats why i am asking this 

    thanks in advance

  • I am not sure what you're asking. Could you elaborate on what you are actually stuck with?

    You need to send two bytes, not one. The second byte holds the amount of registers to read, minus 1, as per the datasheet of the sensor.

     

    Kind regards,

    Håkon