This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 Dongle FATFS issue when SPIM and SPIS are configured at the same time

Hello, 

I have been using nRF52840-DK and also nRF52840 Dongle for testing and I found an interesting behaviour when I established my test setup. The RF module acts as an SPI slave towards another MCU, and also acts as an SPI master towards a micro SD card extension. As far as I know most of the existing GPIO pins can be configured to be used as SPI pins so based on that my PIN layout is the following:

SPIM (micro SD card extension):

  • SCK: P0.31
  • MISO: P0.13
  • MOSI: P0.15
  • CS: P1.0

SPIS (another MCU):

  • SCK: P1.10
  • MOSI: P1.15
  • MISO: P1.13
  • CS: P0.2

Also there is an additional GPIO configured as output on P0.29.

I also set the MISO Pull configuration to pull-up because I read (https://devzone.nordicsemi.com/f/nordic-q-a/24334/fatfs-example-sdk14-0-0-not-working#post-id-163682) that it is needed for the fatfs library to work as expected for new generation micro SD cards.

The issue is when I execute my program the nRF52840-DK works perfectly and the data is written to the SD card always, but when I use the Dongle the data is usually not written (fatfs fails with disk initialization failure). It only happens when I use a new generation 32Gb U3 and U1 micro SD cards, the issue is not present for older versions (with 16Gb U1 works fine).

I tried to change the RF module (Dongle), cables, and tested the setup with 3 different kind of micro SD card extensions, for all of them I received the same result. Also tested the SPIM and SPIS separately and like that both works fine (even the fatfs example works flawlessly).

Is there any difference in the PIN configuration or setup between the nRF52840-DK and Dongle that might cause this issue? Or do you have any PIN layout recommendations that might solve this issue if I intend to use SPIM and SPIS at the same time for the nRF52840 Dongle?

Thank you in advance for your support!

Parents
  • Hello Bertalan,

    Are you currently working on your DK, as suggested by Simon?
    The pins you have selected - p.020 to p.023 - is already in use for the QSPI ( external memory ) on the DK. In order to use those pins as GPIO's you would have to cut and short the SolderBridges mentioned in the documentation.
    You mention that you have tried several other pins, but none of the configurations have worked. Could you elaborate which configurations you have tried?

    When you say that it did not work at all, are you testing the pin configurations with the fatfs example? I suggest using it as a base when changing the configuration, since you were able to verify that the example worked as expected earlier - this will make tracking and identifying issues much easier.

    As Simon mentions, the dongle is a great companion when developing BLE applications - but it is usually best to start the development on the DK, since it has an onboard debugger and a much more broad connection interface.

    Best regards,
    Karl

  • Hello Karl,

    Thank you for your response. Yes I am currently using the DK and a few hours ago I found a pin configuration that only consists of high frequency pins:

    • SCK: P0.11
    • MOSI: P0.13
    • MISO: P0.15
    • CS: P0.14

    With this configuration my software (the SD card initalization is the same as the fatfs example so to validate it should be fine) works as expected, however I don't know if I should enable any configuration if I want to use these pins for SPI with high drive. Or now that it is connected to the pins with high frequency it works in a high drive mode automatically?

    I know that the Dongle is a great tool for developing, I started to work with it in the beginning, but after a while I needed the debugger functionality on the DK so I switched to it. Still the original question why the SD card is working on the DK and not on the Dongle (same software and pin layout) is a mystery :)

    Best regards,

    Bertalan

  • Hello Bertalan,

    I am happy to hear that your software now works as expected!

    BLaszlo said:
    With this configuration my software (the SD card initalization is the same as the fatfs example so to validate it should be fine) works as expected, however I don't know if I should enable any configuration if I want to use these pins for SPI with high drive. Or now that it is connected to the pins with high frequency it works in a high drive mode automatically?

    The standard configuration by the SPIM driver is to set the drive strength to NRF_GPIO_PIN_S0S1.
    You may change the drive strength by calling nrf_gpio_cfg after nrfx_spim_init has finished the SPIM setup.

    BLaszlo said:
    Still the original question why the SD card is working on the DK and not on the Dongle (same software and pin layout) is a mystery :)

    Are you running exactly the same project, or have you made sure to change the board file when generating the .hex for the dongle?
    The nRF52840 dongle is PCA10059, while the nRF52840 DK is PCA10056.

    Best regards,
    Karl

  • Hello Karl,

    Thank you for the clarification on the about the drive strength modification. Is it enough to only modify the strength of the SCK to high or should I do the same for the MISO/MOSI (just asking because in the SPIM driver only the SCK is set up with NRF_GPIO_PIN_S0S1).

    For the paralell Dongle and DK development I usually branch the current example project, and while using the same main.c file the project file is different (it has the same structure as you have used for the examples so next to the main.c file we have the pca10056 and pca10059 folders containing the project file along with the compiled files too). I modified the project so far based on this guide: https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial (Adapting SDK projects for the nRF52840 Dongle paragraph)

    So far everything was working the same way (ESB and SPIS), and this is the first behaviour that works differently, that is why I wrote the question here :)

    Thank you again and best regards,

    Bertalan

Reply
  • Hello Karl,

    Thank you for the clarification on the about the drive strength modification. Is it enough to only modify the strength of the SCK to high or should I do the same for the MISO/MOSI (just asking because in the SPIM driver only the SCK is set up with NRF_GPIO_PIN_S0S1).

    For the paralell Dongle and DK development I usually branch the current example project, and while using the same main.c file the project file is different (it has the same structure as you have used for the examples so next to the main.c file we have the pca10056 and pca10059 folders containing the project file along with the compiled files too). I modified the project so far based on this guide: https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial (Adapting SDK projects for the nRF52840 Dongle paragraph)

    So far everything was working the same way (ESB and SPIS), and this is the first behaviour that works differently, that is why I wrote the question here :)

    Thank you again and best regards,

    Bertalan

Children
  • Hello again Bertalan,

    BLaszlo said:
    Thank you for the clarification on the about the drive strength modification.

    No problem at all, I am happy to help!

    BLaszlo said:
    Is it enough to only modify the strength of the SCK to high or should I do the same for the MISO/MOSI (just asking because in the SPIM driver only the SCK is set up with NRF_GPIO_PIN_S0S1).

    I guess this depends on your specific hardware and requirements. What is your reasoning for needing this - are you seeing unusual signal waveforms on an oscilloscope, or does your SPI slave demand it in their specification? Could you also tell me what frequency you are intending to use? High drive might be favorable on higher speeds, since you typically get faster rise / fall times.

    BLaszlo said:
    For the paralell Dongle and DK development I usually branch the current example project, and while using the same main.c file the project file is different (it has the same structure as you have used for the examples so next to the main.c file we have the pca10056 and pca10059 folders containing the project file along with the compiled files too). I modified the project so far based on this guide

    Great, this is a good way of doing it.
    I just had to make sure that you had accounted for the change in your project files, thank you for verifying this for me.

    BLaszlo said:
    So far everything was working the same way (ESB and SPIS), and this is the first behaviour that works differently, that is why I wrote the question here :)

    I understand. Good call! Could you connect the dongle to the debugger on the DK to use the debugger to identify the issue the dongle is facing? You will need to follow the "Using an external debugger" section of the Dongle Programming Tutorial also.
    Alternatively, could you elaborate on what you are seeing with the dongle - do you know where it fails, and what do you mean specifically when you say that it does not work on the dongle?

    Looking forward to solving this issue together,

    Best regards,
    Karl

Related