<?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>How to interface with an MCP4725 on a custom board based on the nRF52832 SoC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100577/how-to-interface-with-an-mcp4725-on-a-custom-board-based-on-the-nrf52832-soc</link><description>Hi, 
 We need to control an MCP4725 DAC from an nRF52832 SoC, and for one reason or the other, no example we&amp;#39;ve found works. 
 This next was the last attempt, based on the examples from &amp;quot;\nordic\v2.3.0\zephyr\samples\drivers\dac&amp;quot;. I created the board</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Jun 2023 09:13:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100577/how-to-interface-with-an-mcp4725-on-a-custom-board-based-on-the-nrf52832-soc" /><item><title>RE: How to interface with an MCP4725 on a custom board based on the nRF52832 SoC</title><link>https://devzone.nordicsemi.com/thread/432471?ContentTypeID=1</link><pubDate>Thu, 22 Jun 2023 09:13:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b45c2582-a557-4ca0-9e57-d5f4847d63d9</guid><dc:creator>V.Lorz</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I moved away from the code for the dac sample, it did not work for me and it also considered having an extra overlay that was unnecessary for my case.&lt;/p&gt;
&lt;p&gt;I created an alias in my dts (namely &lt;code&gt;refdac&lt;/code&gt;), just for convenience, and I was able to get a pointer to the dac driver&amp;#39;s instance using &lt;code&gt;DEVICE_DT_GET(DT_ALIAS(refdac))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;From that point on, I used that reference and the dac&amp;#39;s driver API.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been experiencing a lot of issues with VSC that, my best guess is, can be traced down to the nRF Connect and related extensions.&lt;/p&gt;
&lt;p&gt;So, for anyone coming next to same issues:&lt;/p&gt;
&lt;p&gt;1) Create the dts for your specific board,&lt;/p&gt;
&lt;p&gt;2) Add the DAC node into the i2c bus, just like in the dts excerpt in my previous post.&lt;/p&gt;
&lt;p&gt;3) In the &lt;code&gt;aliases&lt;/code&gt; section of the dts, add a line with an alias for the dac, like: &lt;code&gt;refdac = &amp;amp;dac0;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;4) In application code, a pointer to the dac&amp;#39;s driver instance can be obtained using something similar to &lt;code&gt;struct device const *dev = DEVICE_DT_GET(DT_ALIAS(refdac))&lt;/code&gt;.&amp;nbsp;&lt;code&gt;refdac&lt;/code&gt; is the dac&amp;#39;s alias, as per the &lt;code&gt;aliases&lt;/code&gt; section of the dts.&lt;/p&gt;
&lt;p&gt;5) the rest is just as simple as using calls like: &lt;code&gt;device_is_ready(dev)&lt;/code&gt;, for checking the device status, and &lt;code&gt;dac_write_value(dev, 0 /*channel*/ , 0 /*value*/)&lt;/code&gt; for writing to the dac.&lt;/p&gt;
&lt;p&gt;6) Go to the nRF Connect extension&amp;#39;s configuration and make sure the BOARD_ROOT setting has absolute paths in Windows formats (including the drive letter). This is a requirement for my specific case as I have my projects and the Nordic&amp;#39;s SDK and toolchain installations in a different drive from windows&amp;#39; main drive.&lt;/p&gt;
&lt;p&gt;7) Close VSCode, and restart, then make a pristine build.&lt;/p&gt;
&lt;p&gt;Steps 6) and 7) are required every time a new project that includes .overlay, .dts or board files/folders is added to the workspace.&lt;/p&gt;
&lt;p&gt;BR&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to interface with an MCP4725 on a custom board based on the nRF52832 SoC</title><link>https://devzone.nordicsemi.com/thread/432042?ContentTypeID=1</link><pubDate>Tue, 20 Jun 2023 13:42:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49db4ae0-38fb-4357-b126-5abbf927b28a</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Sorry for the delay, so does device_is_ready() return true now, using the code from the dac sample? It should if I am reading that correctly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to interface with an MCP4725 on a custom board based on the nRF52832 SoC</title><link>https://devzone.nordicsemi.com/thread/430535?ContentTypeID=1</link><pubDate>Mon, 12 Jun 2023 14:12:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c267dbcc-d7b2-488c-8deb-46349fad3bae</guid><dc:creator>V.Lorz</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I was able to get a &amp;quot;no&amp;quot; logic trace on the i2c pins. The device was not initialising the pins and was not producing any output on them, back then when I tested this last week.&lt;/p&gt;
&lt;p&gt;Now I&amp;#39;ve deleted everything today and started from scratch, creating the custom board inside the project, adding the i2c0 element to the .dts, like below, and including the pinctrl in the .dtsi. Following this I made a pristine build, closed VSC, opened again, and flashed the device.&lt;/p&gt;
&lt;p&gt;After doing this the i2c signals do change. It is a 5-byte read operation which produces, hex: [C0, 80, 00, 08, 00].&lt;/p&gt;
&lt;p&gt;This is what I have in the dts. How do I instanciate dac0 in the program and how do I get access to its API?&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;code&gt;&amp;amp;i2c0 {&lt;/code&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; compatible = &amp;quot;nordic,nrf-twi&amp;quot;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; status = &amp;quot;okay&amp;quot;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp;  clock-frequency = &amp;lt; I2C_BITRATE_STANDARD &amp;gt;;&lt;/code&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;code&gt;&amp;nbsp; pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp;  pinctrl-1 = &amp;lt;&amp;amp;i2c0_sleep&amp;gt;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp;  pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;&lt;/code&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;code&gt;&amp;nbsp; dac0: mcp4725@60 {&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; compatible = &amp;quot;microchip,mcp4725&amp;quot;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;  reg = &amp;lt;0x60&amp;gt;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;  #io-channel-cells = &amp;lt;1&amp;gt;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; };&lt;/code&gt;&lt;br /&gt;&lt;code&gt;};&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also removed all code I was using for testing. Now the only code accessing the device is zephyr&amp;#39;s initialization code itself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to interface with an MCP4725 on a custom board based on the nRF52832 SoC</title><link>https://devzone.nordicsemi.com/thread/429963?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 11:17:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b541191f-07db-4663-a3f1-c70a290d7ed3</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you able to get a logic trace of the i2c pins? device_is_ready() checks whether the device was initialized correctly, and in the initialization of MCP4725 the driver tries to read RDY from the device. It would be good to see if the command fails to send or if the device fails to respond.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>