NRF51822 reset handler

chunt11 gravatar image

asked 2018-01-13 21:08:40 +0100

updated 2018-01-16 17:40:43 +0100

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:

edit retag flag offensive close delete report spam


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 ...(more)

AmbystomaLabs ( 2018-01-14 18:21:51 +0100 )editconvert to answer

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

Martin Børs-Lind ( 2018-01-15 17:48:20 +0100 )editconvert to answer

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

Chris Hunt ( 2018-01-15 19:46:07 +0100 )editconvert to answer

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?

AmbystomaLabs ( 2018-01-15 20:28:09 +0100 )editconvert to answer

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?

AmbystomaLabs ( 2018-01-17 00:54:57 +0100 )editconvert to answer

Yes, the topology of the network is as you described. I guess it is a bit difficult to describe what exactly the issue is. Right after flashing any device, it works as expected. For the hub, this entails receiving packets from each node over ESB and receiving and sending commands to the usb. Each node also reads data from its sensor over I2C and sends that data to the hub over ESB. Additionally, I get the expected behavior after I reset a device using a reset button. However, if I simply power on a device (say by plugging in the MK20 to the PC USB port or connecting a node to a battery), I no longer get the expected behavior. For the hub, it does not respond to any UART commands and the nodes no longer respond to GPIO events. However, they seem to both still undergo ESB communication. That ...(more)

Chris Hunt ( 2018-01-17 02:36:11 +0100 )editconvert to answer

Sorry for the delay. I had an all day meeting yesterday.

I tried out the code on a 51822dk but it seems like I will have to set up quite a bit of hardware to make it all talk.

Just based on your comments and I own experience with UART's, I would guess some garbage is coming down the pipe from the usb transceiver on boot or since there is no flow control the uart just doesn't sync up correctly first time around. This is why the RX buffer has data and you get an event from it. Then my next guess is that it fails to parse correctly in the switch and things fall apart from there.

Assuming that the real issue is data in the RX buffer, some simple solutions you can try are to: 1. put a delay before you init the uart. This will ...(more)

AmbystomaLabs ( 2018-01-18 20:21:16 +0100 )editconvert to answer