NRF52840DK - Serial and Debug not working

Nick_Savva
Mon, 13 Mar 2023 19:10:43 +0000
Bugs

Hi,

Been trying out Mbed today with an NRF52840-dk board, have run into a few issues pretty early on:
I’ve loaded the simple “mbed-os-example-blinky-baremetal” example and got it running at least.
Building, downloading the binary and drop-n-dragging works. Building or debugging directly does not, not sure how to diagnose this issue. This is what I see if I try to debug:

....
Build succeeded
Preparing to run
Parse debug description...
Create system description...
Connect to debug unit (CMSIS-DAP)...
Configure debug unit (SWD @ 10000000 Hz)...
Create device map...
Connect ('haltOnConnect') to device nRF52832_xxAA...
Device connected
Halt...
Device halted after connect
Reset ('auto')...
Reset completed
Add Flash Algorithm...
	'nRF52xxx' (0x00000000 - 0x001fffff)
Add Flash Algorithm...
	'nRF52xxx UICR Erase' (0x10001000 - 0x10001fff)
Load application...
Erase sectors...
ERROR: Memory read failed (@0x20000000)
ERROR: Memory read failed (@0x20000000)
ERROR: Failed to download flash algorithm
ERROR: Failed to erase flash
Skipped reset & run target
Disconnect from device...
Disconnect from debug unit...

I can’t seem to get the serial implementation to work either. It’s odd becuase Printf seems to work, I can see the output on the terminal.
I just want to simply receive characters over UART, so I go with the simple blocking UART example to see if I can get at least anything:

static BufferedSerial serial_port(USBTX, USBRX);


int main() {

  // Set desired properties (9600-8-N-1).
  serial_port.set_baud(9600);
  serial_port.set_format(
      /* bits */ 8,
      /* parity */ BufferedSerial::None,
      /* stop bit */ 1);

  // Application buffer to receive the data
  char buf[256] = {0};

  while (true) {

    if (uint32_t num = serial_port.read(buf, sizeof(buf))) {
      // Echo the input back to the terminal.
      serial_port.write(buf, num);
    }
   }

}

This example just hangs forever. I can see the debug interface of the board receive something as the LED blinks everytime I send a character over UART, but the app isn’t.

1 post - 1 participant