<?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>nrf52832 SPIM Driver &amp;quot;Missing&amp;quot; MISO Bits</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100536/nrf52832-spim-driver-missing-miso-bits</link><description>Hi All, I am running into an issue where the data returned from nrfx_spim_xfer() does not match what is being transmitted on the line. More details below. 
 MCU: nrf52832 SDK: nRF5 17.1.0 
 IDE: Segger 5.70a 
 Here is an example of the issue. When trying</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Jun 2023 13:56:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100536/nrf52832-spim-driver-missing-miso-bits" /><item><title>RE: nrf52832 SPIM Driver "Missing" MISO Bits</title><link>https://devzone.nordicsemi.com/thread/430531?ContentTypeID=1</link><pubDate>Mon, 12 Jun 2023 13:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a013e4f-a196-43f7-b775-9ca3a6a0de89</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Hi, I should have clarified more. In the code samples I posted in the comments, I had currently been using SPI MODE 3. The pictures taken in the original post were using MODE 0. We have been going back and forth with the manufacturer of the AFE for some time now, their documentation and reps have been giving us incorrect information. We currently believe that SPI MODE 3 is the correct mode to use with their chip. Since switching to MODE 3, we have not seen the missing bits issue, which is good. I would still be concerned about the missing bits when using SPI MODE 0 though, because even if it&amp;#39;s the wrong mode, the micro should still be reading the signal shown on the scope correctly, which it was not.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I did try the manual pin configurations to increase the drive strength and that did not seem to have an impact on performance.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 SPIM Driver "Missing" MISO Bits</title><link>https://devzone.nordicsemi.com/thread/430059?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 18:01:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4935d2ce-391e-4957-8aa0-8f8edbabf258</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Yes, that looks good and just repeat for both MOSI and CS. I would also enable the pull-up on the MISO input, but that may be the default already and is not the issue you are reporting. As an aside, in case you ever disable the SPI for (say) extended low-power sleep set the default output state of SCK, MOSI and CS to &amp;#39;1&amp;#39; before spi_init() unless you use a port pin to power down the ADS in which case they should be &amp;#39;0&amp;#39; or changed to inputs to avoid phantom powering the ADS/AFE in such an extended sleep.&lt;/p&gt;
&lt;p&gt;Edit: I see you are using Mode 3; I thought the FAE said use Mode 0? In passing, other manufacturers such as TI AFEs can use Mode 1 or Mode 3, which implies Mode 0&amp;nbsp;would not be interchangeable with Mode 3.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 SPIM Driver "Missing" MISO Bits</title><link>https://devzone.nordicsemi.com/thread/429841?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 17:52:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae94ba64-1076-4223-9efe-806e2ec326d2</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Thanks for the reply. I have not tried that yet. I found the use of nrf_gpio_cfg() in&amp;nbsp;nrfx_spim.c and copied it to right after the spim init. Does this look correct? And would I just repeat with MOSI and CS with all of the same parameters besides the pin #?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1686160258158v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 SPIM Driver "Missing" MISO Bits</title><link>https://devzone.nordicsemi.com/thread/429830?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 16:40:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe38e30d-6f1c-4c3d-8d5c-6a8fdd3ac626</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;You may have already tried this, but if not it will improve reliability of reception. Increase the nRF52 drive strength to CS, SCK and MOSI output drivers to H0H1 instead of the default S0S1. This can be done after the SPI init&amp;nbsp;nrfx_spim_init() if you are using Nordic libraries and want to avoid editing those.&lt;/p&gt;
&lt;p&gt;H0H1 on the clock pin SCK in particular can avoid incorrect data reception on MISO and only a very high bandwidth &amp;#39;scope will show the jitter on the AFE clock in pin transition which can cause bit corruption.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 SPIM Driver "Missing" MISO Bits</title><link>https://devzone.nordicsemi.com/thread/429818?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 14:31:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9395be5f-136c-4c02-b4ea-0f101d13d046</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Also, after talking to reps from analog devices, the chip response in the posted scope screenshot is supposed to be 0x88 not 0x89 as I mentioned in the post. The last bit looks visually to be very close to being HIGH during the last rising edge clock cycle, but it is supposed to go HIGH immediately after the last clock cycle because the MISO pin on the chip is dual purpose pin with a sample rdy interrupt function.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832 SPIM Driver "Missing" MISO Bits</title><link>https://devzone.nordicsemi.com/thread/429802?ContentTypeID=1</link><pubDate>Wed, 07 Jun 2023 13:30:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d397896b-21b9-4608-8002-79b6d1887d1a</guid><dc:creator>dlewis</dc:creator><description>&lt;p&gt;Attached are 3 files. app.c is where the SPI init and ad7785 init functions are called. ad7785_init is where the SPI transactions in question are called. spi_driver.c is where nrfx_spim_xfer() is called.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/app.c"&gt;devzone.nordicsemi.com/.../app.c&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ad7785.c"&gt;devzone.nordicsemi.com/.../ad7785.c&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/spi_5F00_driver.c"&gt;devzone.nordicsemi.com/.../spi_5F00_driver.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>