This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Use I2C0 instead of UART0 (nRF5340)

Hello,

 

I work with the nRF5340 and want to use I2C0 (1-3 is reserved for other sensors in my project ). I already use I2C2 for a sensor and this works fine.

To use the I2C0, I must deactivate the UART0 because you can only use one of them. I deactivated UART0 to use I2C0. Because UART0 is necessary for the terminal output (printk-functions) I switched to RTT instead.

The problem is, when I run the program in debug mode, it won’t reach the main function. When I use “step over” the program works and the program reaches the main-function. Also the function “device_get_binding(“I2C_0”)” is successful.

 

This is my prj.conf:

CONFIG_PRINTK=y
CONFIG_CONSOLE=y

CONFIG_SERIAL=n     #disable logging (serial)
CONFIG_STDOUT_CONSOLE=y

CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y

CONFIG_DEBUG_OPTIMIZATIONS=y

#Buttons and LEDs configuration
CONFIG_DK_LIBRARY=y

#I2C
CONFIG_I2C=y
CONFIG_NRFX_TWIM=y

 

This is my overlay file:

&uart0 {
                status = "disabled";
};

&i2c0 {
        compatible = "nordic,nrf-twim";
        status = "okay";
        sda-pin = < 0x0D >;
        scl-pin = < 0x0E >;
};

 

 Below I listed some functions that are called when I run the program. The functions are always the same.

nrfx_twim_0_irq_handler
twim_irq_handler
z_impl_k_sem_give
z_unpend_first_thread

Why is there a difference between running the program and only use “step-over”?

Thank you very much for your help!

Related