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

I2C code problem

Hi

I am new to nrf52840. I am trying to communicate on I2C bus with Cypress semiconductor CY8CMBR3116 capacitive touch  IC. Some how I am able to connect the on I2C bus. And I am also able to read the required data register. My goal is to set the status of the led1 and led2 on and off when the touch presence on the touch button is detected.  I am working on nrf52840 DK (PCA10056). I have studied  the TWI SENSOR example present in the SDK and I have edited the same code according to my requirement and my touch inputs from the buttons are coming properly on the I2C bus. Below is my source code :

My questions :

1.  The data_handler function scans if there is an actual touch detected at the button. It compares the value of the read register with the desired value . If the value matches the touch is reported.

 if((temp & 0x08)!= 0)
  {
   nrf_gpio_pin_write(led1, 0);
  }

the above code scans the touch button input on I2C bus. but it does not set the state of the led permanently, The led just glows until the touch input is there. but I think the led should light up permanently at single input of the touch sensor.

My motive is to set the status permanently at each touch button input. Please suggest.

2.  Whenever I delete the below code lines from the main function the code just stops working.

APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("\r\nTWI sensor example started.");
    NRF_LOG_FLUSH()

I think the above code lines are not related I2C transactions, then why are the causing problems if I delete them.

Please help with the above questions.

Thanks

Parents Reply Children
No Data
Related