<?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>QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45687/qspi-clock-cycles-shifted</link><description>Hey all, my QSPI woes continue. I&amp;#39;m trying write 4 bytes (0xDEADBEEF) of data to a flash chip, equivalent to the NRF52840 DK. I&amp;#39;m using PP4IO and 24 bit addressing mode but for some reason it looks like the data lines are trying to transmit 32 bits of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Apr 2019 14:21:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45687/qspi-clock-cycles-shifted" /><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181883?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2019 14:21:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce67e025-6e82-4a6b-83d2-260979dd0a83</guid><dc:creator>Adam Gerken</dc:creator><description>&lt;p&gt;Yeah, that totally worked. Thank you! I don&amp;#39;t think I would have figured that out. Just for my own education, why isn&amp;#39;t the qspi example like that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181829?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2019 11:31:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e096f56-99c2-402d-a441-870a6985427e</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;I think I know what the problem is. The m_buffer_tx[4] variable you have is not word aligned. Since it&amp;#39;s an array of bytes (uint8_t not uint32_t), you are not guaranteed that it will be word aligned in RAM. The QSPI peripheral READ and WRITE SRC registers have to point to a word aligned address, i.e. ending with 0x0, 0x4, 0x08, 0xC. &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/qspi.html?cp=3_0_0_5_18_9_14#register.WRITE.SRC"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/qspi.html?cp=3_0_0_5_18_9_14#register.WRITE.SRC&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Try to add __ALIGN(4) in front of the variable declaration and see if that helps.&lt;/p&gt;
&lt;pre&gt;__ALIGN(4) static uint8_t m_buffer_tx[4] = {0xDE,0xAD,0xBE,0xEF};&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181715?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 18:15:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53e6817d-9496-45b9-af96-48971e532abc</guid><dc:creator>Adam Gerken</dc:creator><description>&lt;p&gt;Yes, I agree the QSPI example works just fine. That&amp;#39;s also what I followed, which is why I&amp;#39;m so confused!&lt;/p&gt;
&lt;p&gt;Here is my initialization code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void qspi_init(void){

    uint8_t temporary = 0x40;
    uint32_t err_code;

    //Init the perif
    nrfx_qspi_config_t config = NRFX_QSPI_DEFAULT_CONFIG;

    err_code = nrfx_qspi_init(&amp;amp;config, qspi_handler, NULL);
    APP_ERROR_CHECK(err_code);

    //configure the Flash
    nrf_qspi_cinstr_conf_t cinstr_cfg = {
        .opcode    = QSPI_STD_CMD_RSTEN,
        .length    = NRF_QSPI_CINSTR_LEN_1B,
        .io2_level = true,
        .io3_level = true,
        .wipwait   = true,
        .wren      = true
    };

    // Send reset enable
    err_code = nrfx_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    // Send reset command
    cinstr_cfg.opcode = QSPI_STD_CMD_RST;
    err_code = nrfx_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    // Switch to qspi mode
    cinstr_cfg.opcode = QSPI_STD_CMD_WRSR;
    cinstr_cfg.length = NRF_QSPI_CINSTR_LEN_2B;
    err_code = nrfx_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, &amp;amp;temporary, NULL);
    APP_ERROR_CHECK(err_code);

    //Test the Flash by checking the device and mfg ids
    static uint8_t temp_rx_buf[5];
    static uint8_t temp_tx_buf[] = {0,0,0,0,0};

    cinstr_cfg.opcode = QSPI_STD_CMD_MFG_DEV_ID;
    cinstr_cfg.length = NRF_QSPI_CINSTR_LEN_6B;
    cinstr_cfg.wren   = false;

    nrfx_qspi_cinstr_xfer(&amp;amp;cinstr_cfg, temp_tx_buf, temp_rx_buf);

    printf(&amp;quot;Flash MFG ID: 0x%X  Dev ID: 0x%X\r\n&amp;quot;, temp_rx_buf[3], temp_rx_buf[4]);

    if((temp_rx_buf[3] != MFG_ID)||(temp_rx_buf[4] != DEVICE_ID)){
      printf(&amp;quot;Hardware Error: FLASH INCORRECT\r\n&amp;quot;);
      while(1);
    }

    printf(&amp;quot;qspi_init\r\n&amp;quot;);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This seems to work fine, I get the correct Device ID from the Flash, and all the registers seems to get set up correctly.&lt;/p&gt;
