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

how to use hardware spi and i2c on S130 softdevice(nRF51822)??

Hello,

I am developing a new product using S130 on nRF51822(QFAC). My product use LCD as spi interface and ADXL345 sensor as i2c interface, also test it, works well without softdevice, but when I upload S130 softdevice it goes to h/w fault.

I searched similar problem in this forum, but I cannot find clear solution. Is it possible use hardware spi and i2c on s130 softdevice concurrently?? Please let me know how to handle this problem.

ble_app_uart_on_SDK_v10_0_0.zip

Thanks,

Parents
  • I am not using any interrupt, just polling style is used. Okay my codes are below.

    twi init code:

    void twi_init (void)
    {
        ret_code_t err_code;
            const nrf_drv_twi_config_t twi_adxl_345_config = {
           .scl                = POLARIS_SENSOR_SCL,//ARDUINO_SCL_PIN,
           .sda                = POLARIS_SENSOR_SDA,//ARDUINO_SDA_PIN,
           .frequency          = NRF_TWI_FREQ_100K,
           .interrupt_priority = APP_IRQ_PRIORITY_HIGH  // interrupt priority
      };
        err_code = nrf_drv_twi_init(&m_twi_adxl_345, &twi_adxl_345_config, NULL, NULL);
        APP_ERROR_CHECK(err_code);
        nrf_drv_twi_enable(&m_twi_adxl_345);
    }
    

    spi code:

    static void spi_master_init(nrf_drv_spi_t const * p_instance, bool lsb)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        nrf_drv_spi_config_t config =
        {
            .ss_pin       = LCD_CS,//NRF_DRV_SPI_PIN_NOT_USED,
            .irq_priority = APP_IRQ_PRIORITY_LOW,
            .orc          = 0xCC,
            .frequency    = NRF_DRV_SPI_FREQ_125K,
            .mode         = NRF_DRV_SPI_MODE_3,//NRF_DRV_SPI_MODE_0,
            .bit_order    = (lsb ?
                NRF_DRV_SPI_BIT_ORDER_LSB_FIRST : NRF_DRV_SPI_BIT_ORDER_MSB_FIRST),
        };
    
            config.sck_pin  = LCD_SCK_PIN;//SPIM1_SCK_PIN;
            config.mosi_pin = LCD_MOSI_PIN;//SPIM1_MOSI_PIN;
            config.miso_pin = NRF_DRV_SPI_PIN_NOT_USED;//LCD_MISO_PIN;//SPIM1_MISO_PIN;
            err_code = nrf_drv_spi_init(p_instance, &config,
                NULL);//spi_master_1_event_handler);  
        APP_ERROR_CHECK(err_code);
    }
    

    the above codes are just init codes.

    in spi case, i used it for LCD display, just send data so no need to get data. in twi case, for sensor IC, just read data.

    Thank you for your comment.

Reply
  • I am not using any interrupt, just polling style is used. Okay my codes are below.

    twi init code:

    void twi_init (void)
    {
        ret_code_t err_code;
            const nrf_drv_twi_config_t twi_adxl_345_config = {
           .scl                = POLARIS_SENSOR_SCL,//ARDUINO_SCL_PIN,
           .sda                = POLARIS_SENSOR_SDA,//ARDUINO_SDA_PIN,
           .frequency          = NRF_TWI_FREQ_100K,
           .interrupt_priority = APP_IRQ_PRIORITY_HIGH  // interrupt priority
      };
        err_code = nrf_drv_twi_init(&m_twi_adxl_345, &twi_adxl_345_config, NULL, NULL);
        APP_ERROR_CHECK(err_code);
        nrf_drv_twi_enable(&m_twi_adxl_345);
    }
    

    spi code:

    static void spi_master_init(nrf_drv_spi_t const * p_instance, bool lsb)
    {
        uint32_t err_code = NRF_SUCCESS;
    
        nrf_drv_spi_config_t config =
        {
            .ss_pin       = LCD_CS,//NRF_DRV_SPI_PIN_NOT_USED,
            .irq_priority = APP_IRQ_PRIORITY_LOW,
            .orc          = 0xCC,
            .frequency    = NRF_DRV_SPI_FREQ_125K,
            .mode         = NRF_DRV_SPI_MODE_3,//NRF_DRV_SPI_MODE_0,
            .bit_order    = (lsb ?
                NRF_DRV_SPI_BIT_ORDER_LSB_FIRST : NRF_DRV_SPI_BIT_ORDER_MSB_FIRST),
        };
    
            config.sck_pin  = LCD_SCK_PIN;//SPIM1_SCK_PIN;
            config.mosi_pin = LCD_MOSI_PIN;//SPIM1_MOSI_PIN;
            config.miso_pin = NRF_DRV_SPI_PIN_NOT_USED;//LCD_MISO_PIN;//SPIM1_MISO_PIN;
            err_code = nrf_drv_spi_init(p_instance, &config,
                NULL);//spi_master_1_event_handler);  
        APP_ERROR_CHECK(err_code);
    }
    

    the above codes are just init codes.

    in spi case, i used it for LCD display, just send data so no need to get data. in twi case, for sensor IC, just read data.

    Thank you for your comment.

Children
No Data
Related