Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF5 SDK 15 TWI Scanner example, strange pin layout

Hi,

I have Ublox EVK-NINA-B3 on table, which has totally different pin layout than NRF52 DK (not sure why): https://www.u-blox.com/sites/default/files/EVK-NINA-B3_UserGuide_%28UBX-17056481%29.pdf

It mentions:

SDA, schematic pin GPIO_4, NRF52_pin = P0.16

Your SDK example TWI Scanner contains file: PCA10056_H has only this:

// Arduino board mappings
#define ARDUINO_SCL_PIN 27 // SCL signal pin
#define ARDUINO_SDA_PIN 26 // SDA signal pin
#define ARDUINO_AREF_PIN 2 // Aref pin

Isn't it too bad, after all these years, of NRF5 SDK to put Arduino defines in your official example :-D ?

Anyway, how to map custom pins in this specific case? Your older threads mention some TWI configuration for custom boards, but no defines like TWI0_SCL_PIN do exist in whole SDK. It was only in NRF51.

Thanks,

Cyberluke

Parents
  • Isn't it too bad, after all these years, of NRF5 SDK to put Arduino defines in your official example

    Seems perfectly reasonable to me: these map to the Arduino connectors on on the DK - so it seems obvious to name them, "ARDUINO_..."

    // Arduino board mappings
    #define ARDUINO_SCL_PIN 27 // SCL signal pin
    #define ARDUINO_SDA_PIN 26 // SDA signal pin
    #define ARDUINO_AREF_PIN 2 // Aref pin

    If you look at the DK User Guide, you will see that SCL on the Arduino headers goes to P0.27, and SDA on the Arduino headers goes to P0.26

    So, to use other pins, just change those numbers.

    no defines like TWI0_SCL_PIN do exist in whole SDK

    Presumably because, on the nRF52, you can route the functions to any pin you like.

  • Yes, but I'm developing on DK in order to make firmware for NRF52 unit and for this I only need to setup TWI specific stuff. So it should be portable and written in terms of the best practices for TWI library inside NRF5 SDK 15.2.

    The manufacturer = UBlox and it is big mess. They have custom_board.h in that PDF only and it is split across two pages. I cannot understand, why they cannot provide zip file with headers and just put it inside PDF in a bad way with bad  formatting. Also they mention to put custom_board.h inside NRF SDK/components/boards/ ...which is not portable. Every SDK version, I will have to run recursive diff & merge for these extra files. 

    So question is: Where can I find best practices for NRF5 SDK making custom board and including inside example project? Not polluting SDK folder, which is not under my control?

  • The arduino definitions are intended to be used when the nRF52 Development Kit board is used as a shield together with an Arduino standard motherboard (see this link). I am not sure why the TWI examples uses these definitions. It may be due to simplicity (no need to make new SCL and SDA definitions when it works perfectly well to use the arduino definitions). Also, it doesn't really matter which pins are being used, as long as you connect it correctly to the TWI sensor.

    Regarding board mapping, I think the current approach used in the SDK is a good way of doing it. The examples in the SDK are written in a manner that is independent of the board used, which makes it possible to create one single project, for many different boards.

    This is achieved by being consistent regarding the definition names. E.g. in the TWI scanner example, the definitions ARDUINO_SCL_PIN and ARDUINO_SDA_PIN are used, and if you look at the files components\boards\pca10040.h and components\boards\pca10056.h, both contain these definitions (In this case they are assigned the same pin values, but this is not always the case). Then you can easily switch board by adding the appropriate preprocessor definition, and boards.h will include the correct board mapping. E.g. BOARD_PCA10040 will include the pca10040.h file and make the project compatible with the nRF52832 DK.

    If you can't find your board in components\boards then you would need to create your own custom header file custom_board.h with the appropriate definitions (remember to use the same naming conventions as the example projects).

    Best regards,

    Simon

  • If you can't find your board in components\boards then you would need to create your own custom header file custom_board.h with the appropriate definitions (remember to use the same naming conventions as the example projects).

    ^ THIS. Let me try to ask in more simple way. I have new board and I need to create custom_board.h, but I believe, by best practices, it should not be included in SDK folder. It should be included in project folder. Is it possible? Does it make sense? Then I would not put any preprocessor symbol like BOARD_CUSTOM or BOARD_PCAxxxxx. Would it be correct? 

  • It's only header file, without any logic. It must be separated from code logic (SDK) in order to easily make transition on another SDK deployment: ie. wipeout NRF5_SDK folder and unzip new NRF5 SDK folder. That's how software architecture & development should be. Layers, modules, separate business logic, etc.

Reply Children
No Data
Related