<?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>nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49175/nrfgo-sdk-nrf24le1-spi-questions</link><description>Dear All, 
 Could some one help to answer my commented questions below ? thank you so much ! 
 1. 
 //Definition at line 743 of file hal_nrf.c . 
 uint8_t hal_nrf_read_reg ( uint8_t reg ) 
 
 
 
 
 
 
 
 {
 uint8_t temp;

 CSN_LOW ();

 HAL_NRF_HW_SPI_WRITE</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Jul 2019 13:52:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49175/nrfgo-sdk-nrf24le1-spi-questions" /><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/197160?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 13:52:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5188bdb-a31c-4888-8136-636bbabb2c3d</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I agree with your comments.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/196698?ContentTypeID=1</link><pubDate>Fri, 05 Jul 2019 06:16:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69c0b969-3c02-4982-85ad-2caae5c1b289</guid><dc:creator>Kevin</dc:creator><description>&lt;p&gt;Hi Kenneth,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks a lot for your answers !&lt;/p&gt;
&lt;p&gt;i updated comments according my understanding, please correct me if anything wrong, thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1:&lt;br /&gt;uint8_t hal_nrf_read_reg ( uint8_t reg )&lt;/p&gt;
&lt;p&gt;{&lt;br /&gt; uint8_t temp;&lt;/p&gt;
&lt;p&gt;CSN_LOW();&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE(reg);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// SPIRDAT = reg; &lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {}&lt;br /&gt; temp = HAL_NRF_HW_SPI_READ();&amp;nbsp; &amp;nbsp; &amp;nbsp;// temp is the value of STATUS&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE(0U);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Here write a extra dummy value in order to get the output from above command.&lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {} &lt;br /&gt; temp = HAL_NRF_HW_SPI_READ();&amp;nbsp; &amp;nbsp; &amp;nbsp; // Here this temp stored the real reg value.&lt;br /&gt; CSN_HIGH();&lt;/p&gt;
&lt;p&gt;return temp;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;2:&lt;br /&gt;uint8_t hal_nrf_write_reg(uint8_t reg, uint8_t value) &lt;br /&gt;{&lt;br /&gt; uint8_t retval;&lt;/p&gt;
&lt;p&gt;uint8_t volatile dummy;&lt;/p&gt;
&lt;p&gt;CSN_LOW();&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE((W_REGISTER + reg));&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // SPIRDAT = W_REGISTER + reg; &lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {}&lt;br /&gt; retval = HAL_NRF_HW_SPI_READ();&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// retval is the value of STATUS&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE(value);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// SPIRDAT = value; &lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {}&lt;br /&gt; dummy = HAL_NRF_HW_SPI_READ();&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // dummy is not useful, because our value already wrote in. one of this extra READ Operation&amp;#39;s purpose i think maybe for clearing up the SPIRDAT&lt;/p&gt;
&lt;p&gt;CSN_HIGH();&lt;/p&gt;
&lt;p&gt;return retval; &lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/196631?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2019 14:54:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97eeb767-5d20-49d7-bab2-2c9b6f2d6c39</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You will need to call &amp;#39;input&amp;#39; =&amp;nbsp;&lt;span&gt;HAL_NRF_HW_SPI_WRITE(&amp;#39;output&amp;#39;) every time you want to clock the next 8bit on the SPI interface,&amp;nbsp;at the same time you then transmit &amp;#39;output&amp;#39; and receive &amp;#39;input&amp;#39;. If the output or input is don&amp;#39;t care, you use can use any value (e.g. 0 or dummy value).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/196437?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2019 08:55:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4eef03b8-b375-4692-b6e5-e19907f4a72e</guid><dc:creator>Kevin</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;Thank you so much for update!&lt;/p&gt;
&lt;p&gt;Actually i have some basic understanding of SPI protocol and the SPI time &lt;span&gt;sequence&lt;/span&gt;, but just confused why nRFGo spi written like this.&amp;nbsp; in detail for example,&lt;/p&gt;
&lt;p&gt;The&amp;nbsp; SPI register READ function&amp;nbsp;&amp;nbsp;&lt;span&gt;hal_nrf_read_reg&amp;nbsp; ( uint8_t&amp;nbsp; reg )&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;let&amp;#39;s pass a real register address like&amp;nbsp;&amp;nbsp;hal_nrf_read_reg&amp;nbsp; ( 0x07&amp;nbsp;)&amp;nbsp; &amp;nbsp;[Register STATUS]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;hal_nrf_read_reg&amp;nbsp; ( STATUS )&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;{&lt;br /&gt; uint8_t temp;&lt;/p&gt;
&lt;p&gt;CSN_LOW();&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE(&lt;span&gt;STATUS&lt;/span&gt;);&lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {}&lt;br /&gt; temp = HAL_NRF_HW_SPI_READ();&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&amp;nbsp; we can get the STATUS result here&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE(0U);&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//&amp;nbsp; &amp;nbsp; why we still need this one ? what does 0U means?&lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {} &lt;br /&gt; temp = HAL_NRF_HW_SPI_READ();&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //&amp;nbsp; &amp;nbsp; during the second section&amp;#39;s execution, maybe there is other&amp;nbsp;&lt;/p&gt;
&lt;p&gt;interrupts have happened, but we still return the second temp , is that still accurate ?&lt;/p&gt;
&lt;p&gt;CSN_HIGH();&lt;/p&gt;
&lt;p&gt;return temp;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;br /&gt;Kevin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/196417?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2019 08:30:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d06079ed-9eaf-4af2-9f55-e41bf61753af</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi Kevin,&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t explain this to you, you will need to first understand how SPI works in general. Then once you understand how SPI works, then much of this is self explanatory.&lt;/p&gt;
&lt;p&gt;To create an SPI clock, you will need to write some data on the SPI, the data can be a command, a value, or dummy.&amp;nbsp;SPI is always bidirectional, so for each byte written, there is one byte received. Whether you want to keep any or all of the values received depends on the command.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/196367?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2019 03:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9ca5d34-c943-46b6-ab3b-24e502eb432c</guid><dc:creator>Kevin</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Kenneth,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you very much for your answer !&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;There are still few points haven&amp;#39;t yet got the answer, would you please help ?&lt;/p&gt;
&lt;p&gt;&lt;span&gt; &lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/support/add/nrf24le1_2hal__nrf__hw_8h.html#a1f094d4506edfffef68390745b26c59c"&gt;HAL_NRF_HW_SPI_WRITE&lt;/a&gt;&lt;span&gt;(0U);&amp;nbsp;&amp;nbsp;//&amp;nbsp; what is the Parameter 0U means ? reg or command? or dummy ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regarding the function hal_nrf_write_reg(uint8_t reg, uint8_t value),&amp;nbsp;i&amp;#39;m still&amp;nbsp;not quite understand the logic of SPI operations,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;like why the value shift in at last and return the retval rather than dummy?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE((W_REGISTER + reg));&lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {}&lt;br /&gt; retval = HAL_NRF_HW_SPI_READ();&lt;/p&gt;
&lt;p&gt;HAL_NRF_HW_SPI_WRITE(value);&lt;br /&gt; while(HAL_NRF_HW_SPI_BUSY) {}&lt;br /&gt; dummy = HAL_NRF_HW_SPI_READ();&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;br /&gt;Kevin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFGo SDK nRF24LE1 SPI questions</title><link>https://devzone.nordicsemi.com/thread/196169?ContentTypeID=1</link><pubDate>Wed, 03 Jul 2019 08:30:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c55eb91e-9c08-461e-936b-6fa3c22b0d94</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;SPI read or write typically always is minimum 2bytes: First byte is the command byte that indicate the register address to access (read or write), second&amp;nbsp;byte (or several bytes) contain the&amp;nbsp;data (value) of that register.&lt;/p&gt;
&lt;p&gt;So to answer your questions:&lt;/p&gt;
&lt;p&gt;1. The first&amp;nbsp;&lt;span&gt;temp = &lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/support/add/nrf24le1_2hal__nrf__hw_8h.html#ae2ec22e7c136aef3c1bb0fad4f04747c"&gt;HAL_NRF_HW_SPI_READ&lt;/a&gt;&lt;span&gt;(); is basically a dummy read, but to save RAM the same variable &amp;#39;temp&amp;#39; is updated two times (used as dummy first time, then actual value to read &amp;#39;temp&amp;#39; the second time).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. When writing the first byte to indicate the register address to access, then the return dummy byte actually contains a STATUS register that can be used.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As an example of SPI transfer see below sequence when read or write to the Radio (nRF24L01).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-7ffe99193e074641be4e090a2c8cb3d9/pastedimage1562142630832v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>