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

I2C implementation between nrf52832 and cypress capsense button CY8CMBR2110-24LQ.

Hello!!

I want to implement I2C between nrf52832 and capsense button (CY8CMBR2110-24LQ) and want to put it to sleep mode so that I could get ~2-3uA  if there is no activity. Previously, I was using bsp_evt_handler() but wasn't able to achieve low power mode on nrf52832. The capsense is going to be pull up ( default ). 

I would appreciate any soon response. 

1. Capsense I2C lines are connected to  nrf52832 I2C lines.

2. 10 Capsense Buttons are pull up.

3. One Bi-color LED will be there.

4. Need to put in sleep mode for inactivity. 

Thanks

Parents
  • So what are you observing? Where did it fail? 1: Does it work? 2: Is the current consumption too high?

    1: If not, what happens?

    2: If so, have you tried measureing the current consumption if you don't enable the button/bsp? Does that give the current consumption you expect? Is the I2C enabled? Is it disabled again?

    BR,

    Edvin

  • Hi 

    So what are you observing? Where did it fail?

    My code isn't working for low power mode after adding cypress capsense (CY8CMBR2110-24LQ). It fails when it needs to go to System OFF. 1: No 2: Yes ~1.2mA.

    1: If you could suggest me any example how to implement I2C and then putting capsense on sleep mode for inactivity.

    2. Yes, Nothing changes on current consumption ( ~1.2mA ) for disabling button button/bsp. 

    Does that give the current consumption you expect?

    No

    Is the I2C enabled?

    I am not using I2C. I have just use bsp_evt_handler.

    Thanks

  • In what way? Does the application reset? Or does it enter system off?

    No, application doesn't reset and also enter system off.

    Did you at some point have this application running at 2-3µA?

    It was the working before with normal button interrupt and was achieving system OFF current. After replacing the button with capsense I'm not able to achieve system OFF current on inactivity.

    If you could provide some example with capsense button implementation with nrf52832 and putting it to sleep mode when there is no activity going on. 

  • Sorry. We don't have any capsense button examples.

    So try to compare your application before and after you added the capsense buttons. Is your I2C active? Does the current behave like you expect if you never enable I2C? Do you disable the I2C before you go to system off?

     

    techietech said:
    No, application doesn't reset and also enter system off.

     what does that mean? Does the device enter system off or not?

  • Hi !!

    Before implementing to I2C to my final code, I am trying to implement deep sleep state of my cypress capsense (CY8CMBR2110-24LQ) with host control (nrf52832), so I'm using TWI_SENSOR example as a reference to implement. But I am not able to write and read register properly. I am attaching my main.c below : 

    /**
     * Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
     * @defgroup tw_scanner main.c
     * @{
     * @ingroup nrf_twi_example
     * @brief TWI Sensor Example main file.
     *
     * This file contains the source code for a sample application using TWI.
     *
     */
    
    #include <stdio.h>
    #include "boards.h"
    #include "app_util_platform.h"
    #include "app_error.h"
    #include "nrf_drv_twi.h"
    #include "nrf_delay.h"
    
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    /** slave address **/
    #define DEFAULT_SLAVE_ADDRESS 0x37
    
    /** capsense i2c pins **/
    #define CAPSENSE_SCL_PIN  27
    #define CAPSENSE_SDA_PIN  26
    
    
    #define DEFAULT_SLAVE_ADDRESS	0x37	/* Factory default slave I2C address for initialization */
    
    /* TWI instance ID. */
    #define TWI_INSTANCE_ID     0
    
    /** deep sleep mode register **/
    #define REG_ADDR                 0x00
    #define IN_DEEP_SLP_VALUE        0x10
    #define OUT_DEEP_SLEEP_VALUE     0x00
    
    /* Indicates if operation on TWI has ended. */
    static volatile bool m_xfer_done = false;
    
    /* TWI instance. */
    static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
    
    uint8_t register_address[2] = {REG_ADDR, IN_DEEP_SLP_VALUE};    //Address of the register to be read
        
    /**
     * @brief TWI initialization.
     */
    void twi_init (void)
    {
        ret_code_t err_code;    
        const nrf_drv_twi_config_t twi_config = {
           .scl                = CAPSENSE_SCL_PIN,
           .sda                = CAPSENSE_SDA_PIN,
           .frequency          = NRF_TWI_FREQ_100K,
           .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
           .clear_bus_init     = false
        };
    
        err_code = nrf_drv_twi_init(&m_twi, &twi_config, NULL, NULL);
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_twi_enable(&m_twi);
    }
        
    /**
     * @brief Function for main application entry.
     */
    int main(void)
    {
        ret_code_t err_code;
        uint8_t sample_data;
    
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
        twi_init();
        
        /** writing value to register **/
        err_code = nrf_drv_twi_tx(&m_twi, DEFAULT_SLAVE_ADDRESS, register_address, sizeof(register_address), false);
        if(err_code == NRF_SUCCESS)
          {
    	printf("register value is set");
          }
        //APP_ERROR_CHECK(err_code);
        NRF_LOG_FLUSH();
        nrf_delay_ms(5);
    
        /** reading register value **/
        uint8_t register_address[2] = {REG_ADDR, IN_DEEP_SLP_VALUE};
        err_code = nrf_drv_twi_tx(&m_twi, DEFAULT_SLAVE_ADDRESS, register_address, 1, false);
        if(err_code == NRF_SUCCESS)
          {
    	printf("register value is set");
          }
          NRF_LOG_FLUSH();
                    
          nrf_delay_ms(60);
          err_code = nrf_drv_twi_rx(&m_twi, DEFAULT_SLAVE_ADDRESS, &sample_data, sizeof(sample_data));
        
        if (err_code == NRF_SUCCESS)
          {
            //printf("Written register value = 0x%x", sample_data);
          }		
          NRF_LOG_FLUSH();
    
        while (true)
        {
            printf("Written register value = 0x%x\n\r", sample_data);
            nrf_delay_ms(1000);
        }
    }
    
    /** @} */

    Thanks

  • Edvin said:
    So try to compare your application before and after you added the capsense buttons. Is your I2C active? Does the current behave like you expect if you never enable I2C? Do you disable the I2C before you go to system off?

     

    Edvin said:
    techietech said:
    No, application doesn't reset and also enter system off.

     what does that mean? Does the device enter system off or not?

     You didn't answer any of my previous questions. And now it doesn't answer the TWI calls either? Have you checked the datadsheet for the buttons you are using? Or do you have any drivers? Note that you are not sending the IN_DEEP_SLEEP_VALUE in that call:

        err_code = nrf_drv_twi_tx(&m_twi, DEFAULT_SLAVE_ADDRESS, register_address, 1, false);

    Because the length is set to one. You are only sending the first byte.

  • Hi !!

    So try to compare your application before and after you added the capsense buttons. Is your I2C active? Does the current behave like you expect if you never enable I2C? Do you disable the I2C before you go to system off?

    I compared my application before and after capsense i.e. I found that my system goes to System OFF . But When I attached capsense button I am not getting SYSTEM OFF Condition. No, I am not using I2C but it is connected with pin GPIO 26 & 27. No current doesn't behave like as expected. I also tried to disable the I2c using the api I have found on community but there is no luck.

    Have you checked the datadsheet for the buttons you are using? Or do you have any drivers? Note that you are not sending the IN_DEEP_SLEEP_VALUE in that call

    Yes I have checked the datasheet and found the address 0x00 and was trying to write Ox10 but not able to do that.

    err_code = nrf_drv_twi_tx(&m_twi, DEFAULT_SLAVE_ADDRESS, register_address, 1, false);

    I tried with 2 bytes also. 

    Could you please help me out with writing and reading using I2C. My slave address is 0x37. I want to read register at 0x00 and then want to write 0x10 and then after I want to read written value?

    Eventually, after getting deep sleep mode in I could implement it to capsense button (CY8CMBR2110-24LQ). 

    I will appreciate your soon response.

    Thanks 

Reply
  • Hi !!

    So try to compare your application before and after you added the capsense buttons. Is your I2C active? Does the current behave like you expect if you never enable I2C? Do you disable the I2C before you go to system off?

    I compared my application before and after capsense i.e. I found that my system goes to System OFF . But When I attached capsense button I am not getting SYSTEM OFF Condition. No, I am not using I2C but it is connected with pin GPIO 26 & 27. No current doesn't behave like as expected. I also tried to disable the I2c using the api I have found on community but there is no luck.

    Have you checked the datadsheet for the buttons you are using? Or do you have any drivers? Note that you are not sending the IN_DEEP_SLEEP_VALUE in that call

    Yes I have checked the datasheet and found the address 0x00 and was trying to write Ox10 but not able to do that.

    err_code = nrf_drv_twi_tx(&m_twi, DEFAULT_SLAVE_ADDRESS, register_address, 1, false);

    I tried with 2 bytes also. 

    Could you please help me out with writing and reading using I2C. My slave address is 0x37. I want to read register at 0x00 and then want to write 0x10 and then after I want to read written value?

    Eventually, after getting deep sleep mode in I could implement it to capsense button (CY8CMBR2110-24LQ). 

    I will appreciate your soon response.

    Thanks 

Children
Related