This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I2C communication with nrf5340 custom board

We are using nrf5340-dk to communicate with nrf5340 custom board and trying to search for the other sensors' addresses. There is secure mode and unsecure mode CPU. Which mode to try on? We could not detect the sensors I2C addresses.

  • Hello Vivek,

    that doesn’t matter. You can use the I2C interface both as a secure and non-secure peripheral, as shown here.

    Regards,

    Markus

  • Hi Markus,

    one more question we are using toolchain version 1.5.1. In this there are 2 samples on inside nrf folder and another folder in zephyr.


    when we use nrf samples from path "v1.5.1\nrf\samples\peripheral" and put our I2C sample to check I2C address. Its failed to run in non secure mode (cpuappns). but running in secure mode (cpuapp) not able to get I2C address when running in secure mode. 

    Same sample when i am running from zephyr samples path its running properly.

    for this i have few questions:-

    > Which samples (nrf / zephyr) i have to run to check functionality of our custom board?

    > As we connected my board using nrf5340 PDK board for programming but not able to see printk log on segger IDE debug console? how can i see log using PDK board.
    I also tried hello_world samples code from zephyr. There is no printk log on console.

    Can you please help for these queries?

    As we are using Windows OS for our build environment.

  • Hello Vivek,

    shivkant sharma said:
    > Which samples (nrf / zephyr) i have to run to check functionality of our custom board?

    That depends a little on your use case. The nRF samples are tailored towards our hardware and API, but we are still using Zephyr and its interfaces as RTOS. The Zephyr samples are generic samples, based on the Zephyr API. The nRF samples will as well demonstrate the usage of our own library and driver implementations.

    For getting started with I2C, I recommend use Zephyrs API though.

    shivkant sharma said:
    > As we connected my board using nrf5340 PDK board for programming but not able to see printk log on segger IDE debug console? how can i see log using PDK board.
    I also tried hello_world samples code from zephyr. There is no printk log on console.

    That is probably due to that the SEGGER debug console is not enabled by default. You wanna make sure enabling CONFIG_USE_SEGGER_RTT and CONFIG_RTT_CONSOLE in prj.conf of your application.

    When doing so, I can recommend to disable CONFIG_UART_CONSOLE to avoid high bus loads.

    I hope this answers your questions!

    Regards,

    Markus

  • Hi Markus,

    thanks for you help now we are able to detect I2C address.

    Can you please let us know how to edit overlay file to configure different GPIOs for different functionality in overlay file?

    for example we edit this in our overlay file for working I2C:
    &i2c2 {
    status = "ok";
    compatible = "nordic,nrf-twim";
    sda-pin = < 36 >;
    scl-pin = < 37 >;
    clock-frequency = <I2C_BITRATE_STANDARD>;
    };

    Same  we need to add for our LED and button GPIO.
    Can you please help us for same how can we add for these GPIOs because we didn't find any example/ sample based on it.

    FYI

    we already tried blinky sample on our custom board but that one is not working.

  • Hello Vivek,

    the Blinky sample acutally is quite a good one to demonstrate the usage of the LEDs.

    If you want to modify the LED properties, you can do it in the overlay file as shown below for LED0:

    &led0 {
    	gpios = < &gpio0 0x1c 0x1 >;
    	label = "Green LED 0";
    };

    I hope this will help you!

    Regards,

    Markus

Related