<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84133/nrf52840-one-wire-protocol-usage-with-max17211-ic</link><description>Hello Everyone, 
 I am trying to implement one wire protocol for interfacing MAX17211 fuel guage IC with NRF52840. I wand to know if there is any one wire library or any example which we can use to read the registers of MAX17211. Can we read the registers</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Mar 2022 12:48:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84133/nrf52840-one-wire-protocol-usage-with-max17211-ic" /><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/358210?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2022 12:48:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe87c952-b58a-4efa-8fae-dca1a5d5b7ae</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="vibe"]are you getting a NRF_DRV_TWI_EVT_ADDRESS_NACK or NRF_DRV_TWI_EVT_DATA_NACK event?[/quote]
&lt;p&gt;You are only handling the NRF_DRV_TWI_EVT_DONE event in your twi_handler(), and ignoring NRF_DRV_TWI_EVT_ADDRESS_NACK and NRF_DRV_TWI_EVT_DATA_NACK. Please add these events to your handler and see if either of these are triggered.&lt;/p&gt;
&lt;p&gt;Your screenshot does not show the source file from where you are getting the &amp;quot;unsigned conversion from &amp;#39;int&amp;#39; to &amp;#39;uint8_t&amp;#39; {aka &amp;#39;unsigned char&amp;#39;} changes value from &amp;#39;437&amp;#39; to &amp;#39;181&amp;#39; [-Woverflow]&amp;quot; warning from.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/358158?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2022 10:02:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddb4ec73-a2be-4388-ba92-a643879d4ffb</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;I am getting warning as shown below:-&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#define NPACKCFG_REG&amp;nbsp; &amp;nbsp; &amp;nbsp;0x1B5&lt;/p&gt;
&lt;p&gt;when i try to read&amp;nbsp;&lt;span&gt;NPACKCFG_REG some conversion is happening.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1647339108823v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;There are actually 2 slaves on the same i2c instance.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I2c1_slave address = 0x6B&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I2c2_slave address = 0x6C&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am able to &lt;span style="font-size:12px;"&gt;communicate&lt;/span&gt;&amp;nbsp;with slave 1 but when i try to communicate with slave 2 it gets hanged while sending data through&amp;nbsp;nrf_drv_twi_tx in i2c_register_read_max17211 function. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*****************************************************************************
* Copyright (c) [2021], Netobjex INC
* All rights reserved.
*
* File:    task_psf_comm.c
* Summary: PSF Control Task
*
*/

#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#include &amp;quot;error_defs.h&amp;quot;

#include &amp;quot;task_psf_comm.h&amp;quot;
#include &amp;quot;FreeRTOS.h&amp;quot;
#include &amp;quot;task.h&amp;quot;
#include &amp;quot;semphr.h&amp;quot;
#include &amp;quot;timers.h&amp;quot;

#include &amp;quot;tasks.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_drv_gpiote.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

#include &amp;quot;main.h&amp;quot;
#include &amp;quot;task_led_button.h&amp;quot;

#include &amp;quot;product_config.h&amp;quot;
#include &amp;quot;nrf_drv_twi.h&amp;quot;
#include &amp;quot;psf_i2c.h&amp;quot;
#include &amp;quot;bq24292i.h&amp;quot;
#include &amp;quot;max17211_i2c.h&amp;quot;


/* I2C SLAVE 1*/
#define BQ2429_ADDRESS_LEN  1         //BQ2429
#define BQ2429_ADDRESS     (0xD6&amp;gt;&amp;gt;1)  //BQ2429 Device Address
#define BQ2429_WHO_AM_I     0x6BU     //BQ2429 ID

/* I2C SLAVE 2*/
#define MAX17201_ADDRESS_LEN  1         
#define MAX17201_ADDR     (0xD8&amp;gt;&amp;gt;1) //(0xD8&amp;gt;&amp;gt;1)  
#define MAX17201_WHO_AM_I   0x6CU   

#define TWI_INSTANCE_ID     0 //snehal




/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);
static volatile bool m_xfer_done = false;

