NRF51822 reset handler

Hi all,

I'm having a bit of trouble figuring out why my project using the RedBearLab BLE Nano board is not working. I'm using the NRF51822 as the hub in a star network using the ESB protocol. The hub is connected to a serial port and will return each sensor's current state when queried through the serial port. The hub works as described immediately after flash and after pin reset is activated through a button. However, the hub will not work when immediately plugged in. Although it will work once the button is pressed.

I feel as though this behavior may be because I have not configured power-on reset or the reset handler (in assembly) correctly? One strange thing I have noticed is that after button reset or initial flash, the NRF_POWER->EVENTS_RXDRDY register reads 0 and 1 as expected. However, after unplugging the hub and replugging it, that register always reads 1. This leads me to believe I am not cleaning up resources appropriately (i.e. my reset handler is not working). Any help in this regard would be greatly appreciated. Thank you for your time.

Note: I am not using any SoftDevice, if that matters at all.

EDIT: I've attached my project as a zip file. I'm using the GCC cross compiler with a single Makefile to compile the hex files. The relevant source file I've been discussing is in '/OrientationTrackingRX/source/main.c'. I've also included the board schematics in the Schematics subfolder. The BLE Nano board schematic is labeled while the USB interface I'm using is the MK20 USB schematic. I'd like the stress that I'd consider myself a newbie to serious embedded programming and would welcome any notes or critiques in general about the project structure and stuff. Please let me know if anything else is required. Thank you all!

Attached Project:

  • Sounds like whomever wrote the code failed to initialize gpio/comms correctly. I don't think you can even configure the reset vector so not much to say about configuring reset. It should go to 0x0 and then start at the MBR if running SD, or the first line of your code if not running SD.

    Some gpio/comms take a few clocks to be configured. Out of power reset everything goes back to defaults, but out of button reset this is not true. So likely the code runs, stuff gets initialized, some of it wrong and it doesn't do a button reset, some of the settings are sticky and next time around it works.

    This is especially true of the NRF_POWER-> registers.

    Also, since it is not a Nordic DK you are using it could be a hardware issue. Anything processor related takes quite a bit of current to get the ball rolling. This aspect is often is lost on new engineers.
    So, it could be some voltage dipping issue during a cold start.

  • I have never heard of NRF_POWER->EVENTS_RXDRDY. Do you mean NRF_UART->EVENTS_RXDRDY?

  • Oh I am sorry. The register is NRF_UART0->EVENTS_RXDRDY.

  • I don't think it changes anything on the possible causes. Please post your code and a schematic of the nano board if possible. How are you powering it when it fails to start correctly? Also, the serial devices you have it connected to, are these all 3volt devices?

  • Wow, quite the mix of hardware. I assumed the Red Bear was a module. Nope! It is a module with a BLE module slapped on it.

    So, can you clarify what is working and not? I assume you mean the uart on hub is not working, but I'm not sure how you could distinguish this from ESB not working, or client uart connections not working.

    Is the topology a red bear at each sensor, then ESB back to a red bear as hub, then uart to usb via MK20 to virtual uart on a PC?