<?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 device tree implementation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114789/mcp7940-device-tree-implementation</link><description>Hi I am receiving the error &amp;quot;Linking C executable zephyr\zephyr_pre0.elf FAILED:&amp;quot; which I have found is linked to the mcp7940 device tree node through the error code &amp;quot; undefined reference to `__device_dts_ord_57&amp;#39;&amp;quot; in the device_generated.h file. I want</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Oct 2024 12:03:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114789/mcp7940-device-tree-implementation" /><item><title>RE: MCP7940 device tree implementation</title><link>https://devzone.nordicsemi.com/thread/505171?ContentTypeID=1</link><pubDate>Mon, 07 Oct 2024 12:03:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2149c4ad-c3d3-464f-91a6-639566c9a3a6</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Did you check the&amp;nbsp;&lt;strong&gt;line&lt;/strong&gt; 57 or the number in the list corresponding to 57 here? You can upload it here if you want me to take a look?&lt;/p&gt;
&lt;p&gt;If it was due to the MCP7940 RTC it means that the RTC on the sensor wasn&amp;#39;t enabled I guess. Is everything running as expected when using the standard driver API? If so, can we close this ticket now, or do you have any follow-ups?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 device tree implementation</title><link>https://devzone.nordicsemi.com/thread/505069?ContentTypeID=1</link><pubDate>Sat, 05 Oct 2024 19:38:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a906763e-016c-4acc-bdd3-09317ff3b590</guid><dc:creator>ljch</dc:creator><description>&lt;p&gt;Hi Simon, I did check line 57 and it said it corresponded to the MCP7940 RTC. I ended up scrapping the custom driver and just used the generic i2c driver api.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 device tree implementation</title><link>https://devzone.nordicsemi.com/thread/503198?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2024 06:18:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4229ee5f-0c9f-483a-a6e4-1e625fec6b18</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;So, the device_dts_ord_xx error in itself doesn&amp;#39;t tell us much other than that the device tree structure (dts) is missing something. Please check out the file in&amp;nbsp;&lt;strong&gt;build\zephyr\include\generated\devicetree_generated.h&amp;nbsp;&lt;/strong&gt;and check what the number 57 corresponds to. You can check out the DevAcademy lesson on troubleshooting the devicetree here:&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-2-debugging/topic/troubleshooting-the-devicetree/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-2-debugging/topic/troubleshooting-the-devicetree/&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCP7940 device tree implementation</title><link>https://devzone.nordicsemi.com/thread/503010?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2024 23:50:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bc0040e-4daf-40cb-bfc6-25993ee456cb</guid><dc:creator>ljch</dc:creator><description>&lt;p&gt;I am using the nrf connect SDK 2.6.1 and here is my proj.conf file&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_RTT_CONSOLE=y
CONFIG_I2C=y
CONFIG_LOG=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;and the custom board defconfig file&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52805_CAAA=y
CONFIG_BOARD_CESSADK_NRF52805=y

# Enable MPU
CONFIG_ARM_MPU=y

# Enable hardware stack protection
CONFIG_HW_STACK_PROTECTION=y

# enable GPIO
CONFIG_GPIO=y

# enable console
CONFIG_CONSOLE=y

# enable RTT console
CONFIG_USE_SEGGER_RTT=y

# additional board options
CONFIG_GPIO_AS_PINRESET=n

CONFIG_PINCTRL=y

# enable internal oscillator
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;here is the main.c code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
#include &amp;lt;zephyr/drivers/i2c.h&amp;gt;

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   1000

/* The devicetree node identifier for the &amp;quot;led0&amp;quot; alias. */
#define LED0_NODE DT_ALIAS(led0)
#define RTC_NODE DT_NODELABEL(mcp7940n)

#define MCP7940_ADDR 0x6F
#define RTCSEC_ADDR 0x00
#define RTCMIN_ADDR 0x01
#define RTCSHOUR_ADDR 0x02
#define RTCWKD_ADDR 0x03
/*
 * A build error on this line means your board is unsupported.
 * See the sample documentation for information on how to fix this.
 */
LOG_MODULE_REGISTER(maindev, LOG_LEVEL_DBG);
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);



int main(void)
{
	const struct device *rtc_dev; 
	rtc_dev = DEVICE_DT_GET(RTC_NODE);
	uint8_t write_msg = 0x00; 
	uint8_t read_sec_msg = 255; 
	uint8_t read_wkd_msg = 0;
	
	int ret;
    // Get the I2C device
	

    if (!device_is_ready(rtc_dev)) {
        LOG_ERR(&amp;quot;I2C device not ready&amp;quot;);
        return 0;
    }
	if (!gpio_is_ready_dt(&amp;amp;led)) {
		LOG_ERR(&amp;quot;LED not ready&amp;quot;);
		return 0;
	}

	//load the rtc sec register with 0 while the osc is disabled
	ret = i2c_reg_write_byte(rtc_dev, MCP7940_ADDR,RTCSEC_ADDR, 0);
	
	if(ret){
		LOG_ERR(&amp;quot;write to osc start bit failed error = %d&amp;quot;,ret);
	}

	write_msg |= 0x80; //SET THE START OSCILLATOR BIT 

	//write to the start bit of the oscillator
	ret = i2c_reg_write_byte(rtc_dev, MCP7940_ADDR,RTCSEC_ADDR,write_msg);
	
	if(ret){
		LOG_ERR(&amp;quot;write to rtc second register failed error = %d&amp;quot;,ret);
	}

	//wait three seconds
	k_msleep(1000);
	k_msleep(1000);
	k_msleep(1000);

	//read the sec register after waiting 3 seconds
	ret = i2c_reg_read_byte(rtc_dev,MCP7940_ADDR, RTCSEC_ADDR,&amp;amp;read_sec_msg);

	if(ret){
		LOG_ERR(&amp;quot;read to rtc second register failed error = %d&amp;quot;,ret);
	}


	//read the rtc second address to see if one second has passed
	ret = i2c_reg_read_byte(rtc_dev,MCP7940_ADDR, RTCWKD_ADDR,&amp;amp;read_wkd_msg);
	
	
	if(ret){
		LOG_ERR(&amp;quot;read to rtc second register failed error = %d&amp;quot;,ret);
	}
	
	LOG_INF(&amp;quot;here is the read message: 0x%02X&amp;quot;, read_sec_msg);
	LOG_INF(&amp;quot;here is the wkd register contents: 0x%02X&amp;quot;, read_wkd_msg);
	

	ret = gpio_pin_configure_dt(&amp;amp;led, GPIO_OUTPUT_ACTIVE);
	if (ret &amp;lt; 0) {
		return 0;
	}

	while (1) {
		ret = gpio_pin_toggle_dt(&amp;amp;led);
		if (ret &amp;lt; 0) {
			return 0;
		}
		k_msleep(SLEEP_TIME_MS);
	}
	return 0;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>