change device name through spi

hi

Working with Linux operating system I faced the problem not knowing how can the nrf52840 device name be changed via the SPI protocol and what frame format should be used?

I would appreciate if you help me with step by step guidance.

Many thanks

Parents
  • Hello,

    I am not sure what you are asking. What name do you want to change? Is the nRF52840 connected to your linux computer using SPI?

    Best regards,

    Edvin

  • Hello
    Yes nrf52840 connected to a core board with linux operation system using SPI . How can I merge advertise and SPI(master and slave) communications examples into one code so that the string that nrf receives as a slave will sit instead of the device name ?
    #define DEVICE_NAME      "Nordic"

    On the other hand, the main issue is what should be the spi frame format for Linux?

  • Ok, let me split your request into 2 parts:

    1: How do I change the advertising name during runtime?

    2: How do I set up SPI?

    3:  (Bonus) How does SPI work on my custom board with Linux OS using SPI?

    First of all, what SDK are you using for the nRF? Do you use the nRF5 SDK, or do you use nRF Connect SDK (NCS)?

    1: Depending on the SDK that you are using, you should look at how the advertising name is usually set up. Look in the file that defines the bt_le_adv_start() in adv.c (if you are using NCS), or ble_advertising_init() in ble_advertising.c (if you are using the nRF5 SDK). Then look for a function that is used to update the advertising data. In NCS it would be called bt_le_adv_update_data(), while in the nRF5 SDK it would be ble_advertising_advdata_update().

    2: Depends on the SDK again. In the nRF5 SDK, please look at the SDK\examples\peripheral\spi (or spis, if you are the SPI slave). In NCS, I can recommend this tutorial: https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/

    Lesson 6 shows you how to set up I2C, but the method to use SPI is quite similar.

    3: I don't know. You would need to ask this in some sort of Linux forum, or find someone who can help you with whatever is present on your core board.

    Best regards,

    Edvin

  • Hi Edvin
    Thank you for your guidance
    I use the nRF5 SDK.

    I got the SPI communication with the DK board, but considering that I want to set it on the custom board, when I change the pins on the "sdk_config.h"  to the
    cs:P0.24(AD20)
    CLK:P0.15(AD10)
    mosi:P0.17(AD12)
    miso:P0.22(AD18)
    ,the data won't be sent and received, and the spi won't work properly.  What parts of the SPI example need to be changed to set the SPI pins ?

Reply
  • Hi Edvin
    Thank you for your guidance
    I use the nRF5 SDK.

    I got the SPI communication with the DK board, but considering that I want to set it on the custom board, when I change the pins on the "sdk_config.h"  to the
    cs:P0.24(AD20)
    CLK:P0.15(AD10)
    mosi:P0.17(AD12)
    miso:P0.22(AD18)
    ,the data won't be sent and received, and the spi won't work properly.  What parts of the SPI example need to be changed to set the SPI pins ?

Children
  • nRF5_SDK_15.2.0_9412b96\examples\peripheral\spis

  • So your linux machine is running an SPI master? How did you connect the pins? What is the SPI speed that the SPI master is using? 

    Can you please test all the SPI modes, NRF_SPIS_MODE_0 to NRF_SPIS_MODE_3.

    You can set it like this:

        nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
        spis_config.csn_pin               = APP_SPIS_CS_PIN;
        spis_config.miso_pin              = APP_SPIS_MISO_PIN;
        spis_config.mosi_pin              = APP_SPIS_MOSI_PIN;
        spis_config.sck_pin               = APP_SPIS_SCK_PIN;
        spis_config.mode                  = NRF_SPIS_MODE_0
    
        APP_ERROR_CHECK(nrf_drv_spis_init(&spis, &spis_config, spis_event_handler));

    If that doesn't work, can you please try to capture a logic trace of the SPI wires? 

    Best regards,

    Edvin

  • In the target application, Linux and NRF will behave as master and slave depending on the type of request, but to test the performance of a part of the application, currently Linux is used as Master and NRF as Slave.
    When I change the pins defined in the example (spi&spis) to custom board pins, data is not sent/received.
    I uploaded the samples (spi&spis) on two NRF DK boards by changing the pins I mentioned earlier, but still no data is being exchanged.
    I also repeated this with the NRF DK board as a slave and the STM 32 as a master, but I could not send/receive data.

    Master DK and Slave DK are connected by wire without any element between them

    I don't know what is the SPI speed but  I didn't change the speed in the SPI example.

    spis_config.mode = NRF_SPIS_MODE added to SPIS example in main.c and tested 0-3 but the problem still persists.

  • If you take the unmodified spi&spis samples on two nRF DK boards (if you are not sure whether they are unmodified or not, download and unzip the SDK again). 

    Then let me know what pins you connected between the DKs. If possible, take a photo, and upload it here. Can you also show me the logs that you are seeing on both devices?

Related