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

TWI and BLE on nRF52840 DK

Hello, 

I am interfacing nRF52840 DK with the MAX30101 sensor. I am able to execute all the TWI transactions necessary by using port 0 pin 27 as SCL and port 0 pin 26 as SDA. 

However when i use port 0 pin 14 as SCL and port 0 pin 13 as SDA I am not getting any output. I used ble_app_uart example and added TWI drivers. Are pins 14 and 13 assigned to something else in the ble_app_uart example? 

Changing pins is not an option, please tell me how I can go about working TWI on these pins. 

Thank you. 

Parents
  • Hi Gautham,

    I am working on similar boards, I have configured the sensor correctly but when I read FIFO I get zero. Can you help me out with configurations?

  • Hi Muhammad, 
    Sure, i can help you. can you tell me your configuration values?

  • /**@brief Function for initializations of max30101 .
     *
     * @param[in] p_instance  TWI instance.
    */
    void setup(nrf_drv_twi_t const * p_instance)
    {
    	 
    		//Setting the Mode configuration register
    		regwrite8(p_instance,MAX30101_MODECONFIG, MAX30101_MODE_MULTILED); // Setting the mode to Multi LED i-e 0x07
    
    	   // Multi Led mode control configuration register setup for slotx
        regwrite8(p_instance,MAX30101_MULTILEDCONFIG1,MULTI_LED_1); // Register 0x11 setup to value 0x21
    	
    		regwrite8(p_instance,MAX30101_MULTILEDCONFIG2,MULTI_LED_3); // Register 0x12 setup to value 0x03
    	
    		//LED Pulse applitude register to set the current in the led	
    		regwrite8(p_instance,MAX30101_LED1_PULSEAMP,powerLevel); // Current register setup to value 0x1F
    		regwrite8(p_instance,MAX30101_LED2_PULSEAMP,powerLevel);
    		regwrite8(p_instance,MAX30101_LED3_PULSEAMP,powerLevel);
    
    
      
     // Configuration register setting
    	/*
    	*	Fifo roll over enabled
    	*	Fifo sample average to 4
    	*	Generate Interrupt when 29 samples are filled in memeory
    	*/
    		regwrite8(p_instance,MAX30101_FIFOCONFIG,MAX30101_CONF_FIFO);// Fifo configuration register setup
    	
    		// Spo2 Configuration setup 
    		/*
    		*	ADC range set to 4096
    		* Sample Rate 400
    		*	LED pulse width 411
    		*/
    		regwrite8(p_instance,MAX30101_PARTICLECONFIG,0x2F);
    		// Clear fifo
    		clearFIFO(p_instance);
    	
    }
    
    /**@brief Function for writing the data to max30101 .
     *
     * @param[in] p_instance  TWI instance.
     * @param[in] RegAddr     Register Address to be written.
     * @param[in] data        Data to be written to the register.
     */
    void regwrite8(nrf_drv_twi_t const * p_instance, uint8_t RegAddr, uint8_t data)
    {
    	uint8_t reg[2] = {RegAddr, data};
    	nrf_drv_twi_tx(p_instance, MAX30101_ADDRESS, reg, sizeof(reg), false); //Repeated start is disabled
    	nrf_delay_ms(5);
    }
    

    Code to Initialize the sensor

Reply
  • /**@brief Function for initializations of max30101 .
     *
     * @param[in] p_instance  TWI instance.
    */
    void setup(nrf_drv_twi_t const * p_instance)
    {
    	 
    		//Setting the Mode configuration register
    		regwrite8(p_instance,MAX30101_MODECONFIG, MAX30101_MODE_MULTILED); // Setting the mode to Multi LED i-e 0x07
    
    	   // Multi Led mode control configuration register setup for slotx
        regwrite8(p_instance,MAX30101_MULTILEDCONFIG1,MULTI_LED_1); // Register 0x11 setup to value 0x21
    	
    		regwrite8(p_instance,MAX30101_MULTILEDCONFIG2,MULTI_LED_3); // Register 0x12 setup to value 0x03
    	
    		//LED Pulse applitude register to set the current in the led	
    		regwrite8(p_instance,MAX30101_LED1_PULSEAMP,powerLevel); // Current register setup to value 0x1F
    		regwrite8(p_instance,MAX30101_LED2_PULSEAMP,powerLevel);
    		regwrite8(p_instance,MAX30101_LED3_PULSEAMP,powerLevel);
    
    
      
     // Configuration register setting
    	/*
    	*	Fifo roll over enabled
    	*	Fifo sample average to 4
    	*	Generate Interrupt when 29 samples are filled in memeory
    	*/
    		regwrite8(p_instance,MAX30101_FIFOCONFIG,MAX30101_CONF_FIFO);// Fifo configuration register setup
    	
    		// Spo2 Configuration setup 
    		/*
    		*	ADC range set to 4096
    		* Sample Rate 400
    		*	LED pulse width 411
    		*/
    		regwrite8(p_instance,MAX30101_PARTICLECONFIG,0x2F);
    		// Clear fifo
    		clearFIFO(p_instance);
    	
    }
    
    /**@brief Function for writing the data to max30101 .
     *
     * @param[in] p_instance  TWI instance.
     * @param[in] RegAddr     Register Address to be written.
     * @param[in] data        Data to be written to the register.
     */
    void regwrite8(nrf_drv_twi_t const * p_instance, uint8_t RegAddr, uint8_t data)
    {
    	uint8_t reg[2] = {RegAddr, data};
    	nrf_drv_twi_tx(p_instance, MAX30101_ADDRESS, reg, sizeof(reg), false); //Repeated start is disabled
    	nrf_delay_ms(5);
    }
    

    Code to Initialize the sensor

Children
No Data
Related