I had a mbed firmware running on a ST Nucleo 64 that periodically query a sensor for data. It only use the I2C, a button interrupt and a LED for heartbeat. I ported it to a nRF51 target by changing the pin numbers. The firmware compiled just fine. And the firmware runs on the nRF51-DK without any hard fault. The heartbeat LED toggle periodically as it should, debugging UART messages are being printed out in the correct order.
However there is a problem in the I2C communication.
For I2C write, consistently, I2C write would fail once, then succeed once, and repeat.
For I2C read, I used a function that would read three times. This function would succeed twice, fail once, and repeat...
The most bizarre thing is that this failing behavior has a consistent pattern to it.
What could be going on here?
Update:
I encountered this issue while working with the X-NUCLEO-1KS01A1 shield. Both this shield and the nRF51 DK has Arduino UNO Rev 3 compliance connectors. However, they have some conflicts where the shield's data ready signals overlap with the nRF51 DK's buttons. So I started by connecting them together using jumper wires. Apparently this is what causes the issue. When I try to connect the two board using the Arduino headers, the issue is resolved.
However, I still would like to resolve this issue. As mentioned, the boards has pin conflicts, so I would rather avoid having to connect them using the Arduino headers