nRF52840 Mini and Serial Print

My apologies if I posted this to the wrong forum but it is a basic programming issue but specific to the new nRF52840 board I bought. I can get part of the BLE example code running (LED on/off control via tablet, but not PBswitch read) I can get standard Blinky example running, but I can not get a simple Serial.println(“hello”); working. I have done so successfully with several other arduino boards but not the nRF52. I need to test some of my SPI and I2C code with this ARM MCU and will need “printing” to help me debug the port. This works on a nano but not the new board.

Serial.begin(9600); // Serial is the USB serial port

Serial.println(“HELLO”);

Any help or suggestions appreciated.

Hi fetcorp,

If you are printing via serial during your setup, try adding in a while loop like this:

Serial.begin(9600);
  while ( !Serial );
  Serial.println("Ready!");
  delay(500);

That should fix the issue in setup. For debugging in your loop, Serial.println(); should work just fine. Let us know if you run into any other issues or cannot get your Pro nRF52840 Mini printing serial data and we can troubleshoot further.

Hi,

Thanks for the suggestion, but it doesn’t work either. With a normal Arduino, I am connected to the MCU via a USB to Serial (Rx/Tx) FTDI chip, directly into the Rx/Tx pins of the Atmega328p MCU for example. With the nRF52840, there is a native USB 2.0 port on the MCU itself, so it is a direct connect. There are also assigned Rx/Tx pins on the MCU.

Given a normal Serial.println isn’t working with the nRF52840, is it possible that a Serial.println is being compiled to be directed out the Rx/Tx port instead of back up the USB connection?

I can’t think of why else something so basic as a “print” statement will not work.

Thanks in advance.

Jim

Hmm, well that is strange. I’m having no issues using the method I outlined in my previous post with a known good Pro nRF52840 in my testing so I’m not entirely sure what is going on here. Calling “Serial.print();” should route to the USB port since Serial1 is hardware serial and is routed to pins 17 (TX) and 15 (RX). You could try connecting those pins to a 3.3V FTDI or similar USB to Serial converter and see if you’re seeing the serial data there but I would be really surprised if that is the case.

Do you have the SparkFun board definition added into the Adafruit nRF package? There was a small issue that we fixed roughly a month ago related to using serial so if you installed the board definitions following the instructions outlined in our [nRF52840 Development with Arduino and CircuitPython Guide longer than a month ago, try going back through those steps and re-installing the Pro nRF52840’s custom board definition. Even if you did install them after the fix was pushed, re-installing the board definition may fix the problem for you.](https://learn.sparkfun.com/tutorials/nrf52840-development-with-arduino-and-circuitpython#arduino-installation)

Hi TS_Mark,

Am using VS Code and GCC to compile and flash my code onto the board, which is nrf52840.

Need to debug the code now as some codes probably is missing.

Hv been searching for debugging tools/software/hardware necessary to do it. No joy find one that fit the board.

Are you able to recommend me all the debugging tools necessary, pls?

I hv found this kind soul sharing this:

https://iosoft.blog/2019/09/28/arm-gcc- … dic-nrf52/

But it required another RPi and complicated set up.

And probably best illustration found.

i also found these, explaining how to setup the luanch.json

https://code.visualstudio.com/docs/cpp/ … -reference

https://code.visualstudio.com/docs/editor/debugging

But i still unable to relate what hardware required or specific setting to the board/application/Nordic SDKs.

Is there a way around, without using any extra hardware to debug the code?

https://store.makerdiary.com/blogs/tuto … tudio-code

It come across that this is a tools nordic recommended:

https://www.segger.com/products/develop … /debugger/

Do i need this to debug? which brand/model/version/series best fit?

Your kind advice, pls. Really appreciate if we can found some form of guide for this board:

https://learn.sparkfun.com/tutorials/nr … e-nrf5-sdk

Rgds