&lt;p&gt;My event handler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void qspi_handler(nrfx_qspi_evt_t event, void * p_context)
{
    UNUSED_PARAMETER(event);
    UNUSED_PARAMETER(p_context);
    m_qspi_finished = true;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also seems to work just fine.&lt;/p&gt;
&lt;p&gt;I call my qspi_init routine, then go into my main loop:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  while(1){

    uint8_t err_code;
    static uint8_t m_buffer_tx[4] = {0xDE,0xAD,0xBE,0xEF};
    static uint8_t m_buffer_rx[4];

    err_code = nrfx_qspi_write(m_buffer_tx, 4, 0);
    APP_ERROR_CHECK(err_code);
    while(!m_qspi_finished);
    m_qspi_finished = false;

    err_code = nrfx_qspi_read(m_buffer_rx, 4, 0);
    APP_ERROR_CHECK(err_code);
    while(!m_qspi_finished);
    m_qspi_finished = false;

    printf(&amp;quot;Why did the cow cross the road: %X%X%X%X\r&amp;quot;, m_buffer_rx[3],m_buffer_rx[2],m_buffer_rx[1],m_buffer_rx[0]);
    nrf_delay_ms(100);

  }//main while loop&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is where I see the above analyzer traces. The read function seems to return garbage most of the time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Here is the QSPI portion of my sdk_config:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// &amp;lt;e&amp;gt; NRFX_QSPI_ENABLED - nrfx_qspi - QSPI peripheral driver
//==========================================================
#ifndef NRFX_QSPI_ENABLED
#define NRFX_QSPI_ENABLED 1
#endif
// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_SCK_DELAY - tSHSL, tWHSL and tSHWL in number of 16 MHz periods (62.5 ns).  &amp;lt;0-255&amp;gt; 


#ifndef NRFX_QSPI_CONFIG_SCK_DELAY
#define NRFX_QSPI_CONFIG_SCK_DELAY 1
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_XIP_OFFSET - Address offset in the external memory for Execute in Place operation. 
#ifndef NRFX_QSPI_CONFIG_XIP_OFFSET
#define NRFX_QSPI_CONFIG_XIP_OFFSET 0
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_READOC  - Number of data lines and opcode used for reading.
 
// &amp;lt;0=&amp;gt; FastRead 
// &amp;lt;1=&amp;gt; Read2O 
// &amp;lt;2=&amp;gt; Read2IO 
// &amp;lt;3=&amp;gt; Read4O 
// &amp;lt;4=&amp;gt; Read4IO 

#ifndef NRFX_QSPI_CONFIG_READOC
#define NRFX_QSPI_CONFIG_READOC 0
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_WRITEOC  - Number of data lines and opcode used for writing.
 
// &amp;lt;0=&amp;gt; PP 
// &amp;lt;1=&amp;gt; PP2O 
// &amp;lt;2=&amp;gt; PP4O 
// &amp;lt;3=&amp;gt; PP4IO 

#ifndef NRFX_QSPI_CONFIG_WRITEOC
#define NRFX_QSPI_CONFIG_WRITEOC 0
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_ADDRMODE  - Addressing mode.
 
// &amp;lt;0=&amp;gt; 24bit 
// &amp;lt;1=&amp;gt; 32bit 

#ifndef NRFX_QSPI_CONFIG_ADDRMODE
#define NRFX_QSPI_CONFIG_ADDRMODE 0
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_MODE  - SPI mode.
 
// &amp;lt;0=&amp;gt; Mode 0 
// &amp;lt;1=&amp;gt; Mode 1 

#ifndef NRFX_QSPI_CONFIG_MODE
#define NRFX_QSPI_CONFIG_MODE 0
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_FREQUENCY  - Frequency divider.
 
// &amp;lt;0=&amp;gt; 32MHz/1 
// &amp;lt;1=&amp;gt; 32MHz/2 
// &amp;lt;2=&amp;gt; 32MHz/3 
// &amp;lt;3=&amp;gt; 32MHz/4 
// &amp;lt;4=&amp;gt; 32MHz/5 
// &amp;lt;5=&amp;gt; 32MHz/6 
// &amp;lt;6=&amp;gt; 32MHz/7 
// &amp;lt;7=&amp;gt; 32MHz/8 
// &amp;lt;8=&amp;gt; 32MHz/9 
// &amp;lt;9=&amp;gt; 32MHz/10 
// &amp;lt;10=&amp;gt; 32MHz/11 
// &amp;lt;11=&amp;gt; 32MHz/12 
// &amp;lt;12=&amp;gt; 32MHz/13 
// &amp;lt;13=&amp;gt; 32MHz/14 
// &amp;lt;14=&amp;gt; 32MHz/15 
// &amp;lt;15=&amp;gt; 32MHz/16 

#ifndef NRFX_QSPI_CONFIG_FREQUENCY
#define NRFX_QSPI_CONFIG_FREQUENCY 15
#endif

// &amp;lt;s&amp;gt; NRFX_QSPI_PIN_SCK - SCK pin value.
#ifndef NRFX_QSPI_PIN_SCK
#define NRFX_QSPI_PIN_SCK 19
#endif

// &amp;lt;s&amp;gt; NRFX_QSPI_PIN_CSN - CSN pin value.
#ifndef NRFX_QSPI_PIN_CSN
#define NRFX_QSPI_PIN_CSN 17
#endif

// &amp;lt;s&amp;gt; NRFX_QSPI_PIN_IO0 - IO0 pin value.
#ifndef NRFX_QSPI_PIN_IO0
#define NRFX_QSPI_PIN_IO0 20
#endif

// &amp;lt;s&amp;gt; NRFX_QSPI_PIN_IO1 - IO1 pin value.
#ifndef NRFX_QSPI_PIN_IO1
#define NRFX_QSPI_PIN_IO1 21
#endif

// &amp;lt;s&amp;gt; NRFX_QSPI_PIN_IO2 - IO2 pin value.
#ifndef NRFX_QSPI_PIN_IO2
#define NRFX_QSPI_PIN_IO2 22
#endif

// &amp;lt;s&amp;gt; NRFX_QSPI_PIN_IO3 - IO3 pin value.
#ifndef NRFX_QSPI_PIN_IO3
#define NRFX_QSPI_PIN_IO3 23
#endif

// &amp;lt;o&amp;gt; NRFX_QSPI_CONFIG_IRQ_PRIORITY  - Interrupt priority
 
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7 

#ifndef NRFX_QSPI_CONFIG_IRQ_PRIORITY
#define NRFX_QSPI_CONFIG_IRQ_PRIORITY 6
#endif

// &amp;lt;/e&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is SDK 15.2.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181714?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 18:04:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96325ce0-28b6-4ecb-b955-1f9e8cd58c5c</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;I tried with the QSPI SDK example and it seems to be according to spec. Can you please post the code you are using to transmit the data. Are you using the SDK drivers?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181707?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 16:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb881357-7032-4bad-8052-debad09a3256</guid><dc:creator>Adam Gerken</dc:creator><description>&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181705?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 16:25:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8379d449-8ef9-49ff-8e86-fce8763643e3</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Hi, sorry for not responding. I will look into it now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181698?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 16:08:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d16cd172-bfff-4609-968d-97d03fd5c068</guid><dc:creator>Adam Gerken</dc:creator><description>&lt;p&gt;Putting it in 32bit mode, seems to send 5 address bytes, with 4 sets of clock signals, followed by three data bytes. Where is this extra address/dummy byte on the data lines coming from?!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1554998912902v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/181410?ContentTypeID=1</link><pubDate>Wed, 10 Apr 2019 19:48:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14bd83a0-23f0-4abd-94d1-a488cd966dc4</guid><dc:creator>Adam Gerken</dc:creator><description>&lt;p&gt;Anyone?&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/joh2"&gt;Jørgen Holmefjord&lt;/a&gt;? This is driving me nuts.&lt;/p&gt;
&lt;p&gt;Changing the number of data lines doesn&amp;#39;t change anything:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1554926061460v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Still sends the correct number of clocks, but sends 32 bits of zero, instead of 24 zero bits and DEADBEEF.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: QSPI clock cycles shifted</title><link>https://devzone.nordicsemi.com/thread/180877?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2019 00:46:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2259746e-8686-43a7-9047-3b51c33c8327</guid><dc:creator>Adam Gerken</dc:creator><description>&lt;p&gt;No ideas? No one? I still can&amp;#39;t get this to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>