//Event Handler
void twi_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
    //Check the event to see what type of event occurred
    switch (p_event-&amp;gt;type)
    {
        //If data transmission or receiving is finished
	case NRF_DRV_TWI_EVT_DONE:
        m_xfer_done = true;//Set the flag
        break;
        
        default:
        // do nothing
          break;
    }
}

void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = PSF_SCL_PIN,
       .sda                = PSF_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_400K, 
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_twi, &amp;amp;twi_config, twi_handler, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_twi);
}



bool bq2429i_i2c_init(void)
{
    ret_code_t err_code;
    uint8_t address = 0x6B;  
    uint8_t sample_data = 0x00;

    err_code = nrf_drv_twi_rx(&amp;amp;m_twi,address,&amp;amp;sample_data,sizeof(sample_data));
    if(err_code == NRF_SUCCESS)
    {
       NRF_LOG_INFO(&amp;quot;SUCCESS&amp;quot;);
       return true;
    }
    else
    {
       NRF_LOG_INFO(&amp;quot;FAILED&amp;quot;);
       return false;
    }

}


bool max17211_i2c_init(void)
{
    ret_code_t err_code;
    uint8_t address = 0x6C;  
    uint8_t sample_data = 0x00;

    err_code = nrf_drv_twi_rx(&amp;amp;m_twi,address,&amp;amp;sample_data,sizeof(sample_data));
    if(err_code == NRF_SUCCESS)
    {
       NRF_LOG_INFO(&amp;quot;SUCCESS&amp;quot;);
       return true;
    }
    else
    {
       NRF_LOG_INFO(&amp;quot;FAILED&amp;quot;);
       return false;
    }

}


/*
  A Function to read data from the MPU6050
*/ 
bool i2c_register_read(uint8_t register_address, uint8_t * destination, uint8_t number_of_bytes)
{
    ret_code_t err_code;

    //Set the flag to false to show the receiving is not yet completed
    m_xfer_done = false;
    
    // Send the Register address where we want to write the data
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, BQ2429_ADDRESS, &amp;amp;register_address, 1, true);
	  
    //Wait for the transmission to get completed
    while (m_xfer_done == false){}
    //vTaskDelay(1000);

    // If transmission was not successful, exit the function with false as return value
    if (NRF_SUCCESS != err_code)
    {
        return false;
    }

    //set the flag again so that we can read data from the MPU6050&amp;#39;s internal register
    m_xfer_done = false;
	  
    // Receive the data from the MPU6050
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, BQ2429_ADDRESS, destination, number_of_bytes);
		
    //wait until the transmission is completed
    while (m_xfer_done == false){}
    //vTaskDelay(1000);

	
    // if data was successfully read, return true else return false
    if (NRF_SUCCESS != err_code)
    {
        return false;
    }
    
    //NRF_LOG_INFO(&amp;quot;DATA IS %x&amp;quot;,destination);
    return true;
}

/*
   A function to write a Single Byte to MPU6050&amp;#39;s internal Register
*/ 
bool i2c_register_write(uint8_t register_address, uint8_t value)
{
    ret_code_t err_code;
    uint8_t tx_buf[BQ2429_ADDRESS_LEN+1];
	
    //Write the register address and data into transmit buffer
    tx_buf[0] = register_address;
    tx_buf[1] = value;

    //Set the flag to false to show the transmission is not yet completed
    m_xfer_done = false;
    
    //Transmit the data over TWI Bus
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, BQ2429_ADDRESS, tx_buf, BQ2429_ADDRESS_LEN+1, false);
    
    //Wait until the transmission of the data is finished
    while (m_xfer_done == false)
    {
      }

    // if there is no error then return true else return false
    if (NRF_SUCCESS != err_code)
    {
        NRF_LOG_INFO(&amp;quot;FAILED&amp;quot;);
        return false;
    }

   // NRF_LOG_INFO(&amp;quot;SUCCESS&amp;quot;);

    return true;	
}


