RSL 10 I2C setup doubt

Hi,

Im trying to make a RSL10-sense-db-gevk interface with the sensor HTS221, using i2c.

At first, i’ve made the sensor communicate with an Arduino, using a pre built library, and it worked fine, so i know the library and the sensor works.

So i’ve downloaded the ONsemi IDE and all the required drivers, including drivers for the debugging, then i’ve copied the i2c_cmsis_driver code to start with, and after some studying, i’ve found out that i have to use the “i2c->MasterTransmit” and “i2c->MasterReceive” functions to communicate with the sensor, because i want the rsl10 to be the master and the HTS221 to be the slave.

Then, i’ve copied all the hts221 arduino library and ported all the functions to make them work with the rsl10.

The thing is, it doesnt work, and after putting a PRINTF to show whats going on the i2c, i saw that i am not getting any data from it,
image

Do you know what i am doing wrong? I’ve setup the i2c as master and i thinkg i am using the driver correctly.

I’ve attached the app.c file.

Thank you.
app.c (16,3,KB)

Hi @felipe.gomes

I believe that the difference between the Arduino and CMSIS-Driver APIs is that Arduino is blocking while CMSIS-Driver is not blocking.

So if you want to execute a sequence of events you either need to use the callbacks to drive the next step or wait until the previous operation completes.

You can add

while (i2c->GetStatus().busy);

after each MasterTransmit and MasterReceive call to block and check that the return values are always ARM_DRIVER_OK.

Ref: CMSIS-Driver documentation on MasterTransmit function: I2C Interface

The function is non-blocking and returns as soon as the driver has started the operation. During the operation it is not allowed to call any Master function again. Also the data buffer must stay allocated and the contents of data must not be modified. When transmit operation has finished the ARM_I2C_EVENT_TRANSFER_DONE event is generated. When not all the data is transferred then the ARM_I2C_EVENT_TRANSFER_INCOMPLETE flag is set at the same time.

Best regards,
Lukas

1 Like

Hi Lukas

Thanks for the info, i’ve added the blocking while in all operations that use the MasterTransmit and receive.

But i am still not getting any data from the I2C of the device, i’ve checked the flag when i initiliaze the i2c, and it is returning that “ARM DRIVER OK”, but i dont understand why i am still not getting any data using the MasterReceive function.

Do i have to add pull up resistor on the line, or something like that?

Thanks for the help.

Hi @felipe.gomes

The library should use internal pull up resistors by default.

Looking at the writeRegister function you have, I think it should be modified to do the register write in single MasterTransmit operation.
Can you try to change your writeRegister function like this?

int writeRegister(uint8_t slaveAddress, uint8_t regToWrite, uint8_t dataToWrite)
{
    int32_t status;
    uint8_t data[2];
    data[0] = regToWrite;
    data[1] = dataToWrite;

    status = i2c->MasterTransmit(slaveAddress, data, 2, false);
    while (i2c->GetStatus().busy);
}