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

nrf51822 not working in non-Debug mode

I have nrf51822 controlling 2 I2C devices:

  1. OLED display - SSD1306
  2. Capacitive touch sensor - CAP1203

When in debug mode I get images on display, however when i disconnect debugger I dont get any output on the screen. Why would it work differently in a non-debug mode?

Second problem is that CAP1203 generates interrupt by pulling IRQ line low and then I need to issue I2C command to clear the register so that the IRQ line would be released. In debug step-by-step mode if I do it step by step I get GPIO interrupt, process it send I2C command and it works. In debug mode but without step-by-step the first time I receive interrupt correctly and then IRQ line doesnt get released. Any idea what could be wrong?

Thanks!

  • It sounds like it could be a timing issue with the configurations of the various parts. It could be that some part of the initialization is going too fast for the display/sensor to handle it in normal mode, but when you step through in debug mode t works. Also, make sure that the 16 MHz is running as expected, in debug mode this is forced on, and that could be the potential difference that makes this work in debug mode, but not in normal mode.

  • Asbjørn, thanks looks like you are right about the clock. I implicitly turned it on and it seems to work now. Funny thing though that without turning HFclock sometimes it works and sometimes doesnt, so very random. Regarding I2C operation seems like you are right as well. Strange they dont write about that in datasheet. Thanks a lot!

  • How are you forcing the HFCLK on? Are you able to verify by for example an oscilloscope that the external 16 MHz is actually running? Have you tried adding some delays in the initialization? Did that have any effect? Try initializing the peripherals and timers with the softdevice safe sd_ commands after you have started up the stack/softdevice. Is it asserting or is it still running once you enable the softdevice?

  • Forgive me, but I would love to add to this answer in the case that other people may run into a variation of this problem.

    My problem is that I had two (or more) spi sensors on the same nrf spi bus. I would notice that when I retrieved data from my sensors, that I would be able to get data from one sensor and not from the other(s).

    Solution: I had performed my initialization of all my sensors back to back. Therefore, the second (or more) sensor(s) were unable to recognize that the nrf was talking to it. Therefore, my other devices were never initialized. I added a 100ms delay between each initialization and, everything worked perfectly when I applied power without the debugger starting the application.

  • Dear Sergy, Can you please send me the CAP1203 I2C driver? I am trying to use nrf_drv_twi_tx (with no stop condition) and nrf_drv_twi_rx

    BUT the problem is that CAP1203 does not respond back to the address sent by nRF52832. I have seen on oscilloscope that nRF52832 is sending the address and start condition but no response from CAP1203. Here is where my code stucks:

    err_code = nrf_drv_twi_tx(&m_twi_mag3110, dev_addr, &reg_addr, 1, true);  	//Write the address with no stop condition
    

    Your help in this regard will really be appreciated.

Related