<?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>NRF9160 ADC ,SPI and I2C example codes. SPI and I2C api</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59272/nrf9160-adc-spi-and-i2c-example-codes-spi-and-i2c-api</link><description>Hello 
 I am developing peripheral interfaces on nrf9160 dk, For I2C, sPI and ADC I am not able find exapmle codes. ALso could not find api required for the same to develop the code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Mar 2020 08:39:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59272/nrf9160-adc-spi-and-i2c-example-codes-spi-and-i2c-api" /><item><title>RE: NRF9160 ADC ,SPI and I2C example codes. SPI and I2C api</title><link>https://devzone.nordicsemi.com/thread/240563?ContentTypeID=1</link><pubDate>Thu, 19 Mar 2020 08:39:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d53f7f41-0746-4f81-9568-aa10172d687a</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For ADC, I2C, and SPI you have two alternatives:&lt;/p&gt;
&lt;p&gt;* Use Zephyr API (which uses nrfx in the deep)&lt;/p&gt;
&lt;p&gt;* Use nrfx driver API&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Zephyr API:&lt;/p&gt;
&lt;p&gt;* ADC sample :&amp;nbsp;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/adc"&gt;https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/adc&lt;/a&gt;&amp;nbsp;- &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c#L19"&gt;Change this to&amp;nbsp;&lt;/a&gt;&lt;span&gt;&lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc/src/main.c#L19"&gt;CONFIG_BOARD_NRF9160_PCA10090NS&lt;/a&gt; if using non-secure region.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;* SPI &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/spi/src/main.c"&gt;sample available here&lt;/a&gt;. This is a bit old (device tree properties has changed since the sample was created), so the overlay files needs to be trimmed down - let me know if you need help here.&lt;/p&gt;
&lt;p&gt;* I2C samples can be found on different threads on devzone, for instance this one:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44939/how-to-implement-i2c-on-nrf9160"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/44939/how-to-implement-i2c-on-nrf9160&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrfx API:&lt;/p&gt;
&lt;p&gt;Each nrfx component has a dedicated config option, CONFIG_NRFX_$(COMPONENT), for instance CONFIG_NRFX_SPIM and CONFIG_NRFX_TWIM. Once enabled, include the respective header into your application and use the API directly. You can have a look at samples in nRF5 SDK for examples on using nrfx API, and port these to zephyr.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One special note when using bus peripherals:&lt;/p&gt;
&lt;p&gt;Most of these are shared peripherals. This means that you cannot have SPIM0 and TWIM0 enabled simultaneously. You need to use for instance SPIM1, TWIM2, and UARTE0.&lt;/p&gt;
&lt;p&gt;See the list here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/memory.html?cp=2_0_0_3_1_1#topic"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf9160/memory.html?cp=2_0_0_3_1_1#topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If devices share the same address offset, then they are shared and shall not be used simultaneously.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>