bool i2c_register_write_max17211(uint16_t register_address, uint16_t value)
{

      ret_code_t err_code;
      uint8_t tx_data[4];

      tx_data[0] = ( (register_address &amp;gt;&amp;gt; 8)&amp;amp; 0xFF );
      tx_data[1] = register_address &amp;amp; 0xFF;
      tx_data[2] = ((value&amp;gt;&amp;gt;8)&amp;amp; 0xff);
      tx_data[3] = value &amp;amp; 0xFF;

      m_xfer_done = false;
    
      err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MAX17201_WHO_AM_I, tx_data, sizeof(tx_data), false);
  //Wait until the transmission of the data is finished
    while (m_xfer_done == false)
    {  }
    //vTaskDelay(1000);

   // if there is no error then return true else return false
    if (NRF_SUCCESS != err_code)
    {
        NRF_LOG_INFO(&amp;quot;FAILED&amp;quot;);
        return false;
    }

    NRF_LOG_INFO(&amp;quot;SUCCESS&amp;quot;);

    return true;	

}

bool i2c_register_read_max17211(uint8_t register_address, uint8_t destination[2], uint8_t number_of_bytes)
{
   // uint8_t address = 0x6C;  

    ret_code_t err_code;

    //Set the flag to false to show the receiving is not yet completed
    m_xfer_done = false;
    
    // Send the Register address where we want to write the data
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MAX17201_WHO_AM_I, &amp;amp;register_address, 1, true);
	  
    //Wait for the transmission to get completed
    while (m_xfer_done == false){}

    // If transmission was not successful, exit the function with false as return value
    if (NRF_SUCCESS != err_code)
    {
        return false;
    }

    //set the flag again so that we can read data from the MPU6050&amp;#39;s internal register
    m_xfer_done = false;
	  
    // Receive the data from the MPU6050
    //err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MAX17211_WHO_AM_I, destination, number_of_bytes);
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MAX17201_WHO_AM_I, &amp;amp;destination[0], sizeof(destination));
		
    //wait until the transmission is completed
    while (m_xfer_done == false){}


    // if data was successfully read, return true else return false
    if (NRF_SUCCESS != err_code)
    {
        return false;
    }
    
    //NRF_LOG_INFO(&amp;quot;DATA IS %x&amp;quot;,destination);
    return true;

}

&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;With slave 1 i have no issues reading and writing the data.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What might be the issue that I am not getting&amp;nbsp;m_xfer_done= true after sending data to the 2nd slave??&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/358135?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2022 08:56:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:156d94c7-97da-46e8-abe4-bf479a481ae8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="snehal_2789"]I have modified the code a bit in order to read 2bytes from register. I am not able to read 16bit registers. I tried to read NPACKCFG_REG but not able to read it properly.[/quote]
&lt;p&gt;What do you mean by not being able to read it properly? Are you getting the NRF_DRV_TWI_EVT_DONE event after you have called nrf_drv_twi_rx(), or are you getting a NRF_DRV_TWI_EVT_ADDRESS_NACK or NRF_DRV_TWI_EVT_DATA_NACK event?&lt;/p&gt;
[quote user="snehal_2789"]unsigned conversion from &amp;#39;int&amp;#39; to &amp;#39;uint8_t&amp;#39; {aka &amp;#39;unsigned char&amp;#39;} changes value from &amp;#39;437&amp;#39; to &amp;#39;181&amp;#39; [-Woverflow][/quote]
&lt;p&gt;Please show me where you are getting this warning.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/357942?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 12:40:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2eef186d-2d92-4fcd-b0fe-a4ce0d35cc99</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;We have solved the issue with MAX17211, we tried to check the pulses but it seemed that there was some problem with the hardware. So the hardware guy has now replaced the ic from MAX17211 to MAX17201. This IC is pure I2C based and I am able to connect and read some data from the IC. When I read 8bit registers I dont have any issue. But when I am trying to read 16bit register from the IC, I am getting errors:-&lt;/p&gt;
&lt;p&gt;I have modified the code a bit in order to read 2bytes from register. I am not able to read 16bit registers. I tried to read NPACKCFG_REG but not able to read it properly.As well as while compiling I am getting warnings like this:-&lt;/p&gt;
&lt;p&gt;unsigned conversion from &amp;#39;int&amp;#39; to &amp;#39;uint8_t&amp;#39; {aka &amp;#39;unsigned char&amp;#39;} changes value from &amp;#39;437&amp;#39; to &amp;#39;181&amp;#39; [-Woverflow]&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#define NPACKCFG_REG     0x1B5



