<?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>MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54222/mcp7940-drivers-for-nrf52840</link><description>We are working on external RTC MCP7940(i2c) interfaced with nrf52840. Please check if drivers of the same for nrf52/51 are available or any implementation of CLOCK using MCP7940 with NRF? 
 
 Regards 
 Vishal Aditya 
 Embedded Software Engineer</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 05 Mar 2020 10:20:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54222/mcp7940-drivers-for-nrf52840" /><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/238229?ContentTypeID=1</link><pubDate>Thu, 05 Mar 2020 10:20:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3491de18-125b-4b6a-8249-0ae3662ca729</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Great, then you are good to go. You should be able to reuse the snippet I provided to configure the&amp;nbsp;MCP7940.&amp;nbsp; My suggestion would be to capture a trace of the Arduino Init sequence to see which values that are written to which register and then just copy paste the code snippet I provided and change the&amp;nbsp;REG_RTCSEC register value and the 0x80 to match what you&amp;#39;re seeing in the trace.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/238193?ContentTypeID=1</link><pubDate>Thu, 05 Mar 2020 09:00:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccff57f7-bd21-46b6-ad84-105985d36d9c</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Yes getting 0x80&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/debugger2.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/initSeq1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Below is the attached Arduino init sequence:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  Wire.begin();                               // Start I2C as master device
  Wire.setClock(i2cSpeed);                    // Set the I2C bus speed
  Wire.beginTransmission(MCP7940_ADDRESS);    // Address the MCP7940M
  uint8_t errorCode = Wire.endTransmission(); // See if there&amp;#39;s a device present
  if (errorCode == 0)                         // If we have a MCP7940M
  {
    clearRegisterBit(MCP7940_RTCHOUR, MCP7940_12_24);                      // Use 24 hour clock
    setRegisterBit(MCP7940_CONTROL, MCP7940_ALMPOL);                       // assert alarm low, default high
    _CrystalStatus = readRegisterBit(MCP7940_RTCSEC, MCP7940_ST);          // Status bit from register
    _OscillatorStatus = readRegisterBit(MCP7940_RTCWKDAY, MCP7940_OSCRUN); // Oscillator state from register
  }&lt;/pre&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/MCP7940.h"&gt;devzone.nordicsemi.com/.../MCP7940.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/MCP7940.cpp"&gt;devzone.nordicsemi.com/.../MCP7940.cpp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/238172?ContentTypeID=1</link><pubDate>Thu, 05 Mar 2020 07:44:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:066cd20d-1ffa-4494-b8b8-56b9a6dcbb96</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Ok, if the nrf_drv_twi_rx call does not return a non-zero error code, then things are working as they should. Could you try to run the following code and see if the rx_data[0] is 0x80. If it is then the code is working as intended.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Initizalize buffers 	
uint8_t tx_data[] = {REG_RTCSEC, 0x80 }; // Set TX buffer - Write 0x80 ( Enable Osc) to REG_RTCSEC register
uint8_t rx_data[] = {}; // Empty RX buffer

// Write Tx data to MCP7940
err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,tx_data , sizeof(tx_data),false);
APP_ERROR_CHECK(err_code);

// Select REG_RTCSEC register and use repeated start (only send 1 byte of tx buffer)
err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,tx_data , 1 ,true);
APP_ERROR_CHECK(err_code);

