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

Problems porting application from NRF52DK board to custom board

I am trying to port an application that works on the NRF52 DK board to a custom board containing a 52832 QFAA chipset. The MCU is connected via SPI to an IMU BMI160 and a SD card slot. In debug mode, the program downloaded successfully to the custom board through the SWD interface. However, stepping through the code, it hangs on the following line.

int8_t ret = nrf_drv_spi_transfer(&spi_BMI160, m_buf, 1, read_temp, payload_size+1);

I have not defined a custom_board header as I am not changing the pin configuration. I defined custom GPIO pins as the SPI interface, as follows.

#define IS_CS_PIN 23
#define IS_MISO_PIN 24
#define IS_MOSI_PIN 17
#define IS_SCK_PIN 13

May I know what I might have missed during the porting process, generating such an error?

Parents Reply Children
  • Hi Simon,

    Thanks for getting back so quickly. No error is returned - it simply freezes and block the whole application.

    No, it isn't one of the examples. It is a custom application we wrote in order to test the IMU and the SD card slot. 

    I just tried loading the example 'spi_pca10040', and I got the log messages '"Transfer completed."', and no exceptions are returned.

    Best,

    Ed 

  • int8_t bmi160_init(struct bmi160_dev *dev)
    {
        int8_t rslt;
        uint8_t data;
        uint8_t try = 3;
    
        /* Null-pointer check */
        rslt = null_ptr_check(dev);
    
        /* Dummy read of 0x7F register to enable SPI Interface
         * if SPI is used */
        if ((rslt == BMI160_OK) && (dev->interface == BMI160_SPI_INTF))
        {
            rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev);
        }
        if (rslt == BMI160_OK)
        {
            /* Assign chip id as zero */
            dev->chip_id = 0;
            while ((try--) && (dev->chip_id != BMI160_CHIP_ID))
            {
                /* Read chip_id */
                rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &dev->chip_id, 1, dev);
            }
            if ((rslt == BMI160_OK) && (dev->chip_id == BMI160_CHIP_ID))
            {
                dev->any_sig_sel = BMI160_BOTH_ANY_SIG_MOTION_DISABLED;
    
                /* Soft reset */
                rslt = bmi160_soft_reset(dev);
            }
            else
            {
                rslt = BMI160_E_DEV_NOT_FOUND;
            }
        }
    
        return rslt;
    }
    
    int8_t bmi160_get_regs(uint8_t reg_addr, uint8_t *data, uint16_t len, const struct bmi160_dev *dev)
    {
        int8_t rslt = BMI160_OK;
    
        /* Null-pointer check */
        if ((dev == NULL) || (dev->read == NULL))
        {
            rslt = BMI160_E_NULL_PTR;
        }
        else
        {
            /* Configuring reg_addr for SPI Interface */
            if (dev->interface == BMI160_SPI_INTF)
            {
                reg_addr = (reg_addr | BMI160_SPI_RD_MASK);
            }
            
            rslt = dev->read(dev->id, reg_addr, data, len);
            
            if (rslt != BMI160_OK)
            {
                rslt = BMI160_E_COM_FAIL;
            }
        }
    
        return rslt;
    }
    
    int8_t nrf_acc_read_register(uint8_t dev_id, uint8_t reg_addr, uint8_t* payload, uint16_t payload_size) {
      uint8_t m_buf[payload_size+1];
      m_buf[0] = reg_addr;
      uint8_t read_temp[ payload_size + 1 ] ;
      
      read_reg = true;
      spi_xfer_done = false;
      
      //int8_t ret = nrf_drv_spi_transfer(&spi_BMI160, m_buf, 1, m_rx_buf, payload_size+1);
      int8_t ret = nrf_drv_spi_transfer(&spi_BMI160, m_buf, 1, read_temp, payload_size+1);
      APP_ERROR_CHECK(ret);
      nrf_delay_ms(5);
      
      for( int i = 1 ; i < payload_size+1 ; i ++ )
        payload[i-1] = read_temp[i] ;
      
      return ret;	
    }

    The application is failing during the initialisation phase, at the following lines (down the call stack).

    l23: rslt = bmi160_get_regs(BMI160_CHIP_ID_ADDR, &dev->chip_id, 1, dev);

    l58: rslt = dev->read(dev->id, reg_addr, data, len);

    l78: int8_t ret = nrf_drv_spi_transfer(&spi_BMI160, m_buf, 1, read_temp, payload_size+1);
     

    Any help appreciated, thanks.

    Ed 

Related