<?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>Transmitting 16 bit at once over SPI on nRF51-DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26790/transmitting-16-bit-at-once-over-spi-on-nrf51-dk</link><description>Forgive me if this is a stupid question, but I am new to programming microcontrollers other than Arduino and SPI in general. 
 I have a DAC that has a 16-bit register and I need to write to it using SPI. If I try to transfer 16 bits,
only the second</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Nov 2017 11:32:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26790/transmitting-16-bit-at-once-over-spi-on-nrf51-dk" /><item><title>RE: Transmitting 16 bit at once over SPI on nRF51-DK</title><link>https://devzone.nordicsemi.com/thread/105308?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 11:32:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9fab814-99a5-40d0-9129-306d8361a311</guid><dc:creator>Jakub Rzeszutko</dc:creator><description>&lt;p&gt;This driver has been written mainly for nrf52832 where when using SPI with EasyDMA you are limited to 8bit buffer. As nrf52810 and nrf52840 have different buffer size we plan to rework this soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmitting 16 bit at once over SPI on nRF51-DK</title><link>https://devzone.nordicsemi.com/thread/105307?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 11:05:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c938d50-bb51-4881-8a3e-57be478608f0</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;.. and let me repeat the last line of my answer which already covered this ..&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;If you want to send 16 bit then use a uint16_t to store it and cast the pointer on send.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it&amp;#39;s just a byte pointer, it has a length, I so wish Nordic had used void* here but they didn&amp;#39;t.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmitting 16 bit at once over SPI on nRF51-DK</title><link>https://devzone.nordicsemi.com/thread/105306?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 11:02:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68ffdfed-fb5d-4055-a366-dbda7ec8201c</guid><dc:creator>stephbur</dc:creator><description>&lt;p&gt;Thank you for your answer, that could be indeed the problem. But apparently the transfer function only accepts uint8_t. Do i have to rewrite transfer in the SDK to accept 16bit integers?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Transmitting 16 bit at once over SPI on nRF51-DK</title><link>https://devzone.nordicsemi.com/thread/105305?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 10:39:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8074d63e-0bba-4e26-8917-89bf7fe23f58</guid><dc:creator>RK</dc:creator><description>&lt;pre&gt;&lt;code&gt;uint8_t test_payload = 43775; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;that&amp;#39;s not going to work very well is it, 43775 doesn&amp;#39;t fit into a uint8_t. So you&amp;#39;re getting one byte of real data and one byte of random garbage off the stack.&lt;/p&gt;
&lt;p&gt;If you want to send 16 bit then use a uint16_t to store it and cast the pointer on send.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>