// Read REG_RTCSEC register 
err_code = nrf_drv_twi_rx(&amp;amp;m_twi,MCP7940_I2C,rx_data,1);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/238161?ContentTypeID=1</link><pubDate>Thu, 05 Mar 2020 06:06:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75a6d3e7-f31c-475e-b28a-710bfa18fd01</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;&lt;strong&gt;err_code = 0&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/debugger1.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/238016?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2020 12:21:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28c69bad-6976-4d9d-94b5-5c94303d479f</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, but you are reading back the value of the register, i.e. 0x07. Wasnt that what you wrote to the register previously? What is the return code of&amp;nbsp;&lt;span&gt;nrf_drv_twi_rx()? Is it&amp;nbsp;NRF_ERROR_DRV_TWI_ERR_DNACK or&amp;nbsp;NRF_ERROR_DRV_TWI_ERR_ANACK?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237995?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2020 10:50:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ddde094-1e08-41bc-a997-6a1d8df3efcf</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Please check still NAK&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/Oscillator1.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237950?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2020 08:56:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0706ed85-fece-48b7-a91b-441de4f84f1e</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;If you want to start the oscillator, then you need to set bit 7 in&amp;nbsp;REG_RTCSEC to 1, i.e. you need to write 0x80 not 0x07.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The read operation is Not Acknowledged so it could be that you have to select the register you want to read from before&amp;nbsp;&lt;/p&gt;
&lt;p&gt;// Read REG_RTCSEC register&lt;/p&gt;
&lt;p&gt;uint8_t tx_data[] = {REG_RTCSEC };&lt;br /&gt; uint8_t rx_data[] = {0};&lt;/p&gt;
&lt;p&gt;// Select&amp;nbsp;&lt;span&gt;REG_RTCSEC&amp;nbsp;register and use repeated start&lt;/span&gt;&lt;br /&gt; err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,tx_data , sizeof(tx_data),true);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;&lt;span&gt;// Read&amp;nbsp;&lt;/span&gt;&lt;span&gt;REG_RTCSEC&amp;nbsp;register&amp;nbsp;&lt;/span&gt;&lt;br /&gt; err_code = nrf_drv_twi_rx(&amp;amp;m_twi,MCP7940_I2C,rx_data,1);&lt;br /&gt;&lt;span&gt;APP_ERROR_CHECK(err_code);&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237929?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2020 07:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02af8f30-271f-4c19-815a-cbd7fa3ba283</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Pls check&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;const uint8_t  MCP7940_ST                =         7; ///&amp;lt; MCP7940 register bits. RTCSEC reg
//REST variables remains same as above
	while(1)
	{
	uint8_t tx_data[] = {REG_RTCSEC, MCP7940_ST };
	uint8_t rx_data[] = REG_RTCSEC;

	//trying to start oscillator
		err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,tx_data , sizeof(tx_data),false);
		APP_ERROR_CHECK(err_code);
	  err_code = nrf_drv_twi_rx(&amp;amp;m_twi,MCP7940_I2C,rx_data,1);
		nrf_delay_ms(1);
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/OscillatorInit.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237499?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2020 14:47:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3ef6c9e-b661-481c-8f28-9154f4b7d5d4</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, now you are writing to register with address 0x02 of the device with address 0xDE, but you are not providing the value you want to write to register 0x02.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t tx_data[] = {REG_RTCHOUR, &amp;lt;value to write to REG_RTCHOUR register&amp;gt; };

err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,tx_data , sizeof(tx_data));

