<?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>SPI Clock BUG</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9636/spi-clock-bug</link><description>Hi:
I use the demo code (nRF51_SDK_9.0.0_2e23562-NORDIC\nRF51_SDK_9.0.0_2e23562\examples\peripheral\spi_master) find a BUG(?) : when i use 1M clock , 1byte translate use about 10us, the delay between 2 byte is OK, when i use 4M clock , 1byte translate</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Oct 2015 11:21:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9636/spi-clock-bug" /><item><title>RE: SPI Clock BUG</title><link>https://devzone.nordicsemi.com/thread/35615?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2015 11:21:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc49474e-946c-48ac-bfcf-1a5e58bbf44a</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;We discussed this a while ago in &lt;a href="https://devzone.nordicsemi.com/question/30908/slow-spi-performance/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt; plus some others. I have about 3MHz running, Clem said he got 4MHz. That required not using the SPI Master driver but writing our own which, when it gets an interrupt, keeps filling the TX buffer as fast as it can until it runs out of characters or manages to fill the buffer, at which point it waits for another interrupt.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Clock BUG</title><link>https://devzone.nordicsemi.com/thread/35614?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2015 08:58:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aab301d-a336-46d0-b6c8-2ba19960ed02</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;This is due to overhead in the spi_master.c driver. Sadly there is no easyDMA in the master SPI on the nRF51 so in the driver an interrupt is called after every transmitted byte. The interrupt routine is responsible for handling incoming bytes and load new bytes to the transmit register which takes time. The SPI is double buffered meaning that the second byte can be written to the TXD register immediately after the first one. In other words, the SPI driver is not using the interrupt handler to load the second byte so there is almost no overhead. The following bytes however, are loaded into the TXD register using the interrupt handler creating an overhead.&lt;/p&gt;
&lt;p&gt;I did some experiments and it looks like you actually won&amp;#39;t get any higher throughput by increasing the frequency above 1MHz if you use the driver in the SDK:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SPI-times.png" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;You can probably make your own interrupt routine though, customized for your own needs that will work faster than the one in the SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>