<?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 custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113737/spi-custom-clock-frequency-value-calculation</link><description>I have a slightly off the wall requirement where I need to send a serial data stream at 5kbps, it will be used to drive an external OOK 433MHz transmitter. The data format and bit timing are rigid as it will be used with some existing legacy receivers</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Aug 2024 15:32:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113737/spi-custom-clock-frequency-value-calculation" /><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/498109?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 15:32:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34431510-8648-4b77-b50b-c12cffe84576</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;Sadly 5kbps wasn&amp;#39;t achievable, although it will go low enough the frequency setting doesn&amp;#39;t have enough resolution - it jumps from 4k to 6k&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    spi_config.frequency =   0x0017fffeUL; // 250uS 4kbps
    spi_config.frequency =   0x0017ffffUL; // 165uS 6kbps&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Still it may be a moot point after all: looking at hardware options for the 433MHz RF side many devices now incorporate a TX FIFO so I may be able to just use SPI as-is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/497376?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2024 17:24:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c06b46c-2a0a-4e24-bad0-db9fec387ad3</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Some of the peripherals use common hardware implementations, so for example a peripheral can be used as either SPI or I2C depending on the enable bits; that can create difficulties if switching between them but maybe the baud rate generator is similar to the Uart baud rate generator; I don&amp;#39;t remember trying this on the SPIM but maybe worth a look at my (unofficial) code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;   // Baud rate calculation on nRF51 and nRF52832
   // ===========================================
   //
   // Calculate BAUDRATE value settings for the black-magic 20-bit baud rate generator

   uint32_t CalculatedRegisterValue;
   uint64_t SystemClock = 16000000ULL;    // Typically 16MHz
   uint64_t MagicScaler = 32; // Preserves bits on divisions, shift 32 bits

   // Baudrate generator for the UART is the top 20 bits of a 32-bit field; add in rounding 0.5 ls bit
   CalculatedRegisterValue = (uint32_t)(((((uint64_t)RequiredBaudRate &amp;lt;&amp;lt; MagicScaler) + (SystemClock&amp;gt;&amp;gt;1)) / SystemClock) + 0x800) &amp;amp; 0xFFFFF000;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/497352?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2024 13:46:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7aa60327-9fb4-49ab-9dd3-1db62abc5a0c</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;It&amp;#39;s not that I don&amp;#39;t want to answer really, but I would have to go into the design description for the serial box that include the spi ip to find the details, and that is a bit out of scope.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/497346?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2024 12:54:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1646991b-c4bc-454e-afeb-5fdb3d37bb1f</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;Thanks, but as I highlighted in my original post, I&amp;#39;m not after tested &amp;amp; qualified values! Especially as I&amp;#39;m not actually using it as a SPI interface per se.&lt;/p&gt;
&lt;p&gt;Oh well, if you can&amp;#39;t/won&amp;#39;t divulge the workings behind the FREQUENCY register I&amp;#39;ll have to resort to a fudge-it-and-see approach.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/497333?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2024 12:12:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbd06682-5878-4418-8689-c4f1d727ee46</guid><dc:creator>Kenneth</dc:creator><description>[quote user="Nick_RA"]I was hoping you could advise how the SPIM FREQUENCY register relates to the actual frequency rather than me doing trial-and-error,[/quote]
&lt;p&gt;I can understand that, but unfortunately we have only tested and qualifed those values listed in the FREQUENCY register.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/497323?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2024 11:45:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e05df34f-f3e2-47e7-b202-fb601fd5298d</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;Hi Kenneth&lt;/p&gt;
&lt;p&gt;Actually I don&amp;#39;t need the clock itself. I just need to clock out data at 5kbps; the data itself will be Manchester encoded, which is self-clocking.&lt;/p&gt;
&lt;p&gt;I was hoping you could advise how the SPIM FREQUENCY register relates to the actual frequency rather than me doing trial-and-error,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI custom clock frequency value calculation</title><link>https://devzone.nordicsemi.com/thread/497319?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2024 11:24:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48cba55f-0f79-4fc5-a680-f9870419b11f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I would have looked at using PWM, should be no problem to make a 5kHz PWM signal that is continuous.&amp;nbsp;But if you only want to send 56 &amp;quot;clock&amp;quot; periods, then I agree that using SPIM might also work, but you will need to test it, because you may not get a very accurate frequency of 5kHz, since i believe not all LSB bits of the FREQUENCY register impact the frequency. So you will need to simply test how close you get to 5kHz:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html#register.FREQUENCY"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html#register.FREQUENCY&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>