APP_ERROR_CHECK(err_code)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237367?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2020 09:58:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac54bec3-3e0f-469a-b945-eab1ebd6adf5</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Pls check the trace of&amp;nbsp;&lt;span&gt;REG_RTCHOUR,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;const uint8_t MCP7940_RTCHOUR = 0x02; ///&amp;lt; Timekeeping, RTCHOUR Register address&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/REG_5F00_RTCHOUR.PNG" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237263?ContentTypeID=1</link><pubDate>Sat, 29 Feb 2020 07:02:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf553b66-a43a-4e35-a7df-dbbe6ddaed5b</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Custom defined which works as below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitclear/"&gt;https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitclear/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset/"&gt;https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Will update the traces &amp;amp; API call as per this soon!&lt;/p&gt;
&lt;p&gt;[quote userid="7571" url="~/f/nordic-q-a/54222/mcp7940-drivers-for-nrf52840/237133"][/quote]&lt;/p&gt;
&lt;p&gt;uint8_t tx_data =&amp;nbsp;&lt;span&gt;REG_RTCHOUR;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,&amp;amp;tx_data&amp;nbsp;, sizeof(tx_data));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;APP_ERROR_CHECK(err_code)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237133?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 13:02:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b254d502-0baf-4de5-8fdf-e08602c35af2</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The trace clearly show that its only the&amp;nbsp;MCP7940_I2C&amp;nbsp;address that is transmitted. The&amp;nbsp;nrf_drv_twi_tx documentation states that the data passed to it should be a uint8_t pointer, so try&amp;nbsp;passing it like this&lt;/p&gt;
&lt;p&gt;uint8_t tx_data =&amp;nbsp;&lt;span&gt;REG_RTCHOUR;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C,&amp;amp;tx_data&amp;nbsp;, sizeof(tx_data));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;APP_ERROR_CHECK(err_code)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Furthermore what does the &lt;span&gt;bitClear (registerValue, 6) and&amp;nbsp;bitSet (registerValue, 6) functions do? You are passing they&amp;#39;re return value as the length parameter to&amp;nbsp;nrf_drv_twi_tx and&amp;nbsp;nrf_drv_twi_rx.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void init_MCP7940() {

    char registerValue = 0x00; // Holds the received register value
    char twelveHour = 0x00; // 0 = 24 Hour Clock Mode / 1 = 12 Hour Clock Mode
    char startClock = 0x01; // 0 = Start Oscillator / 1 = Stop Oscillator
    
    // Turn on/off: 12 hour vs. 24 hour clock
    err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCHOUR, 1);
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MCP7940_I2C, registerValue, sizeof(MCP7940_I2C));
    
    if (twelveHour == 0x00) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCHOUR, bitClear (registerValue, 6));
    if (twelveHour == 0x01) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCHOUR, bitSet (registerValue, 6));
    
    // Turn on/off: Oscillator (starts the clock)
    err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MCP7940_I2C, registerValue, 1);
    
    if (startClock == 0x00) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCSEC, bitClear (registerValue, 7));
    if (startClock == 0x01) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCSEC, bitSet (registerValue, 7));

}&lt;/pre&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/237100?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2020 11:49:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acc58ff4-9ebb-4ec5-8b4b-2520020121ad</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Yes calling &lt;span&gt;init_MCP7940()&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;span style="text-decoration:underline;"&gt;Below register maps:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;const uint8_t&amp;nbsp;MCP7940_I2C = 0xDE;&lt;/strong&gt;&lt;br /&gt; const uint8_t MCP7940_RTCSEC = 0x00; ///&amp;lt; Timekeeping, RTCSEC Register address &lt;br /&gt; const uint8_t MCP7940_RTCMIN = 0x01; ///&amp;lt; Timekeeping, RTCMIN Register address &lt;br /&gt; const uint8_t MCP7940_RTCHOUR = 0x02; ///&amp;lt; Timekeeping, RTCHOUR Register address &lt;br /&gt; const uint8_t MCP7940_RTCWKDAY = 0x03; ///&amp;lt; Timekeeping, RTCWKDAY Register address &lt;br /&gt; const uint8_t MCP7940_RTCDATE = 0x04; ///&amp;lt; Timekeeping, RTCDATE Register address &lt;br /&gt; const uint8_t MCP7940_RTCMTH = 0x05; ///&amp;lt; Timekeeping, RTCMTH Register address &lt;br /&gt; const uint8_t MCP7940_RTCYEAR = 0x06; ///&amp;lt; Timekeeping, RTCYEAR Register address &lt;br /&gt; const uint8_t MCP7940_CONTROL = 0x07; ///&amp;lt; Timekeeping, RTCCONTROL Register address &lt;br /&gt; const uint8_t MCP7940_OSCTRIM = 0x08; ///&amp;lt; Timekeeping, RTCOSCTRIM Register address &lt;br /&gt; const uint8_t MCP7940_ALM0SEC = 0x0A; ///&amp;lt; Alarm 0, ALM0SEC Register address&lt;br /&gt; const uint8_t MCP7940_ALM0MIN = 0x0B; ///&amp;lt; Alarm 0, ALM0MIN Register address&lt;br /&gt; const uint8_t MCP7940_ALM0HOUR = 0x0C; ///&amp;lt; Alarm 0, ALM0HOUR Register address&lt;br /&gt; const uint8_t MCP7940_ALM0WKDAY = 0x0D; ///&amp;lt; Alarm 0, ALM0WKDAY Register address&lt;br /&gt; const uint8_t MCP7940_ALM0DATE = 0x0E; ///&amp;lt; Alarm 0, ALM0DATE Register address&lt;br /&gt; const uint8_t MCP7940_ALM0MTH = 0x0F; ///&amp;lt; Alarm 0, ALM0MTH Register address&lt;br /&gt; const uint8_t MCP7940_ALM1SEC = 0x11; ///&amp;lt; Alarm 1, ALM1SEC Register address&lt;br /&gt; const uint8_t MCP7940_ALM1MIN = 0x12; ///&amp;lt; Alarm 1, ALM1MIN Register address&lt;br /&gt; const uint8_t MCP7940_ALM1HOUR = 0x13; ///&amp;lt; Alarm 1, ALM1HOUR Register address&lt;br /&gt; const uint8_t MCP7940_ALM1WKDAY = 0x14; ///&amp;lt; Alarm 1, ALM1WKDAY Register address&lt;br /&gt; const uint8_t MCP7940_ALM1DATE = 0x15; ///&amp;lt; Alarm 1, ALM1DATE Register address&lt;br /&gt; const uint8_t MCP7940_ALM1MTH = 0x16; ///&amp;lt; Alarm 1, ALM1MONTH Register address&lt;br /&gt; const uint8_t MCP7940_PWRDNMIN = 0x18; ///&amp;lt; Power-Fail, PWRDNMIN Register address&lt;br /&gt; const uint8_t MCP7940_PWRDNHOUR = 0x19; ///&amp;lt; Power-Fail, PWRDNHOUR Register address&lt;br /&gt; const uint8_t MCP7940_PWRDNDATE = 0x1A; ///&amp;lt; Power-Fail, PWDNDATE Register address&lt;br /&gt; const uint8_t MCP7940_PWRDNMTH = 0x1B; ///&amp;lt; Power-Fail, PWRDNMTH Register address&lt;br /&gt; const uint8_t MCP7940_PWRUPMIN = 0x1C; ///&amp;lt; Power-Fail, PWRUPMIN Register address&lt;br /&gt; const uint8_t MCP7940_PWRUPHOUR = 0x1D; ///&amp;lt; Power-Fail, PWRUPHOUR Register address&lt;br /&gt; const uint8_t MCP7940_PWRUPDATE = 0x1E; ///&amp;lt; Power-Fail, PWRUPDATE Register address&lt;br /&gt; const uint8_t MCP7940_PWRUPMTH = 0x1F; ///&amp;lt; Power-Fail, PWRUPMTH Register address&lt;br /&gt; const uint8_t MCP7940_RAM_ADDRESS = 0x20; ///&amp;lt; NVRAM - Start address for SRAM&lt;br /&gt; const uint8_t MCP7940_ST = 7; ///&amp;lt; MCP7940 register bits. RTCSEC reg&lt;br /&gt; const uint8_t MCP7940_12_24 = 6; ///&amp;lt; RTCHOUR, PWRDNHOUR &amp;amp; PWRUPHOUR&lt;br /&gt; const uint8_t MCP7940_AM_PM = 5; ///&amp;lt; RTCHOUR, PWRDNHOUR &amp;amp; PWRUPHOUR&lt;br /&gt; const uint8_t MCP7940_OSCRUN = 5; ///&amp;lt; RTCWKDAY register&lt;br /&gt; const uint8_t MCP7940_PWRFAIL = 4; ///&amp;lt; RTCWKDAY register&lt;br /&gt; const uint8_t MCP7940_VBATEN = 3; ///&amp;lt; RTCWKDAY register&lt;br /&gt; const uint8_t MCP7940_LPYR = 5; ///&amp;lt; RTCMTH register&lt;br /&gt; const uint8_t MCP7940_OUT = 7; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_SQWEN = 6; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_ALM1EN = 5; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_ALM0EN = 4; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_EXTOSC = 3; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_CRSTRIM = 2; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_SQWFS1 = 1; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_SQWFS0 = 0; ///&amp;lt; CONTROL register&lt;br /&gt; const uint8_t MCP7940_SIGN = 7; ///&amp;lt; OSCTRIM register&lt;br /&gt; const uint8_t MCP7940_ALMPOL = 7; ///&amp;lt; ALM0WKDAY register&lt;br /&gt; const uint8_t MCP7940_ALM0IF = 3; ///&amp;lt; ALM0WKDAY register&lt;br /&gt; const uint8_t MCP7940_ALM1IF = 3; ///&amp;lt; ALM1WKDAY register&lt;br /&gt; const uint32_t SECONDS_PER_DAY = 86400; ///&amp;lt; 60 secs * 60 mins * 24 hours&lt;br /&gt; const uint32_t SECONDS_FROM_1970_TO_2000 = 946684800; ///&amp;lt; Seconds between year 1970 and 2000&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Please let me know if any traces required at any line with break-point? Also, I can send the drivers again with a private link to your INBOX it is required?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/236544?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 12:56:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd33c2dc-a8bd-4f62-832a-60f9faa1e458</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Are you calling the&amp;nbsp;&lt;span&gt;init_MCP7940() function at all? You seem to be writting to the same register (0xDE) over and over again. Does 0xDE correspond with&amp;nbsp;REG_RTCHOUR or&amp;nbsp;REG_RTCSEC?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/236513?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 11:59:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5243aba-c411-40d8-bc67-f99029157975</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/initSeq.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;pls guide or let me know further which transactions traces required will update it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/236490?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 10:53:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc67f954-103f-4fa0-abaf-0a7e19a4ba7d</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Please attach a logic trace of the I2C lines when you run the&amp;nbsp;&lt;span&gt;init_MCP7940() function.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/236488?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 10:47:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97c2b05d-7879-4f34-a3b2-1298ad82c12c</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;I am trying to do init sequence but not able to START Clock Oscillator of MCP7940&lt;/p&gt;
&lt;p&gt;void init_MCP7940() {&lt;br /&gt; &lt;br /&gt; char registerValue = 0x00; // Holds the received register value&lt;br /&gt; char twelveHour = 0x00; // 0 = 24 Hour Clock Mode / 1 = 12 Hour Clock Mode&lt;br /&gt; char startClock = 0x01; // 0 = Start Oscillator / 1 = Stop Oscillator&lt;br /&gt; &lt;br /&gt; // Turn on/off: 12 hour vs. 24 hour clock&lt;br /&gt; err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCHOUR, 1);&lt;br /&gt; err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MCP7940_I2C, registerValue, sizeof(MCP7940_I2C));&lt;/p&gt;
&lt;p&gt;if (twelveHour == 0x00) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCHOUR, bitClear (registerValue, 6));&lt;br /&gt; if (twelveHour == 0x01) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCHOUR, bitSet (registerValue, 6));&lt;br /&gt; &lt;br /&gt; // Turn on/off: Oscillator (starts the clock)&lt;br /&gt; err_code = nrf_drv_twi_rx(&amp;amp;m_twi, MCP7940_I2C, registerValue, 1);&lt;/p&gt;
&lt;p&gt;if (startClock == 0x00) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCSEC, bitClear (registerValue, 7));&lt;br /&gt; if (startClock == 0x01) err_code = nrf_drv_twi_tx(&amp;amp;m_twi,MCP7940_I2C, REG_RTCSEC, bitSet (registerValue, 7));&lt;br /&gt; &lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/227728?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2020 15:01:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ade3b81-f1d3-4918-a644-11ec4db94c7c</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;All write transactions are now followed by an ACK, which means that the&amp;nbsp;&lt;span&gt;MCP7940 is responding correctly. You could now try to send the I2C transaction that returns the time from the&amp;nbsp;MCP7940.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/227633?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2020 10:32:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:917b7a99-0c2d-4dd9-b9ab-7339f35903bb</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Please check the traces after code updates:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    twi_init();

