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

TWI with SDK v14.2.0 and IQS231A

Dear Nordic Team,

We are using nRF52832 with a IQS231A for proximity detection for a new product, the pins are connected to SDA and SCL and everything is routed as in datasheet. however, I got to know today this sensor can only enter I2C mode in "test mode" which last for 340ms at initialization, and during this time we can access the I2C, this is done for power consumption purposes.

however, this requires polling the device at the start within 340ms and recieving the ACK this also includes burning the setting to the IC within this time window, my question. is the nRF52832 able to communicate at this speed ?, i tried the TWI scanner example but no device was found, changed to frequency to higher speed  400KB but still no device was found on I2C bus. Are you aware of any possible solution ? is it possible if there is any code sample that we can test as a biginning. an idea would be to supply the VDD directly from the the nordic chip, but what is maximum current that can the pins can supply without disrupting.

datasheet for the sensor can be found here:

https://www.mouser.com/ds/2/42/iqs231a_datasheet-1062577.pdf

The way to access the test mode/I2C mode can be found here:

https://www.mouser.com/pdfdocs/AZd0981QS231OTPconfiguration-2.pdf

I look forward for your reply,

Moe

Parents
  • Hi Kenneth,

     

    Thanks for your answer, so in the last days i tried to work around a code to make the device entering in test mode so i can initialize the sensor, i tried to build upon the example provided "TWI sensor example, here is my code:

     

    #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"
    
    /*************************************************************************/
    #include "nrf_drv_gpiote.h"
    #include "nrf_delay.h"
    
    /* TWI instance ID. */
    #define TWI_INSTANCE_ID     0
    
    /******************************IQS231A at test mode**********************************************/
    #define IQS231A_I2C_ADDR_TEST_MODE        (0x45U >> 1) //entering test mode aka I2C mode
    																										
    /********************************OTP test mode RAM addresses*******************************************************/
    #define OTP_BANK_0					0x10U  //check setting...it doesnt exist ?
    #define OTP__BANK_1 				0x11U 
    #define OTP_BANK_2					0x12U
    #define OTP_BANK_3					0x13U
    /*********************************Memory map I2C reg*********************************************/
    
    #define PRODUCT_NUMBER 			0x00U
    #define SOFTWARE_VERSION		0x01U
    #define	DEBUG_EVENTS			0x02U
    #define COMMANDS				0x04U
    
    #define QUICK_RELEASE			0x08U
    #define MOVEMENT				0x09U
    #define PROX_THRESHOLDS			0x0BU
    #define	CH_0_MULTIPLIERS		0x0DU
    #define	CH_1_MULTIPLIERS		0x0FU
    #define SYSTEM_FLAGS			0x11U
    #define UI_FLAGS				0x12U
    #define EVENT_FLAGS				0x14U
    #define CH0_ACF_H				0x15U
    #define CH0_ACF_L				0x16U
    #define CH0_LTA_H				0x17U
    #define CH0_LTA_L				0x18U
    #define CH0_QRD_H				0x19U
    #define	CH0_QRD_L				0x1AU
    #define	CH1_ACF_H				0x1BU
    #define	CH1_ACF_L				0x1CU
    #define	CH1_UMOV_H				0x1DU
    #define	CH1_UMOV_L				0x1EU
    #define	CH1_LMOV_H				0x1FU
    #define	CH1_LMOV_L				0x20U
    #define REGISTER_ADDRESS_CONFIRM_TEST_MODE 0x0FU
    
    #define VDDHI_PIN			    22
    
    /***************TIMINGS*********************/
    #define T_init					2
    
    
    
    /* 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);
    
    /* Buffer for samples read from temperature sensor. */
    static uint8_t m_sample;
    
    /**
     * @brief Function for switching on VDDHI
     */
    
    void init_vddhi_on(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    
    	ret_code_t err_code;
    	    if(!nrf_drv_gpiote_is_init()) {
            nrf_drv_gpiote_init();
    			}
    			
    			/****configure P0.22 VDDHI as output********/
    			nrf_drv_gpiote_out_config_t vddhi_config = GPIOTE_CONFIG_OUT_SIMPLE(0);
    			err_code = nrf_drv_gpiote_out_init(VDDHI_PIN, vddhi_config);
    			//nrf_gpio_pin_set(VDDHI_PIN);
    			APP_ERROR_CHECK(err_code);
    }
    
    /**
     * @brief Function for writing the setting for IQS231A capacitive sensor
     */
    
    void IQS231A_switch_to_test_mode(void)
    {
    
    	ret_code_t err_code;
    	uint32_t level;
    	uint32_t reg[0] = REGISTER_ADDRESS_CONFIRM_TEST_MODE; //0x0F
    	
    	nrf_gpio_pin_set(VDDHI_PIN);
    	level = nrf_gpio_pin_read(VDDHI_PIN);
    	
    	/*check if device pulled high then initialize the sensor*/
    	if(level == true){
    		
    		
    		nrf_delay_ms(T_init); // wait for the cap sensor initialization time
    		/**/
        err_code = nrf_drv_twi_tx(&m_twi, IQS231A_I2C_ADDR_TEST_MODE, reg, sizeof(reg), false);
    		APP_ERROR_CHECK(err_code);
    		
    	}
    	
    	
    
    
    

    however, according to the datasheet here, Page2, section 3 ("Entering Test mode"), i need to read the data and check if data = A5, how can I do this ?

    also the ACK should be recieved, how can i check if ACK is recieved ?

     

    Thanks a lot in advance,

    Mohamed

    Edit: right now VDDHI is connected to  a GPIO

    I am using Nordic devkit and VDDHI is connected to pin P0.22

     

Reply
  • Hi Kenneth,

     

    Thanks for your answer, so in the last days i tried to work around a code to make the device entering in test mode so i can initialize the sensor, i tried to build upon the example provided "TWI sensor example, here is my code:

     

    #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"
    
    /*************************************************************************/
    #include "nrf_drv_gpiote.h"
    #include "nrf_delay.h"
    
    /* TWI instance ID. */
    #define TWI_INSTANCE_ID     0
    
    /******************************IQS231A at test mode**********************************************/
    #define IQS231A_I2C_ADDR_TEST_MODE        (0x45U >> 1) //entering test mode aka I2C mode
    																										
    /********************************OTP test mode RAM addresses*******************************************************/
    #define OTP_BANK_0					0x10U  //check setting...it doesnt exist ?
    #define OTP__BANK_1 				0x11U 
    #define OTP_BANK_2					0x12U
    #define OTP_BANK_3					0x13U
    /*********************************Memory map I2C reg*********************************************/
    
    #define PRODUCT_NUMBER 			0x00U
    #define SOFTWARE_VERSION		0x01U
    #define	DEBUG_EVENTS			0x02U
    #define COMMANDS				0x04U
    
    #define QUICK_RELEASE			0x08U
    #define MOVEMENT				0x09U
    #define PROX_THRESHOLDS			0x0BU
    #define	CH_0_MULTIPLIERS		0x0DU
    #define	CH_1_MULTIPLIERS		0x0FU
    #define SYSTEM_FLAGS			0x11U
    #define UI_FLAGS				0x12U
    #define EVENT_FLAGS				0x14U
    #define CH0_ACF_H				0x15U
    #define CH0_ACF_L				0x16U
    #define CH0_LTA_H				0x17U
    #define CH0_LTA_L				0x18U
    #define CH0_QRD_H				0x19U
    #define	CH0_QRD_L				0x1AU
    #define	CH1_ACF_H				0x1BU
    #define	CH1_ACF_L				0x1CU
    #define	CH1_UMOV_H				0x1DU
    #define	CH1_UMOV_L				0x1EU
    #define	CH1_LMOV_H				0x1FU
    #define	CH1_LMOV_L				0x20U
    #define REGISTER_ADDRESS_CONFIRM_TEST_MODE 0x0FU
    
    #define VDDHI_PIN			    22
    
    /***************TIMINGS*********************/
    #define T_init					2
    
    
    
    /* 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);
    
    /* Buffer for samples read from temperature sensor. */
    static uint8_t m_sample;
    
    /**
     * @brief Function for switching on VDDHI
     */
    
    void init_vddhi_on(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    
    	ret_code_t err_code;
    	    if(!nrf_drv_gpiote_is_init()) {
            nrf_drv_gpiote_init();
    			}
    			
    			/****configure P0.22 VDDHI as output********/
    			nrf_drv_gpiote_out_config_t vddhi_config = GPIOTE_CONFIG_OUT_SIMPLE(0);
    			err_code = nrf_drv_gpiote_out_init(VDDHI_PIN, vddhi_config);
    			//nrf_gpio_pin_set(VDDHI_PIN);
    			APP_ERROR_CHECK(err_code);
    }
    
    /**
     * @brief Function for writing the setting for IQS231A capacitive sensor
     */
    
    void IQS231A_switch_to_test_mode(void)
    {
    
    	ret_code_t err_code;
    	uint32_t level;
    	uint32_t reg[0] = REGISTER_ADDRESS_CONFIRM_TEST_MODE; //0x0F
    	
    	nrf_gpio_pin_set(VDDHI_PIN);
    	level = nrf_gpio_pin_read(VDDHI_PIN);
    	
    	/*check if device pulled high then initialize the sensor*/
    	if(level == true){
    		
    		
    		nrf_delay_ms(T_init); // wait for the cap sensor initialization time
    		/**/
        err_code = nrf_drv_twi_tx(&m_twi, IQS231A_I2C_ADDR_TEST_MODE, reg, sizeof(reg), false);
    		APP_ERROR_CHECK(err_code);
    		
    	}
    	
    	
    
    
    

    however, according to the datasheet here, Page2, section 3 ("Entering Test mode"), i need to read the data and check if data = A5, how can I do this ?

    also the ACK should be recieved, how can i check if ACK is recieved ?

     

    Thanks a lot in advance,

    Mohamed

    Edit: right now VDDHI is connected to  a GPIO

    I am using Nordic devkit and VDDHI is connected to pin P0.22

     

Children
No Data
Related