8 years, 8 months ago.

I can not use the I2C Class in nRF51-DK(Again)

I can not use the I2C Class in nRF51-DK. There is no signal at p6 or p5. I set the I2C class as like below.

and I call the function that use the I2C members.

<< code >>

  1. #define hksSda p6
  2. #define hksScl p5

I2C i2c(hksSda,hksScl);

void TestDigitalOut(void)

{

char cdData[2];

int iAddr,iCount=0;

int iResult=0;

iAddr=0xa0;

cdData[0]=0;

cdData[1]=0;

i2c.write(iAddr,cdData,1,false);

i2c.read(iAddr+1,cdData,2,true);

}

Question relating to:

use UART Service to loopback anything received on the TX characteristic onto the RX. BLE, nRF UART

It is not clear what you're asking here. You've made a claim that the I2C class isn't usable on the nRF51-DK, but you haven't explained the problem clearly. Can you also please better formatting for the code so it is more readable for those who may attempt to provide an answer? Please refer to 'Editing tips' at the bottom right of the text-edit window. You might benefit from using "<<code>>" to surround your code.

posted by Rohit Grover 08 Sep 2015

1 Answer

8 years, 8 months ago.

You use p5 and p6.
If you look at the pin picture https://developer.mbed.org/platforms/Nordic-nRF51-DK/...should be P0.07 and P0.30
If you look at the file PinNames.h , you find P0.07 = p7 and P0.30=p30 and most important:
I2C_SDA0 = p30, I2C_SCL0 = p7,
Maybe this can help you (I do not have a NRF51-DK to test )