Good day
I am developing on the nrf9160dk with a tag reader using i2c and am wanting to know if there is a function to pull down the SDA or SCL pins during operation in order to wake up the slave device.
Thank you in advance.
Kind regards,
Hassan
Good day
I am developing on the nrf9160dk with a tag reader using i2c and am wanting to know if there is a function to pull down the SDA or SCL pins during operation in order to wake up the slave device.
Thank you in advance.
Kind regards,
Hassan
Hi, thank you for the reply. This is the extent of what the documentation states. Thank you !
6.1.1 Start condition Start is identified by a falling edge of serial data (SDA) while the serial clock (SCL) is stable in the high state. A Start condition must precede any data transfer command. The device continuously monitors (except during a write cycle) the SDA and the SCL for a Start condition, and does not respond unless one is given.
HI, do you mind sending the name or a link to that function so I may see how it works. I can't seem to find it
Yes, I have used instruments to test and have found that by using an internal pull-up resister, the pin signal level doesnt drop enough.
I am still not able to find this function. I am not sure you understand my question. Please refer me to where the start condition is handled.
There is no function for this because it is handled in HW.
Oh I see okay thank you ! so would I just need to use
The TWIM peripheral must be configured to transmit data before you can trigger the start task. It is easier to just use the driver APIs to start a transaction as it will take care of the configurations for you.
Good afternoon
By driver API's, do you mean this function.
Yes, this is our function to start a TWI transfer. However, in general, we recommend to use the Zephyr's driver APIs when possible (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/i2c.html). You can have a look at the i2c_fujitsu_fram driver sample in the Zephyr tree for an example of how this API can be used.
Kind regards,
Vidar
Yes, this is our function to start a TWI transfer. However, in general, we recommend to use the Zephyr's driver APIs when possible (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/i2c.html). You can have a look at the i2c_fujitsu_fram driver sample in the Zephyr tree for an example of how this API can be used.
Kind regards,
Vidar
Good day,
I've attempted using these functions and APIs and when I test the board with the multimeter, pin 30 and 31 (my i2c2 pins) get zero voltage output. Do the pins start the output in the prj file or when a write/read sequence is initiated?
Kind regards,
Hassan
My code is as follows:
main.c
#include <zephyr/zephyr.h>
#include <drivers/i2c.h>
#include <stdio.h>
#include <nrfx_twim.h>
#include <C:\nordicsemi\v2.1.1\modules\hal\nordic\nrfx\hal\nrf_gpio.h>
#include <hal/nrf_twim.h>
/** I2C address to be used for ST25DV Data accesses. */
#define ST25DV_ADDR_DATA_I2C 0x53
/** I2C address to be used for ST25DV System accesses. */
#define ST25DV_ADDR_SYST_I2C 0x57
void Delay(int n)
{
int c, d;
for (c = 1; c <= n; c++)
for (d = 1; d <= n; d++)
{}
return 0;
}
void main(void)
{
// *************START************* //
const struct device * i2c_dev;
i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c2));
if (i2c_dev == NULL) {
printk("Unable to bind !\n");
return;
}
//************** DEVICE SELECT CODE**************//
const uint8_t devSelCode[8] = {1, 0, 1, 0, 0, 1, 1, 0};
int err1 = i2c_write(i2c_dev,devSelCode,8,ST25DV_ADDR_DATA_I2C);
printk("Device select msg: %d", err1);
}
prj
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_I2C=y
# CONFIG_LOG=y
Is there possibly something wrong in my configuration that I am not seeing an output in my specified i2c2 pins? Thank you for your help!
It seems like you don't have external pull-ups on the SDA and SCL lines as you measure 0 V on both . In that case, you will need to enable the internal pull-up resistors by adding the bias-pull-up property to your pin assignment in the device tree.
&pinctrl {
i2c2_default: i2c2_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
<NRF_PSEL(TWIM_SCL, 0, 31)>;
bias-pull-up;
};
};
i2c2_sleep: i2c2_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
<NRF_PSEL(TWIM_SCL, 0, 31)>;
low-power-enable;
};
};
};
HI
This has helped! Am now seeing an output when the program starts as well as the drop of output on the SDA line when writing to the i2c2 . However, the write function still returning an error value. Other than the slave address or device function code being incorrect, are there any other reasons for the function to fail?
Hi,
Can you turn on logging to see what the error is?