This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI peripherial with no output

Hi,

I have got the problem with using BMD-340 demo SPI commuination for many days.

+----------------------------+
|                                    |
| Problem Describtion   |
|                                    |
+----------------------------+

1. Developing Tool:

(*) RIGADO BMD-340 Evaluation Kit  BMD-340 datasheet
(*) Module based on Nordic nRF52840
-------------------------------------

2. Software:   Segger-Embedded-Studio 

(*) SEGGER Embedded Studio for ARM 4.30c
(*) nRF5_SDK_16.0.0_98a08e2
(*) Nordic\nRF5_SDK_16.0.0_98a08e2\examples\peripheral
-------------------------------------

3. Present steps 

Step 1 - Go folder [D:\User\Nordic\nRF5_SDK_16.0.0_98a08e2\examples\peripheral\nrfx_spim\pca10056\blank\ses].

Step 2 - Open [nrfx_spim_pca10056.emProject] by {SEGGER Embedded Studio for ARM 4.30c} .

Step 3 - Connect BMD-340 board to PC then turn on the power.

Step 4 - In {SEGGER Embedded Studio for ARM 4.30c} press [Target] -> [Connect J-link].

Step 5 - In {SEGGER Embedded Studio for ARM 4.30c} press [Target] -> [Download nrfx_spim_pca10056].


-------------------------------------

+----------------------------+
|                                   |
| SPI signal output pin |
|                                   |
+----------------------------+

4. Excepted Result


Step 1 - On {SEGGER Embedded Studio for ARM 4.30c} the project [nrfx_spim_pca10056.emProject], see "main.c".

Step 2 - Default SPI specification starting from line 51.

#include "nrfx_spim.h"
#include "app_util_platform.h"
#include "nrf_gpio.h"
#include "nrf_delay.h"
#include "boards.h"
#include "app_error.h"
#include <string.h>
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"

#define NRFX_SPIM_SCK_PIN  3
#define NRFX_SPIM_MOSI_PIN 4
#define NRFX_SPIM_MISO_PIN 28
#define NRFX_SPIM_SS_PIN   29
#define NRFX_SPIM_DCX_PIN  30

#define SPI_INSTANCE  3                                           /**< SPI instance index. */
static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);  /**< SPI instance. */

static volatile bool spi_xfer_done;  /**< Flag used to indicate that SPI instance completed the transfer. */

#define TEST_STRING "Nordic123456789012345678901234567890"
static uint8_t       m_tx_buf[] = TEST_STRING;           /**< TX buffer. */
static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];  /**< RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**< Transfer length. */

51 #define NRFX_SPIM_SCK_PIN 3
52 #define NRFX_SPIM_MOSI_PIN 4
53 #define NRFX_SPIM_MISO_PIN 28
54 #define NRFX_SPIM_SS_PIN 29
55 #define NRFX_SPIM_DCX_PIN 30
.
.
.
62 #define TEST_STRING "Nordic123456789012345678901234567890"