bool i2c_register_write_max17211(uint16_t register_address, uint16_t value)
{

      ret_code_t err_code;
      uint8_t tx_data[4];

      tx_data[0] = ( (register_address &amp;gt;&amp;gt; 8)&amp;amp; 0xFF );
      tx_data[1] = register_address &amp;amp; 0xFF;
      tx_data[2] = ((value&amp;gt;&amp;gt;8)&amp;amp; 0xff);
      tx_data[3] = value &amp;amp; 0xFF;

      m_xfer_done = false;
    
      err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MAX17211_WHO_AM_I, tx_data, sizeof(tx_data), false);
  //Wait until the transmission of the data is finished
    while (m_xfer_done == false)
    {
      }

   // if there is no error then return true else return false
    if (NRF_SUCCESS != err_code)
    {
        NRF_LOG_INFO(&amp;quot;FAILED&amp;quot;);
        return false;
    }

    NRF_LOG_INFO(&amp;quot;SUCCESS&amp;quot;);

    return true;	

}

bool i2c_register_read_max17211(uint8_t register_address, uint8_t destination[2], uint8_t number_of_bytes)
{
    ret_code_t err_code;
    //uint8_t rx_buffer[2];

    //Set the flag to false to show the receiving is not yet completed
    m_xfer_done = false;
    
    // Send the Register address where we want to write the data
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi, MAX17211_WHO_AM_I, &amp;amp;register_address, 1, true);
	  
    //Wait for the transmission to get completed
    while (m_xfer_done == false){}
    //vTaskDelay(1000);

    // If transmission was not successful, exit the function with false as return value
    if (NRF_SUCCESS != err_code)
    {
        return false;
    }

    //set the flag again so that we can read data from the MPU6050&amp;#39;s internal register
    m_xfer_done = false;
	  
    // Receive the data from the MPU6050
    //err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MAX17211_WHO_AM_I, destination, number_of_bytes);
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MAX17211_WHO_AM_I, &amp;amp;destination[0], sizeof(destination));
		
    //wait until the transmission is completed
    while (m_xfer_done == false){}
    //vTaskDelay(1000);


    // if data was successfully read, return true else return false
    if (NRF_SUCCESS != err_code)
    {
        return false;
    }
    
    //NRF_LOG_INFO(&amp;quot;DATA IS %x&amp;quot;,destination);
    return true;

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you please help? Also Is my code proper for writing 16bit register?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/357030?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 07:55:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cda524c-2ef5-47c4-9484-72398039be4e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Snehal,&lt;/p&gt;
&lt;p&gt;I guess it may be ok to share it with the i2c clock line, but this is something you need to confirm yourself. Check the datasheets and see if you can use the same pullups, etc&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/357022?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 06:32:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79f71db9-e649-4bd1-ae57-895c246b26e8</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;One more thing I wanted to ask is that on the same one wire line we have attached one more I2C based IC bq2429. so basically BQ2429 is I2c based and on the same line we have MAX17211 which is one wire based. So will it cause problems in getting data from the MAX17211??&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The pins used for BQ2429&amp;nbsp; are as follows:-&lt;/p&gt;
&lt;p&gt;#define PSF_SCL_PIN NRF_GPIO_PIN_MAP(1,9) &lt;br /&gt;#define PSF_SDA_PIN NRF_GPIO_PIN_MAP(0,11)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The pins used for&amp;nbsp;MAX17211&amp;nbsp;is&amp;nbsp;as follows:-&lt;/p&gt;
&lt;p&gt;#define PSF_SDA_PIN NRF_GPIO_PIN_MAP(0,11)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Snehal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/357018?ContentTypeID=1</link><pubDate>Wed, 09 Mar 2022 05:05:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36928fc6-d605-4686-a567-56611bec4a0f</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yes you are right. we can use nrf_delay_us inside an rtos task. Thank you. I thought when rtos is used only vTaskDelay should be used for creating delays.I am going to test more with the IC max17211 today. will update you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Snehal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356912?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 13:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e36e18e-8212-49a4-b80c-74c331aaa157</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Snehal,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t see any problems with using &lt;span&gt;nrf_delay_us&lt;/span&gt;() as long as you aren&amp;#39;t using long delays.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356880?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 12:40:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4201fdc2-b9b1-41e5-8589-d672223a7011</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Thanks for your reply. But we cant use&amp;nbsp;&lt;span&gt;nrf_delay_us() function inside an rtos task right??&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Snehal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356875?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 12:26:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9a70d03-caee-4e78-8905-084099c9b0f2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Snehal,&lt;/p&gt;
&lt;p&gt;You can&amp;#39;t use vTaskDelay() for delays that are shorter than the RTOS tick interval. I think it&amp;#39;s best to continue with busy waits using the nrf_delay_us() function as long as it provides you with sufficient accuracy. Otherwise you will have use a HW timer. &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356760?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2022 07:49:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b802dc73-879d-4627-915c-8141d974993a</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I also had one doubt. currently in my project I will be using FREERTOS. The above code which I shared uses &amp;quot;nrf_delay_us&amp;quot; to put delays after setting and clearing the pin. In FREERTOS , if I want to communicate with max17211, how can we generate delay of microseconds using vTaskDelay?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Snehal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356607?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 13:14:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61121b30-630b-4fe9-9e51-331c3446bb5f</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;ok I will try to check and get back.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356599?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 13:03:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1008c221-b83a-4fa9-a188-f5084b8eeafe</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;It likely means that it&amp;#39;s not responding to your command. With a scope trace you could verify the timing and check if the sensor replies at all.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356547?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 11:26:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab860ad0-c894-4696-8fb5-be0ab555a1c2</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;okay I removed the reset command but still&amp;nbsp;when i read val1, i get 0xff. I don&amp;#39;t think that&amp;#39;s proper data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356545?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 11:19:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f02cc69-69bd-452f-a937-5796b18be3e5</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The sequence looks OK, but why the reset at the end? It seems like there should only be one reset at the start according to the datasheet:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1646651964158v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356542?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 11:04:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64ae4fe1-7a79-4655-bad8-91770cd45846</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;But is my code proper?? I will do the debugging but is the reading pattern in the code ok?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Snehal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356541?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 11:03:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa0d5d48-7ee4-4f92-aece-8e09392f4ce8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I think you need a logic analyzer or oscilloscope if you don&amp;#39;t have one already and confirm if the transaction meet the timing requirements outlined in the datasheet. It will be difficult to do much troubleshooting without it. &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/356539?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2022 10:57:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abfe5160-62ba-40eb-8783-35e672be427d</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;I am not sure. I am really going in circles on how to read data from MAX17211. Can you please help me. I want to read data 0x06h REPSOC. I am using the below function but I am not able to get proper values&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;float max1720x_getSOC1()&lt;br /&gt;{&lt;br /&gt; unsigned char check;&lt;/p&gt;
&lt;p&gt;check=max17211_reset();&lt;br /&gt; if(check)&lt;br /&gt; {&lt;/p&gt;
&lt;p&gt;max17211_send_byte(0xCC); //skip rom command&lt;br /&gt; max17211_send_byte(0x69); //READ command&lt;br /&gt; max17211_send_byte(0x06); //SOC REGISTER&lt;br /&gt; max17211_send_byte(0x00); //SOC REGISTER&lt;br /&gt; max17211_reset();&lt;br /&gt; //val1=max17211_read_byte();&lt;br /&gt; val1=OneWire_read(); //read_byte();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;soc = (double)val1/256;&lt;br /&gt; return soc;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Your help will be appreciated.&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;br /&gt;Snehal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/351152?ContentTypeID=1</link><pubDate>Thu, 03 Feb 2022 14:25:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3741853a-efb3-4416-8543-ac2cdfa79c86</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;Snehal,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The read and write sequences seem to be well documented in the datasheet. For instance, Figure 82 on page 109 which show the communication sequences. There&amp;#39;s also guide for the SW implementation for this sensor here: &lt;a href="https://www.maximintegrated.com/en/design/technical-documents/userguides-and-manuals/6/6260.html"&gt;https://www.maximintegrated.com/en/design/technical-documents/userguides-and-manuals/6/6260.html&lt;/a&gt; &lt;/span&gt;&lt;/p&gt;
[quote user="snehal_2789"]Scratch Pad memory[/quote]
&lt;p&gt;I&amp;#39;m not familiar with the driver, but isn&amp;#39;t it just a buffer to hold the received data?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Vidar&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/350812?ContentTypeID=1</link><pubDate>Wed, 02 Feb 2022 10:02:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e76d4f2e-6ab5-4205-a2c8-55015a4065e8</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thank you so much for your reply. I am trying to implement the above shared code in my project for MAX17211. I will check the timings for sure. Now I had one question. The github code shows how to read temperature from READSCRATCH method(Reading the Scratch Pad Memory).&amp;nbsp;&lt;span&gt;The Scratch Pad memory provides the user with all the necessary device data including temperature, TH and TL programmable thermometer settings, as well as the Count Remain and Count Per C data used in fractional temperature measurements. The CRC byte is also included in Scratch Pad memory. This was for temperature sensor. If I want to read another register from MAX17211, how to read that register?? I can&amp;#39;t use the scratchpad method as I directly want to read the register. Will I have to use it this way??&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span class="pl-c1"&gt;ds18b20_send_byte&lt;/span&gt;(&lt;span class="pl-c1"&gt;0x00A&lt;/span&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;uint16_t&amp;nbsp;data =&lt;span class="pl-c1"&gt;ds18b20_read_byte&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this the right way to read register?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;Snehal&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/350225?ContentTypeID=1</link><pubDate>Fri, 28 Jan 2022 13:54:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a10308ff-4de0-403d-8700-2cab25299249</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Snehal,&lt;/p&gt;
&lt;p&gt;I see. At first glance it looked like all the variants had i2c support.&lt;/p&gt;
&lt;p&gt;Timing requirements, communication sequences, etc. are documented in the datasheet (starting on page 104 - section 1-Wire Bus System (MAX17211/MAX17215 Only)), and you may have to implement this yourself. I am not aware of any third party examples for this IC.&lt;/p&gt;
[quote user="snehal_2789"]Also can I use this library &amp;quot;&lt;a href="https://github.com/sigurdnev/Nordic-DS18B20"&gt;&amp;quot;&amp;gt;github.com/.../Nordic-DS18B20&amp;quot;&lt;/a&gt; to read data from MAX17211?? will have to modify reg values?? Is it possible?&amp;nbsp;[/quote]
&lt;p&gt;It may serve as a starting point. You will still need to make sure the timing is correct and implement the command sequences to control the chip.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/349985?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 13:16:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72a5e40a-900a-4355-889b-f21bad66110e</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Actually the IC which we are using(MAX17211)&amp;nbsp; in our hardware supports only 1 wire. I asked the Maxim support team if we can communicate via I2c, so they replied that MAX17211 can be communicated using only One wire protocol. How can it be implemented in NRF52840 ??&lt;/p&gt;
&lt;p&gt;I saw the link which you had shared so driving the bus high and low and giving the reset pulse is possible with appropriate delays. That can be done. But if I want to read any register from the MAX17211, how to do that? How to sample the bus to read the data from a particular register??&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also can I use this library &amp;quot;&lt;a href="https://github.com/sigurdnev/Nordic-DS18B20"&gt;&amp;quot;&amp;gt;github.com/.../Nordic-DS18B20&amp;quot;&lt;/a&gt; to read data from MAX17211?? will have to modify reg values?? Is it possible?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Snehal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf52840 one wire protocol usage with MAX17211 IC.</title><link>https://devzone.nordicsemi.com/thread/349976?ContentTypeID=1</link><pubDate>Thu, 27 Jan 2022 12:49:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4fb2a3b-02c2-4eb7-aaef-c4a95c9d6119</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Looks like this Maxim IC also supports TWI (i2c), so is there any reason for selecting 1-wire over TWI in this case? With the 1-wire interface you would have to bit bang the protocol as explained in their app note here: &lt;a href="https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/126.html"&gt;https://www.maximintegrated.com/en/design/technical-documents/app-notes/1/126.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>