<?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>It cannot use SPI to control TI cc1101 properly.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92947/it-cannot-use-spi-to-control-ti-cc1101-properly</link><description>Hi friend, 
 I am using SDK16.0 and softdevice is S140 7.0.1 version. But SPI can only send out 1 byte. It can&amp;#39;t call back the function of spi_event_handler, so my code is locked while checking spi_xfer_done. 
 Can someone help me? My code snippet is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 18 Oct 2022 12:05:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92947/it-cannot-use-spi-to-control-ti-cc1101-properly" /><item><title>RE: It cannot use SPI to control TI cc1101 properly.</title><link>https://devzone.nordicsemi.com/thread/391184?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 12:05:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1eb8f2ba-bad8-483e-8ce8-2e6491b42a3e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ok, then that was the case. If you want to keep it in the bsp_event_handler, you need to make sure that the SPI has higher priority than the bsp_event_handler.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Look for&amp;nbsp;SPI_DEFAULT_CONFIG_IRQ_PRIORITY and&amp;nbsp;NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY in sdk_config.h and set them to a higher priority (smaller number). Please note that if you are using the SoftDevice (Bluetooth Low Energy stack), then you need to make sure that you don&amp;#39;t use the priorities that are reserved for the SoftDevice. You can see what priorities that are reserved here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=4_7_4_0_15_1"&gt;https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=4_7_4_0_15_1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: It cannot use SPI to control TI cc1101 properly.</title><link>https://devzone.nordicsemi.com/thread/391151?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 10:22:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c40772c1-0840-41a3-a3b0-bf7b67910be8</guid><dc:creator>Ted</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp; put my SPI code in the call back function of&amp;nbsp;bsp_event_handler(bsp_event_t event). I moved it to main loop, then it works fine.&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;
&lt;p&gt;Ted Wu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: It cannot use SPI to control TI cc1101 properly.</title><link>https://devzone.nordicsemi.com/thread/391128?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 09:05:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:261b6897-a36d-45d9-9975-98bddd1df758</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]&lt;p&gt;so my code is locked while checking spi_xfer_done.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;So from where are you calling this? (the function that is calling nrf_drv_spi_transfer() and while (!spi_xfer_done))?&lt;/p&gt;
&lt;p&gt;Are you calling it from your main() function, or from some interrupt? (GPIO change, button press, bluetooth event, other interrupt...)&lt;/p&gt;
&lt;p&gt;Make sure that your spi_xfer_done variable is a volatile, wherever you declare it. E.g.:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;volatile bool spi_xfer_done = false;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is to make sure that optimization doesn&amp;#39;t mess with it and assumes it knows it&amp;#39;s value without actually checking whether it was changed externally.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then, if it still doesn&amp;#39;t work, I assume that it is because you are waiting for spi_xfer_done to be set to true from inside another interrupt with the same or higher priority, not allowing access to the SPI interrupt that is supposed to set spi_xfer_done to true. Is that the case? If so, what interrupt are you waiting in?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>