<?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 Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78378/spi-communication-is-not-working-in-nrf52840</link><description>Hi, 
 I am using nrf52840 customized dongle in our project. We have interfaced ADS1118 using spi communication with nrf52840 (customized dongle). The problem here with the spi communication is i am not able to read the data from the ADS1118 using spi</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Aug 2021 17:13:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78378/spi-communication-is-not-working-in-nrf52840" /><item><title>RE: SPI Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/thread/325186?ContentTypeID=1</link><pubDate>Mon, 16 Aug 2021 17:13:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fb227ce-de14-4015-aa99-e4bac4129bb4</guid><dc:creator>SilasV</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;here are some points:&lt;/p&gt;
&lt;p&gt;1. No need to have pullup resistors on SPI i/o lines&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. The default SPI config -&amp;nbsp;NRF_DRV_SPI_DEFAULT_CONFIG has mode set to&amp;nbsp;NRF_DRV_SPI_MODE_0, you are not setting this to&amp;nbsp;NRF_DRV_SPI_MODE_1. You should run the SPI with frequency like 1Mhz, the default&amp;nbsp;NRF_DRV_SPI_FREQ_4M (4Mhz)&lt;/p&gt;
&lt;p&gt;3. When you assign a CS pin to SPI, this pin is controlled by the SPI instance, no need to add any code for that.&lt;/p&gt;
&lt;p&gt;4. The reference manual of ADS1118 suggests series resistor of 50ohm on each SPI l/o lines to provide short circuit protection.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;5. Also the DRDY / Dout pin on nRF should be configured as falling edge triggered interrupt input.&lt;/p&gt;
&lt;p&gt;6. Since either config register or conversion register are 16bit type, you need to send 2 bytes , also the MSB goes first when writing / receiving the data.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are two ways to config the device and read conversion values: 32bit mode or 16bit mode. 32bit is reading config register and followed by conversion register. If reading config register is not required, then use 16bit mode, which sends the config register set value (tx) and at the same time receive conversion value.&lt;/p&gt;
&lt;p&gt;For 32bit, you can send 4 bytes, tx_buf first two bytes represent config register values, and rx_buf will receive conversion data (2 bytes) followed by configReg value (2bytes).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First using 32bit mode:&amp;nbsp;&lt;span&gt;if configRegister = 0x058B (this is POR value), then since your buffers are 8bit&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;m_tx_buf[0] = configRegister &amp;gt;&amp;gt; 8;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;m_tx_buf[1] = configRegister;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and then if you run the following SPI transfer commands, you should receive the same value in rx_buffer. If you read the same value, then your SPI is working fine.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, 2, m_rx_buf, 4) &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;the above will transmits 2 bytes which is the config register value and received data will be 4 bytes, this would be the conversion value&amp;nbsp;followed by config reg value. The values in rx_buf[2] and rx_buf[3] should be same as tx_buf sent.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;For 16bit mode which is just reading the conversion data after DRDY is low, you can just send current config reg value (2bytes) and receive conversion data (2bytes) at the same time&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, 2, m_rx_buf, 2)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;hope above helps.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/thread/325001?ContentTypeID=1</link><pubDate>Mon, 16 Aug 2021 05:51:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90e0cebd-ff6d-4772-9c54-f04b2f007719</guid><dc:creator>sharmelaraju</dc:creator><description>&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;We have checked that we are measuring on the correct pins and there is no problem in pin assignment also .But the doubt is the programming can you pleas tell me whether the programming is correct or do i need to make changes in the program&amp;nbsp; as&amp;nbsp; i had initialized the ads1118&amp;nbsp; of the configuration registers in the program. I am attaching the program file here.&lt;/p&gt;
&lt;p&gt;The doubt is do we need to pull up the pin of MISO,MOSI, CS pin in hardware?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SPI_5F00_DONGLLE.txt"&gt;devzone.nordicsemi.com/.../SPI_5F00_DONGLLE.txt&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ADS118.c"&gt;devzone.nordicsemi.com/.../ADS118.c&lt;/a&gt;i&lt;/p&gt;
&lt;p&gt;Initially when we have tried we were getting as zero as output when&amp;nbsp; we have changed the&amp;nbsp;&amp;nbsp;NRFX_SPIM_MISO_PULL_CFG 1 (PULL DOWN)&amp;nbsp; to&amp;nbsp;&amp;nbsp;NRFX_SPIM_MISO_PULL_CFG 3 (PULL UP) in software&amp;nbsp;&lt;/p&gt;
&lt;p&gt;we are reading as 00 and FF in the output . Can you please give me the suggestion where i am going wrong.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/thread/324295?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 14:17:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f2a7538b-862f-4d82-9dbc-c7da5e62429a</guid><dc:creator>SilasV</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I can say the following after going through your code:&lt;/p&gt;
&lt;p&gt;1. I think you need to study the&amp;nbsp;&lt;span&gt;ADS1118&amp;nbsp; datasheet carefully.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;2. The Dout data frame is either 16bit or 32bit. When you are using single-shot conversion by using CS pin, the data frame would be 16bit.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3.&amp;nbsp;There is no code to initialize the config register.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;4. Config register is of R/W type, so you can test if the SPI communication is working ok or not by writing to config register and reading it back and confirming.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;5. After confirming communication is working ok, you can set up ADS1118 for measuring the temperature by using its internal temperature sensor, which will avoid any external circuit issues. If you can read the current temperature correctly then the device is working fine. Then you can go ahead with reading analog inputs.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;6. if the above steps do not work and if this is your custom board, you need to make sure the chip is soldered correctly. you should also provide test points on board for easy access to various pins of the chip.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;7. Further you can also run the code in debug more in SES, and step through each code and see if the SPI pins have expected logic on logic analyzer / oscilloscope. you can also see if the code goes into any hard faults.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;hope the above helps..&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/thread/324233?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 12:14:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc9388c7-0122-4aba-a6f6-3c3be85c0dbb</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;My guess is that either the program is asserting or you&amp;#39;re not measuring on the correct pins. The latter might be due to using the wrong board file or pin assignments etc. The former can be checked by using an external debugger and debugging the fw on the Dongle.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/thread/324221?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 11:48:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2739bbf-b753-4d3e-9835-bf1bd96da6de</guid><dc:creator>sharmelaraju</dc:creator><description>&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;The SPI mode&amp;nbsp; is already set to 1 ,and the chip select is also made as active low ,but we have not waited for the DRDY pin to low and now we are waiting for the DRDY pin to low. When we made this change in the program&amp;nbsp; now we are reading as FF value from the MISO pin.&lt;/p&gt;
&lt;p&gt;Now the problem is i need to read the ADC channel 0 since it is connected to ground it should read as zero but we are reading as FF when&amp;nbsp; we read the other ADC channel it is also reading as zero. Even we have changed the PGA&amp;nbsp; gain ,Data sampling rate to different value but whatever the value we have changed in the configuration register we are reading as FF.&lt;/p&gt;
&lt;p&gt;So when we checked in the oscilloscope the chip select is high, the MISO pin also high but in the clock signal&amp;nbsp; we are&amp;nbsp; not getting clock , and in the MOSI signal the signal is low.&lt;/p&gt;
&lt;p&gt;Can you please tell me where we are going wrong . I am attac&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SPI_5F00_1_5F00_DONGLE.txt"&gt;devzone.nordicsemi.com/.../SPI_5F00_1_5F00_DONGLE.txt&lt;/a&gt;hing the code here.&lt;/p&gt;
&lt;p&gt;Please help me to resolve this problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI Communication is not working in NRF52840</title><link>https://devzone.nordicsemi.com/thread/324064?ContentTypeID=1</link><pubDate>Mon, 09 Aug 2021 14:52:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:297a5d04-6771-4d68-9e1d-7e13cb95aca1</guid><dc:creator>SilasV</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There are a few checks you can do:&lt;/p&gt;
&lt;p&gt;1. Have you configured the SPI for Mode 1 (as per the &lt;span&gt;ADS1118&amp;nbsp;datasheet - the SPI mode should be 1)? Default SPI config has Mode 0.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. Make sure to configure CS as active low.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3. Also need to wait for Dout/DRDY&amp;nbsp;to transition to low, which means conversion data is now available&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;4. after making sure of above, check the signals on the SPI pins on ADS1118 with help of oscilloscope / logic analyzer. You can also use PPK2 logic ports. Make sure the signals are as expected.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>