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

DTM with nRF52832 (NINA B112) on custom board and nRFgo Studio: defining correct UART pins

Hello,

I have a fewURGENT questions.

I have the NINA B112 by u-blox on a custom PCB (datasheet here). We require regulatory testing of the BLE. The NINA B112 is based on Nordic's nRF52832 Bluetooth module (info here and here); therefore, I think it would be useful for our testing facility to be able to use nRFgo Studio together with the nRF52832/NINA B112 in Direct Test Mode (DTM) (info here).

Here is some info on my setup. I have Nordic's SDK v15.3.0 (info here). Development is on a Windows10 PC. I am using a gcc based compiler; I am using the GNU Tools ARM Embedded toolchain (version 8.3.1, found here) which I point to in Makefile.windows in ...nRF5_SDK_15.3.0_59ac345\components\toolchain\gcc. I am compiling using the makefile in ...nRF5_SDK_15.3.0_59ac345\examples\dtm\direct_test_mode\myboard\blank\armgcc. My build tool is make.exe from MinGW (found here) with the path MinGW\msys\1.0\bin which I run in a command window using Git Bash (found here). I am editing the source code using Visual Studio Code and/or Notepad++. I am flashing the nRF52832 using a Segger J-Link connected to the SWDIO/SWDIO pins on the NINA B112. The UART pins are converted to RS-232 levels on the custom PCB. I am using a RS-232/USB converter to interface with the PC.

Below is the schematic of the NINA B112 on the custom PCB. For DTM, I am only interested in using the UART pins (shown as pins 20,21,22, and 23 for RTS, CTS, TXD, and RXD, respectively), and the BLE antenna, obviously (note: the antenna is integrated on the NINA B112).

I modified the pca10040.h file in ...\nRF5_SDK_15.3.0_59ac345\components\boards and renamed it myboard.h. I modified boards.h (in ...\nRF5_SDK_15.3.0_59ac345\components\boards) with the lines #elif defined(BOARD_MYBOARD) #include "myboard.h". The board file is shown below in its entirety (edit: I changed the pin numbers thanks to the response of one contributor. See comments below).

#ifndef MYBOARD_H
#define MYBOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include "nrf_gpio.h"

/* default GPIO nRF52832
#define RX_PIN_NUMBER  8
#define TX_PIN_NUMBER  6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
#define HWFC           true
*/
// NINA UART GPIO pins
#define RX_PIN_NUMBER  5
#define TX_PIN_NUMBER  6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 31
#define HWFC           false


#ifdef __cplusplus
}
#endif

#endif // MYBOARD_H

As can be seen in myboard.h, most of the functionality included on pca10040 has been removed (buttons, switches, LEDs, Arduino interfacing, etc.). We require only the UART functionality. I defined the UART pins to those shown in the schematic above, and disabled hardware flow control.

After flashing this code to the nRF52832/NINA B112, I attempt to connect to nRFgo Studio in the Direct test Mode but get the following error: "An error has occurred in the serial connection. Please ensure everything is connected correctly". See screenshot below.

I am on the correct serial port. I swapped the Tx/Rx pins and confirmed this is not the problem. When I scope the Tx/Rx RS-232 pins on our PCB, when idle the voltage levels are -5.4V and -9.5V, respectively, which is as expected. When I click the "Start Test" button in nRFgo Studio, I see the following waveform (blue trace -> Rx, yellow -> Tx). It looks like nRFgo Studio is attempting to connect to the nRF52832/NINA B112, but there is no response.

Q1 - Is the output waveform from nRFgo Studio what I should expect?

I think one potential issue is this: I don't think I have the correct UART pin numbers/names. The pin naming/numbering convention used on the NINA B112 appears to be different than on the nRF52832. The pinout of the nRF52832 is shown below for reference.

For example, the antenna pin is pin 30 on the nRF52832 but is pin 13 on the NINA B112. Further, the SWDIO/SWDCLK pins are pins 26/25 on the nRF52832 but are pins 15/11 on the NINA B112. The default UART pins are 5,6,7, and 8 on the nRF52832, but we are physically connected to pins 20,21,22,ans 23. I know the GPIO pins can be remapped to UART pins on the nRF52832, but I am not sure how the nRF52832 pins connect to those on the NINA B112.

Q2 - Can anyone help me determine the correct UART pin numbers for this application? (edit: I think I have the correct pin numbers now, thanks to one of the comments below, but I still get the same error in nRfgo Studio).

It doesn't look like there are any other changes that need to be made in the source code. The main.c source code (found in ...nRF5_SDK_15.3.0_59ac345\examples\dtm\direct_test_mode) includes a function call to uart_init() which is shown below.

/**@brief Function for UART initialization.
 */
static void uart_init(void)
{   
    uint32_t err_code;
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          APP_UART_FLOW_CONTROL_DISABLED,
          false,
          DTM_BITRATE
      };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_error_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);

    APP_ERROR_CHECK(err_code);
}

