<?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>NRF9160 SPI Clock Frequency Config</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77803/nrf9160-spi-clock-frequency-config</link><description>1. Using Zephyr, trying to config SPI_3 of nrf9160 more than 1MHz for flash interface. 
 2. Ending up in faults. 
 3. We need to configure SPI_3 as master with freq &amp;gt; 2MHz 
 4. could you help us out (or) provide an alternate 
 5. Code snippet as below</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Aug 2021 06:19:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77803/nrf9160-spi-clock-frequency-config" /><item><title>RE: NRF9160 SPI Clock Frequency Config</title><link>https://devzone.nordicsemi.com/thread/322995?ContentTypeID=1</link><pubDate>Tue, 03 Aug 2021 06:19:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d60ad35-25b2-4f9e-b70e-8fc932859430</guid><dc:creator>nikhil honeywell</dc:creator><description>&lt;p&gt;Hi Carl &amp;amp; Team,&lt;/p&gt;
&lt;p&gt;I am moving this case to private @&amp;nbsp;&lt;span class="attribute-value"&gt;Case ID: 274304.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="attribute-value"&gt;Thanks for the support !&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 SPI Clock Frequency Config</title><link>https://devzone.nordicsemi.com/thread/322279?ContentTypeID=1</link><pubDate>Wed, 28 Jul 2021 14:54:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:773043c7-a159-44fd-8aec-c3fd5325f227</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello again!&lt;br /&gt;&lt;br /&gt;It&amp;#39;s challenging to review code like this, but from what I can see it looks okay to me. Isn&amp;#39;t it working? How is your device tree overlay configured?&lt;br /&gt;&lt;br /&gt;Note that the nRF9160 supports a maximum of 8MHz over SPI.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 SPI Clock Frequency Config</title><link>https://devzone.nordicsemi.com/thread/322270?ContentTypeID=1</link><pubDate>Wed, 28 Jul 2021 13:59:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1084d881-787c-48dc-b3aa-c6c0f4661a87</guid><dc:creator>nikhil honeywell</dc:creator><description>&lt;p&gt;Hi Carl and Team,&lt;br /&gt;I have&amp;nbsp;below design approach to interface NOR-Flash on SPI3 which supports up to 33MHz.&lt;br /&gt;Could you verify this and give suitable advice.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;// eFLASH SPI:&lt;br /&gt;#define EFLASH_SPI_CH &amp;quot;SPI_3&amp;quot; // SPI channel-3&lt;br /&gt;#define EFLASH_SPI_FREQ 400000 //400000 //1000000 // 1MHz&lt;/p&gt;
&lt;p&gt;// eFLASH SPI&amp;#39;s CS pin:&lt;br /&gt;#define EFLASH_SPICS_NODE DT_ALIAS(flashspics)&lt;br /&gt;#define EFLASH_SPICS DT_GPIO_LABEL(EFLASH_SPICS_NODE, gpios) &lt;br /&gt;#define EFLASH_SPICS_PIN DT_GPIO_PIN(EFLASH_SPICS_NODE, gpios) // pin-15&lt;br /&gt;#define EFLASH_SPICS_FLAGS DT_GPIO_FLAGS(EFLASH_SPICS_NODE, gpios)&lt;/p&gt;
&lt;p&gt;static struct spi_cs_control eFlash_spi_css;&lt;br /&gt;static struct device* eFlash_spi_dev;&lt;br /&gt;static struct spi_config eFlash_spi_cfg;&lt;/p&gt;
&lt;p&gt;static uint8_t eFlash_tx_buffer[261];&lt;br /&gt;static struct spi_buf eFlash_tx_buf = {&lt;br /&gt; .buf = eFlash_tx_buffer,&lt;br /&gt; .len = 1,&lt;br /&gt;};&lt;br /&gt;static struct spi_buf_set eFlash_tx = {&lt;br /&gt; .buffers = &amp;amp;eFlash_tx_buf,&lt;br /&gt; .count = 1,&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;static uint8_t eFlash_rx_buffer[261];&lt;br /&gt;static struct spi_buf eFlash_rx_buf = {&lt;br /&gt; .buf = eFlash_rx_buffer,&lt;br /&gt; .len = 1,&lt;br /&gt;};&lt;br /&gt;static struct spi_buf_set eFlash_rx = {&lt;br /&gt; .buffers = &amp;amp;eFlash_rx_buf,&lt;br /&gt; .count = 1,&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;uint8_t eFlash_spiInit(void) {&lt;br /&gt; eFlash_spi_css.gpio_dev = device_get_binding(EFLASH_SPICS);&lt;br /&gt; eFlash_spi_css.gpio_pin = EFLASH_SPICS_PIN;&lt;br /&gt; eFlash_spi_css.delay = 1; // 1msec&lt;br /&gt; eFlash_spi_css.gpio_dt_flags = GPIO_ACTIVE_LOW;&lt;/p&gt;
&lt;p&gt;eFlash_spi_dev = device_get_binding(EFLASH_SPI_CH);&lt;br /&gt; if (eFlash_spi_dev == NULL) {&lt;br /&gt; //printk(&amp;quot;Could not get %s device\n&amp;quot;, EFLASH_SPI_CH);&lt;br /&gt; return 1; // error, SPI device binding error&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;eFlash_spi_cfg.operation = (SPI_WORD_SET(8) | SPI_TRANSFER_MSB | SPI_OP_MODE_MASTER);// | SPI_MODE_CPOL | SPI_MODE_CPHA );&lt;br /&gt; eFlash_spi_cfg.frequency = EFLASH_SPI_FREQ;&lt;br /&gt; eFlash_spi_cfg.slave = 0;&lt;br /&gt; eFlash_spi_cfg.cs = &amp;amp;eFlash_spi_css;&lt;/p&gt;
&lt;p&gt;return 0; // success, no error configuring SPI parameters&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;uint8_t eFlash_spiTxRx(void) {&lt;br /&gt; int32_t error;&lt;br /&gt; error = spi_transceive(eFlash_spi_dev, &amp;amp;eFlash_spi_cfg, &amp;amp;eFlash_tx, &amp;amp;eFlash_rx);&lt;br /&gt; if (error != 0) {&lt;br /&gt; //printk(&amp;quot;spi_transceive error: %d\n&amp;quot;, error);&lt;br /&gt; return 1; // error, SPI transceive error&lt;br /&gt; }&lt;br /&gt; else {&lt;br /&gt; return 0; // success transceive data on SPI &lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 SPI Clock Frequency Config</title><link>https://devzone.nordicsemi.com/thread/322256?ContentTypeID=1</link><pubDate>Wed, 28 Jul 2021 13:28:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13a895f1-6ac1-40cf-8409-abd9c16eea7b</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hi again, Nikhil!&lt;br /&gt;&lt;br /&gt;I had a talk with Lorenzo about this issue. Let&amp;#39;s try to figure this out! Firstly, what does your Device Tree overlay file look like? It&amp;#39;s important that the&amp;nbsp;&lt;strong&gt;clock-frequency&lt;/strong&gt; parameter is large enough. I understood that you where wondering where the clock is sourced from as well and that would be the HFCLK.&lt;br /&gt;&lt;br /&gt;Could you try to test with this &lt;a href="https://github.com/crfosse/ncs_projects/tree/main/peripheral_zephyr/spi"&gt;SPI sample&lt;/a&gt;? I just tried it and achieved 4MHz frequency without any issues.&lt;br /&gt;&lt;br /&gt;If you get any errors or similar please share your build folder and the error messages.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF9160 SPI Clock Frequency Config</title><link>https://devzone.nordicsemi.com/thread/321716?ContentTypeID=1</link><pubDate>Mon, 26 Jul 2021 07:49:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1c58f03-9917-431d-9cb0-7f19664d652b</guid><dc:creator>Carl Richard</dc:creator><description>&lt;p&gt;Hello, NIkhil!&lt;br /&gt;&lt;br /&gt;Thanks for reaching out. To make it easier for me to help you please provide some more details:&lt;/p&gt;
&lt;p&gt;- What kind of faults are you getting?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;- How is your CS configured? If you control it manually you could try the approach described in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/20683/nrf52-spis-max-speed-when-connected-to-a-hub/80684#80684"&gt;this thread&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Carl Richard&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>