Step 3 - so that I get string "Nordic123456789012345678901234567890" at BMD-340 GPIO pin 4 because [#define NRFX_SPIM_MOSI_PIN 4] on line 52.
-------------------------------------

+-----------------------------+
|                                    |
| Logic Analyzer Demo   |
|                                    |
+-----------------------------+


Step 1 - Logic Analyzer connect to BMD-340 GPIOpin4(P0.4 on board) or P0.3

Step 2 - setting analysis rate 100M Hz <-- Must greater than SPI clock rate to get signal
-------------------------------------

+-----------------------+
|                             |
|       Problem         |
|                             |
+-----------------------+


1. no matter what PIN in BMD-340 { P0.3(SCK) P0.4(MOSI) P0.28(MISO) P0.29(SS) P0.30(DCX) } cannot trigger logic analyzer

2. I connect probe of analyzer with PIN VCC (5V0) and logic analyzer was triggered with signal 1.

3.  (2) means logic analysis can work and detect signal on port, only SPI definition port has no signal.

+-----------------------+
|                             |
|     NEED HELP    |
|                             |
+-----------------------+

(*) Can anyone explain does any of above steps wrong?
(*) It just a demo SPI transport function, I have tryed other SPI examples like {spi, spi_master_using_nrf_spi_mmgr, spis} in [/peripheral/] but none of them works.
(*) My project is to use [BMD-340] f_open() file, pass value to [FPGA] with SPI and their pin connected together.

+------------------------------------+                             +-----------------------+
|                                             |                              | PC                       |
|            BMD - 340               +==============+ SEGGER            |
|                                             |                              | Embedded Stdio |
+-+------+--------+----------+----+                             +-----------------------+
    |          |             |            |
    |SCK  | MOSI   | MISO  |SS
    |          |             |            | 
+-+--------+---------+---------+--+
|                                             |
|                 FPGA                  |
|                                             |
+------------------------------------+

--------------------------------------------------------

Please info me if there is anything not clear, I am eager to find the solution.

  • Hi

    A common problem with the modules is that they don't include the optional LF crystal that our SDK examples run by default. Please try adding the following defines to your sdk_config.h file:

    // </e>
    
    // <e> NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
    //==========================================================
    #ifndef NRF_CLOCK_ENABLED
    #define NRF_CLOCK_ENABLED 1
    #endif
    // <o> CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef CLOCK_CONFIG_LF_SRC
    #define CLOCK_CONFIG_LF_SRC 0
    #endif
    
    // <q> CLOCK_CONFIG_LF_CAL_ENABLED  - Calibration enable for LF Clock Source
     
    
    #ifndef CLOCK_CONFIG_LF_CAL_ENABLED
    #define CLOCK_CONFIG_LF_CAL_ENABLED 1
    #endif
    
    // <o> CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef CLOCK_CONFIG_IRQ_PRIORITY
    #define CLOCK_CONFIG_IRQ_PRIORITY 6
    #endif
    
    //==========================================================
    // <e> NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver
    //==========================================================
    #ifndef NRFX_CLOCK_ENABLED
    #define NRFX_CLOCK_ENABLED 1
    #endif
    // <o> NRFX_CLOCK_CONFIG_LF_SRC  - LF Clock Source
     
    // <0=> RC 
    // <1=> XTAL 
    // <2=> Synth 
    // <131073=> External Low Swing 
    // <196609=> External Full Swing 
    
    #ifndef NRFX_CLOCK_CONFIG_LF_SRC
    #define NRFX_CLOCK_CONFIG_LF_SRC 0
    #endif
    
    // <o> NRFX_CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY
    #define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6
    #endif

    Best regards,

    SImon

  • Hi, thank you for answering the problem.

    And I added the code you supply, the logic analyzer still detect no signal for SCK , MOSI ...

    -----------------------------------------------------

    This is my [main.c], I added print "Failed!" when stuck in the while loop.

    The debug mode actually keep printing "Failed" Disappointed 

    Here is another problem.

    /**
     * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    #include "nrfx_spim.h"
    #include "app_util_platform.h"
    #include "nrf_gpio.h"
    #include "nrf_delay.h"
    #include "boards.h"
    #include "app_error.h"
    #include <string.h>
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    
    #define NRFX_SPIM_SCK_PIN  3
    #define NRFX_SPIM_MOSI_PIN 4
    #define NRFX_SPIM_MISO_PIN 28
    #define NRFX_SPIM_SS_PIN   29
    #define NRFX_SPIM_DCX_PIN  30
    
    #define SPI_INSTANCE  3                                           /**< SPI instance index. */
    static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);  /**< SPI instance. */
    
    static volatile bool spi_xfer_done;  /**< Flag used to indicate that SPI instance completed the transfer. */
    
    #define TEST_STRING "Nordic123456789012345678901234567890"
    static uint8_t       m_tx_buf[] = TEST_STRING;           /**< TX buffer. */
    static uint8_t       m_rx_buf[sizeof(TEST_STRING) + 1];  /**< RX buffer. */
    static const uint8_t m_length = sizeof(m_tx_buf);        /**< Transfer length. */
    
    void spim_event_handler(nrfx_spim_evt_t const * p_event,
                           void *                  p_context)
    {
        spi_xfer_done = true;
        NRF_LOG_INFO("Transfer completed.");
        if (m_rx_buf[0] != 0)
        {
            NRF_LOG_INFO(" Received:");
            NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
        }
    }
    
    int main(void)
    {
        bsp_board_init(BSP_INIT_LEDS);
    
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(m_tx_buf, m_length, m_rx_buf, m_length);
    
        nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
        spi_config.frequency      = NRF_SPIM_FREQ_1M;
        spi_config.ss_pin         = NRFX_SPIM_SS_PIN;
        spi_config.miso_pin       = NRFX_SPIM_MISO_PIN;
        spi_config.mosi_pin       = NRFX_SPIM_MOSI_PIN;
        spi_config.sck_pin        = NRFX_SPIM_SCK_PIN;
        spi_config.dcx_pin        = NRFX_SPIM_DCX_PIN;
        spi_config.use_hw_ss      = true;
        spi_config.ss_active_high = false;
        APP_ERROR_CHECK(nrfx_spim_init(&spi, &spi_config, spim_event_handler, NULL));
    
        NRF_LOG_INFO("NRFX SPIM example started.");
    
        while (1)
        {
            // Reset rx buffer and transfer done flag
            memset(m_rx_buf, 0, m_length);
            spi_xfer_done = 0;//false;
    
            APP_ERROR_CHECK(nrfx_spim_xfer_dcx(&spi, &xfer_desc, 0, 15));
    
            while (!spi_xfer_done)
            {
    printf("Failed!\n");
                __WFE();
            }
    
            NRF_LOG_FLUSH();
    
    //        bsp_board_led_invert(BSP_BOARD_LED_0);
            nrf_delay_ms(200);
        }
    }
    

    Thank you for sharing that idea, I hope that we can keep moving with this problem.

    Best regards,

    Nihsrob

  • Hi

    Sorry, I didn't realize that you were using the Rigado EV kit initially. This kit does have the 32kHz crystal oscillator, so the defines I posted should not be necessary.

    Have you read through and completed the steps required to set up the evaluation board in the BMD-340 EV kit User Guide? I can't see anything wrong with your procedure, and the SPI should work using these pins, but seeing as you're using a BMD-340 kit we can't guarantee that our examples will run on it, as it is not our design. We don't have one available either I'm afraid, so I can't test it here on my end. What I can say, is that the nrfx_spim_pca10056 is working as intended on the nRF52840 DK.

    Best regards,

    Simon

  • Hi,

    It's okay, I really thank you for giving me so many responses.

    And Yes, I did read the complete BMD-340 User Guide as you mention above.

    Maybe  I can  describe my problem again so that every reader can get my issue more clearly.

    --------------------------------------------------------------------------------------------------------

    The full-screen is I want to use BMD-340 operate function f_open("File_Name.txt") to an SD card. Then pass the f_open address such as 32'h00_00_00_01 to FPGA port in SPI_mode.

    Base on the project description, It can be divided into 2 parts.

    FIRST,  BMD-340 use Nordic/examples/peripheral/fatfs to execute f_open and get the address. (O) <== SUCCEED !!!

    [ It means BMD-340 can work on nordic peripheral,  BMD-340 I/O PIN can work on SD card  ]

    SECOND, BMD-340 then pass value as "SPI MASTER" to other devices such as FPGA or something. (X) <== ISSUE

    --------------------------------------------------------------------------------------------------------

    So, All I want to do is to check WHETHER BMD-340 can work as SPI MASTER , passing value or any signal to its PIN.

    IF it does ( MOSI_PIN or SCK_PIN detect any signal) , the Logic Analyzer should detect signal.

    --------------------------------------------------------------------------------------------------------

    I have tried Nordic/example/peripheral/ like spi  , nrfx_spim  ,  spi_master_using_nrf_spi_mngr 

    In there 3 examples, all the CODE is in default. Which means I totally modify nothing for any part of code.

    I JUST used Logic Analyzer detect if there exists any signal on BMD-340 I/O PIN.

    Results like what I have said above, I detect nothing. Disappointed

    --------------------------------------------------------------------------------------------------------

    I  am  confusing  about  how  other  project   make  it  work  ?   Can anyone   provide  any source  which  can  run  in  BMD-340.

    My  BMD-340  detect  no  signal  but  5V  output  PIN  and   GND  PIN.

    ============================================================

    Now, I still struggling with this issue, and trying to figure out what

    nrfx_spim_xfer_dcx( ) & nrfx_drv_spi_transfer( )

    function work.

    ============================================================

    Thank you for discussing this problem with me, I hope that we can keep moving on.

    Best regards,

    Nihsrob

  • Hi

    Again, thank you for being so detailed in your replies! It's not too often we get posts that are this thorough. One thing. When you flash the examples to your EV kit, do you see a "download successful" message like the one below in SES afterwards, to confirm that the firmware has been flashed onto the kit?

    If not, please try to press the Build and Run option in the Build dropdown folder, and see if that flashes the board for you.

    Best regards,

    Simon

Related