The struct app_uart_comm_params_t is defined in app_uart.h (found in ...\nRF5_SDK_15.3.0_59ac345\components\libraries\uart) and is shown below.

/**@brief UART communication structure holding configuration settings for the peripheral.
 */
typedef struct
{
    uint32_t                rx_pin_no;    /**< RX pin number. */
    uint32_t                tx_pin_no;    /**< TX pin number. */
    uint32_t                rts_pin_no;   /**< RTS pin number, only used if flow control is enabled. */
    uint32_t                cts_pin_no;   /**< CTS pin number, only used if flow control is enabled. */
    app_uart_flow_control_t flow_control; /**< Flow control setting, if flow control is used, the system will use low power UART mode, based on CTS signal. */
    bool                    use_parity;   /**< Even parity if TRUE, no parity if FALSE. */
    uint32_t                baud_rate;    /**< Baud rate configuration. */
} app_uart_comm_params_t;

From the above two code snippets, it looks like comm_params.rx_pin_no = RX_PIN_NUMBER, etc., which should match the definitions in myboard.h. It doesn't look like there are any other changes that need to be made.

Q3 - Are there any other modifications that need to be made in the source code?

Thank you.

Mark

Parents
  • Hi Mark

    Does the nRFGo Studio error still persist? The error message pretty much sums it up and indicates that something isn't connected correctly. Please double check your wiring and check that the pin assignments are correct. Are you using a DK as a bridge for this test? In that case, make sure that nothing is connected in parallel on the UART lines (I.E. that the nRF on the DK isn't interfering).

    The above post is a bit hard to keep track of, so please state which pins you've assigned as UART in your application and which physical pins you're using at the moment.

    It shouldn't be necessary with any further modifications to the DTM application.

    Best regards,

    Simon

  • Hello again. I have the UART working now, but I still get the error in nRFgo Studio. The problem was that I wasn't properly including myboard.h so the changes I made to the UART pin definitions didn't hold (was using those defined in pca10040.h instead). I also had to completely copy the code in pca10040.h, and limit my changes to just those 5 lines associated with UART (i.e. I had to leave in all the lines associate with serialization, spi, etc.). I didn't change any of these lines: could this be the problem? See myboard.h below.

    #ifndef MYBOARD_H
    #define MYBOARD_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include "nrf_gpio.h"
    
    // no buttons/LEDs on MYBOARD
    // LEDs definitions for PCA10040
    #define LEDS_NUMBER    4
    
    #define LED_START      17
    #define LED_1          17
    #define LED_2          18
    #define LED_3          19
    #define LED_4          20
    #define LED_STOP       20
    
    #define LEDS_ACTIVE_STATE 0
    
    #define LEDS_INV_MASK  LEDS_MASK
    
    #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }
    
    #define BSP_LED_0      LED_1
    #define BSP_LED_1      LED_2
    #define BSP_LED_2      LED_3
    #define BSP_LED_3      LED_4
    
    #define BUTTONS_NUMBER 4
    
    #define BUTTON_START   13
    #define BUTTON_1       13
    #define BUTTON_2       14
    #define BUTTON_3       15
    #define BUTTON_4       16
    #define BUTTON_STOP    16
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_ACTIVE_STATE 0
    
    #define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4 }
    
    #define BSP_BUTTON_0   BUTTON_1
    #define BSP_BUTTON_1   BUTTON_2
    #define BSP_BUTTON_2   BUTTON_3
    #define BSP_BUTTON_3   BUTTON_4
    
    
    /* default GPIO nRF52832
    #define RX_PIN_NUMBER  8
    #define TX_PIN_NUMBER  6
    #define CTS_PIN_NUMBER 7
    #define RTS_PIN_NUMBER 5
    #define HWFC           true
    */
    // NINA UART GPIO pins
    #define RX_PIN_NUMBER  5
    #define TX_PIN_NUMBER  6
    #define CTS_PIN_NUMBER 7
    #define RTS_PIN_NUMBER 31
    #define HWFC           false
    
    // no SPI signals on MYBOARD?
    #define SPIS_MISO_PIN   28  // SPI MISO signal.
    #define SPIS_CSN_PIN    12  // SPI CSN signal.
    #define SPIS_MOSI_PIN   25  // SPI MOSI signal.
    #define SPIS_SCK_PIN    29  // SPI SCK signal.
    
    #define SPIM0_SCK_PIN   29  // SPI clock GPIO pin number.
    #define SPIM0_MOSI_PIN  25  // SPI Master Out Slave In GPIO pin number.
    #define SPIM0_MISO_PIN  28  // SPI Master In Slave Out GPIO pin number.
    #define SPIM0_SS_PIN    12  // SPI Slave Select GPIO pin number.
    
    #define SPIM1_SCK_PIN   2   // SPI clock GPIO pin number.
    #define SPIM1_MOSI_PIN  3   // SPI Master Out Slave In GPIO pin number.
    #define SPIM1_MISO_PIN  4   // SPI Master In Slave Out GPIO pin number.
    #define SPIM1_SS_PIN    5   // SPI Slave Select GPIO pin number.
    
    #define SPIM2_SCK_PIN   12  // SPI clock GPIO pin number.
    #define SPIM2_MOSI_PIN  13  // SPI Master Out Slave In GPIO pin number.
    #define SPIM2_MISO_PIN  14  // SPI Master In Slave Out GPIO pin number.
    #define SPIM2_SS_PIN    15  // SPI Slave Select GPIO pin number.
    
    
    // no serialization APPLICATION board on MYBOARD??
    // serialization APPLICATION board - temp. setup for running serialized MEMU tests
    #define SER_APP_RX_PIN              23    // UART RX pin number.
    #define SER_APP_TX_PIN              24    // UART TX pin number.
    #define SER_APP_CTS_PIN             2     // UART Clear To Send pin number.
    #define SER_APP_RTS_PIN             25    // UART Request To Send pin number.
    
    #define SER_APP_SPIM0_SCK_PIN       27     // SPI clock GPIO pin number.
    #define SER_APP_SPIM0_MOSI_PIN      2      // SPI Master Out Slave In GPIO pin number
    #define SER_APP_SPIM0_MISO_PIN      26     // SPI Master In Slave Out GPIO pin number
    #define SER_APP_SPIM0_SS_PIN        23     // SPI Slave Select GPIO pin number
    #define SER_APP_SPIM0_RDY_PIN       25     // SPI READY GPIO pin number
    #define SER_APP_SPIM0_REQ_PIN       24     // SPI REQUEST GPIO pin number
    
    // serialization CONNECTIVITY board
    #define SER_CON_RX_PIN              24    // UART RX pin number.
    #define SER_CON_TX_PIN              23    // UART TX pin number.
    #define SER_CON_CTS_PIN             25    // UART Clear To Send pin number. Not used if HWFC is set to false.
    #define SER_CON_RTS_PIN             2     // UART Request To Send pin number. Not used if HWFC is set to false.
    
    
    #define SER_CON_SPIS_SCK_PIN        27    // SPI SCK signal.
    #define SER_CON_SPIS_MOSI_PIN       2     // SPI MOSI signal.
    #define SER_CON_SPIS_MISO_PIN       26    // SPI MISO signal.
    #define SER_CON_SPIS_CSN_PIN        23    // SPI CSN signal.
    #define SER_CON_SPIS_RDY_PIN        25    // SPI READY GPIO pin number.
    #define SER_CON_SPIS_REQ_PIN        24    // SPI REQUEST GPIO pin number.
    
    #define SER_CONN_CHIP_RESET_PIN     11    // Pin used to reset connectivity chip
    
    
    // no Arduino on MYBOARD
    // 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
    #define ARDUINO_13_PIN              25    // Digital pin 13
    #define ARDUINO_12_PIN              24    // Digital pin 12
    #define ARDUINO_11_PIN              23    // Digital pin 11
    #define ARDUINO_10_PIN              22    // Digital pin 10
    #define ARDUINO_9_PIN               20    // Digital pin 9
    #define ARDUINO_8_PIN               19    // Digital pin 8
    
    #define ARDUINO_7_PIN               18    // Digital pin 7
    #define ARDUINO_6_PIN               17    // Digital pin 6
    #define ARDUINO_5_PIN               16    // Digital pin 5
    #define ARDUINO_4_PIN               15    // Digital pin 4
    #define ARDUINO_3_PIN               14    // Digital pin 3
    #define ARDUINO_2_PIN               13    // Digital pin 2
    #define ARDUINO_1_PIN               12    // Digital pin 1
    #define ARDUINO_0_PIN               11    // Digital pin 0
    
    #define ARDUINO_A0_PIN              3     // Analog channel 0
    #define ARDUINO_A1_PIN              4     // Analog channel 1
    #define ARDUINO_A2_PIN              28    // Analog channel 2
    #define ARDUINO_A3_PIN              29    // Analog channel 3
    #define ARDUINO_A4_PIN              30    // Analog channel 4
    #define ARDUINO_A5_PIN              31    // Analog channel 5
    
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif // MYBOARD_H

  • Hello again. I was testing with a baudrate os 115200. I returned it to the default value of 19200 and now I do not get any errors in nRFgo Studio. I see the following...

    I can go through and perform the various tests. 

  • Hi

    Please check out this case on how to set up DTM in nRFgo Studio, The initial error you experienced seems to have been due to an incorrect baud rate value.

    Best regards,

    Simon

    NOTE: nRFgo Studio is very outdated at this point, but please use the nAN34 application note as reference when setting up a DTM test.

  • Thank you, Simon.

    I've sense been able to exclude nRFgo Studio from the procedure by modifying the SDK by calling dtm_cmd() in main.c as necessary. I'm not sure if we require the use on the python script for our present purpose. I will refer to the resources you provided if we determine additional controls are necessary.

    Cheers.

Reply Children
No Data
Related