//    for (address = 1; address &amp;lt;= TWI_ADDRESSES; address++)
//    {
				while(1)
				{
					//	nrf_gpio_pin_write(RED_LED,1);
        err_code = nrf_drv_twi_tx(&amp;amp;m_twi, 0x6F, &amp;amp;sample_data, sizeof(sample_data),1);
        if (err_code == NRF_SUCCESS)
        {
            detected_device = true;
            NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.\r\n&amp;quot;, address);
						//nrf_gpio_pin_write(RED_LED,0);

        }
        NRF_LOG_FLUSH();
			}
    

    if (!detected_device)
    {
        NRF_LOG_INFO(&amp;quot;No device was found.\r\n&amp;quot;);
        NRF_LOG_FLUSH();
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/0184.11.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/5481.1.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/227440?ContentTypeID=1</link><pubDate>Fri, 03 Jan 2020 14:07:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17a35c2d-7147-4872-8497-51efa0086913</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;With the Arduino you are writting to a device with address 0x6F, not reading from it. So if you want to do exactly the same with the nRF52840, then you need to replace&amp;nbsp;nrf_drv_twi_rx with&amp;nbsp;nrf_drv_twi_tx.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/227370?ContentTypeID=1</link><pubDate>Fri, 03 Jan 2020 09:56:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7343982f-d3d6-4bf3-9037-5572209f83a6</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Sampling for 5secs:&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/84451.Capture.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;Please check the traces of MCP_Breakout with Arduino:&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/MCP_5F00_BreakOut_5F00_Arduino1.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/MCP_5F00_BreakOut_5F00_Arduino2.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;With Arduino, &lt;strong&gt;MCP Works properly able to do i2c, SET &amp;amp; GET DATETIME&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Arduino Code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;Wire.h&amp;gt;
 
 
void setup()
{
  Wire.begin();
 
  Serial.begin(115200);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println(&amp;quot;\nI2C Scanner&amp;quot;);
}
 
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println(&amp;quot;Scanning...&amp;quot;);
 
  nDevices = 0;
  //for(address = 1; address &amp;lt; 127; address++ )
  while(1)
  {
//SENDING 0x6F in decimal as per arduino Wire library
    Wire.beginTransmission(111);
    error = Wire.endTransmission();
 
    if (error == 0)
    {
      Serial.print(&amp;quot;I2C device found at address 0x&amp;quot;);
      if (address&amp;lt;16)
        Serial.print(&amp;quot;0&amp;quot;);
      Serial.print(address,HEX);
      Serial.println(&amp;quot;  !&amp;quot;);
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print(&amp;quot;Unknown error at address 0x&amp;quot;);
      if (address&amp;lt;16)
        Serial.print(&amp;quot;0&amp;quot;);
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println(&amp;quot;No I2C devices found\n&amp;quot;);
  else
    Serial.println(&amp;quot;done\n&amp;quot;);
 
  //delay(5000);           // wait 5 seconds for next scan
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please reply for a possible way of the solution!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/227283?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2020 15:09:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0d30b68-8e01-4dd1-8ee8-ec5f1fe164c7</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The traces still show that the slave, i.e.&amp;nbsp;MCP7940&amp;nbsp;is not ACKing the read. Can you enable the analog sampling in addition to the digital sampling of the salea? That way we can see if the&amp;nbsp;&lt;span&gt;MCP7940 is attempting to pull eh the SDA line high or not.&amp;nbsp;&lt;/span&gt;Also how large is sample_data?&lt;/p&gt;
&lt;p&gt;What does the trace from the Arduino look like? Does it try to read the same address as the one in the trace below? Have you compared the traces?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/226792?ContentTypeID=1</link><pubDate>Tue, 24 Dec 2019 08:19:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35b013d9-d3a1-4133-96dc-e3bc35652372</guid><dc:creator>jagannathan GOPALAKRISHNAN</dc:creator><description>&lt;p&gt;Mr. bjorn,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kindly respond to the codes posted and suggest solutions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/226523?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 10:11:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47135201-51f3-4c87-835c-0c81dc9a5442</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Please check the traces of the custom board nrf52840 &amp;amp; MCP7940(i2c) with the same code.&amp;nbsp;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x768/__key/communityserver-discussions-components-files/4/MCP_5F00_CustomBoard_5F00_Trace.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pull-ups: 4.7kohm&lt;/strong&gt;&amp;nbsp;in custom board&lt;br /&gt;&lt;em&gt;but in MCP7940 break-out board, it&amp;#39;s 10kohm&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SCL		           				 NRF_GPIO_PIN_MAP(0,14)
#define SDA		           				 NRF_GPIO_PIN_MAP(0,13)  

//    for (address = 1; address &amp;lt;= TWI_ADDRESSES; address++)
//    {
				while(1)
				{
        err_code = nrf_drv_twi_rx(&amp;amp;m_twi, 0x6F, &amp;amp;sample_data, sizeof(sample_data));
        if (err_code == NRF_SUCCESS)
        {
            detected_device = true;
            NRF_LOG_INFO(&amp;quot;TWI device detected at address 0x%x.\r\n&amp;quot;, address);

        }
        NRF_LOG_FLUSH();
			}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 drivers for nrf52840</title><link>https://devzone.nordicsemi.com/thread/226478?ContentTypeID=1</link><pubDate>Fri, 20 Dec 2019 06:46:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10b76d7a-0c6d-4746-b9a9-dda79132af0c</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;The connections are correct!&lt;br /&gt;#define SCL NRF_GPIO_PIN_MAP(0,14)&lt;br /&gt;#define SDA NRF_GPIO_PIN_MAP(0,13) &lt;br /&gt;&lt;br /&gt;Connected to the same as per code via jumper wires. Please suggest any other possible way of debugging this issue. As &lt;span&gt;MCP7940 works with Arduino(i2c scanner)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>