<?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>SPIM fun (not!)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60478/spim-fun-not</link><description>Again, I&amp;#39;m having trouble with the driver library. Earlier when testing I had SPI working OK as a small standalone test , but now I want to add SPIM to my actual application. The application is based on the BLE sample template. 
 I&amp;#39;ve attached a cut down</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Apr 2020 19:45:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60478/spim-fun-not" /><item><title>RE: SPIM fun (not!)</title><link>https://devzone.nordicsemi.com/thread/245912?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 19:45:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa63c26e-8916-4f69-a2eb-92cd1d2758bb</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Ah, sdk_config.h - the bane of developers. I put stuff like this at the top of sdk_config.h:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#if defined(FEATURE_NO_32_KHZ_CRYSTAL)
#define NRFX_CLOCK_CONFIG_LF_SRC         0
#define CLOCK_CONFIG_LF_SRC              0
#define NRF_SDH_CLOCK_LF_SRC             0
#define NRF_SDH_CLOCK_LF_RC_CTIV        16
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV    2
#define NRF_SDH_CLOCK_LF_ACCURACY        1 // &amp;lt;1=&amp;gt; NRF_CLOCK_LF_ACCURACY_500_PPM
#endif

#if defined(FEATURE_SPIM2)
#define SPIM_PRESENT               1
#define NRF_SPI_ENABLED            1//0
#define NRFX_SPI_ENABLED           1//0
#define NRF_SPIM2_ENABLED          1//0
#define NRFX_SPIM_ENABLED          1//0
#define NRFX_SPIM2_ENABLED         1//0
#endif

#if defined(FEATURE_SPIM3)
#define SPIM_PRESENT               1
#define NRF_SPI_ENABLED            1//0
#define NRFX_SPI_ENABLED           1//0
#define NRF_SPIM3_ENABLED          1//0
#define NRFX_SPIM_ENABLED          1//0
#define NRFX_SPIM3_ENABLED         1//0
#define NRFX_SPIM_EXTENDED_ENABLED 1//0
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then in project Preprocessro definitions&amp;nbsp;&lt;em&gt;FEATURE_SPIM2&lt;/em&gt; etc; not pretty but it save lots of time trying to do it &amp;quot;properly&amp;quot; .. these settings give you DMA via the Nordic drivers&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM fun (not!)</title><link>https://devzone.nordicsemi.com/thread/245900?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 16:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8548ec6-7cfa-4037-9082-2bfbc3368a6b</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;OK - humble pie time! Yes it was aliasing as the sampling rate on my LA was sett too low for some reason &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f61e.svg" title="Disappointed"&gt;&amp;#x1f61e;&lt;/span&gt; The drive rate will be useful though... It&amp;#39;s working fine as-is but would be good to set it anyway so not a wasted exercise.&lt;/p&gt;
&lt;p&gt;Do you have any info on the sdk config? The one I&amp;#39;m using has been hacked about and may cause issues down the line. For example I can&amp;#39;t see any option for setting EasyDMA, I may not need it as I&amp;#39;m only sending 2 bytes at a time but every little helps as the CPU can potentially get quite busy at times (I have a SoftDevice running, a SD card connected by SPI, this DAC output and a 5kbps Manchester decoder potentially all running concurrrently)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Nick&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPIM fun (not!)</title><link>https://devzone.nordicsemi.com/thread/245888?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 15:30:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe470ff3-195d-4b39-8c48-7fa7c55e9ba3</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;You may be seeing a &amp;#39;scope alias issue, but even if not using the SPI at 8MHz really requires high drive outputs; these must be set &lt;em&gt;after&lt;/em&gt; initialising the SPI:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  nrf_gpio_cfg(DAC_CS,  NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);
  nrf_gpio_cfg(DAC_SDI, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);
  nrf_gpio_cfg(DAC_SCK, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_H0H1, NRF_GPIO_PIN_NOSENSE);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The Rx stuff is redundant, just use null and 0 thus:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(&amp;amp;dac_buf, DAC_BUF_SIZE, NULL, 0);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If there are still issues, try dropping to clock to 1MHz just to check the capacitance on the connecting leads are not too high, Leads more than a few inches (100mm) can cause transmission issues on the SCK at the DAC if it happens to be a high-speed DAC; in that case a damping or termination resistor will be required. Usually high-drive alone fixes that though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>