pca10059 device won't pair with TWIM enabled, except in debug mode

I've based my code upon the HIDS keyboard example and added code to support an attached polled sensor with I2C interface. The device will pair with the Android phone just fine when using the debugger through a JTAG mini, but I need to disable the TWIM interface if I want the device to pair outside the debugger. Do I need to change priority settings somehow?

  • I was able to program the open USB bootloader and MBR using the debug port and then subsequently program the application without attaching the JTAG at all, and the application doesn't even start. The LF clock is set to XTAL (NRFX_CLOCK_CONFIG_LF_SRC). The memory reads back ok, and I adjusted the placement macros to make room for everything. what am I doing wrong?

  • There can be some glitches on the pins when doing a hard reset, however I don't see how this should affect the the serial transfer later. Are you sure the twi sensor is reset here when pushing the reset button (and not only the nRF)? Maybe the twi sensor is in a configured state while the nRF52 is trying to configure it.

    Kenneth

  • OK, using the blue LED I was able to track down where the failure occurs - the call to nrf_sdh_enable_request is erroring out when it tries to enable the softdevice and returns the following error: @retval ::NRF_ERROR_INVALID_STATE SoftDevice is already enabled, and the clock source and fault handler cannot be updated. I'm stumped as to why this error would occur when running without the debugger only. Thoughts as to how to fix this?

  • Problem still persists but I've got more information. Some of the issues I've been having had to do with programming the UICR for 3V GPIO - the particular sensor I'm using doesn't seem to like that (even though it's powered off the 3V Vdd_nrf supply, and the SDA and SDL lines are of course open collector). Once I set the board type to PCA10056 instead of PCA10059 the I2C interface started working as expected. But the issues with advertising without the debugger persist. It seems the following sequence might be the critical clue but I have no idea what it means:1) Build and debug (I've populated the JTAG connector on the PCA10059 board and am using a JTAG mini). 2) Dongle advertises and connects correctly. 3) Stop the debugger and try to pair the device through the Android settings but the device either never shows up in the advertising list or doesn't pair 4) In SES, click Target->Connect J-link 5) Device connects and pairs as normal. None of the other methods of programming the firmware (using the nRF Connect for desktop full erase and write, or using "Build and Run" vs "Build and Debug") result in the device showing up in the Android advertising list, although it appears and pairs without issue using nRF Connect for Android. what does that "connect to Jlink" command do exactly? I've also found an issue that makes the softdevice not run: When the code calls nrf_sdh_enable_request, sd_softdevice_enable is returning a NRF_ERROR_INVALID_STATE error code. I can bypass this error if I modify nrf_sch.c to not run the enable if the softdevice is already enabled using sd_softdevice_is_enabled. Could this be part of the issue?

Related