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

If delay is inserted after data transmission by SPI, it transits to default_handler

Hi!

I am planning to port SPI sending and receiving functions to the sample code of ble_app_uart of SDK 14.0.0.

The transplant was finish, but when I am debugging,if I add a delay after sending data with SPI while debugging, it will transition to Default_handler.

The code running SPI and UART worked fine without problems.

Is it impossible to put a delay in ble's sample code?

best regards!!

void SPITxCommand(unsigned char Data)
{
nrf_gpio_pin_clear(22); //CS pin low
nrf_drv_spi_transfer(&spi, &Data, 1, NULL, NULL);
//nrf_delay_us(50);
nrf_delay_us(100); //error component
}

 

  • thank you for your reply!

    Since I want to set the register of the sensor on the slave side, I have to send a command for register setting.

    For that reason, I describe the processing in the main sentence.

    Since this process is written at the beginning of the main sentence, I think that there is no influence on the soft device.

    If soft-device is to be affected, how should it be avoided?

     best regards!

    int main(void)
    {
        uint32_t err_code;
        bool     erase_bonds;
    
        // Initialize.
        err_code = app_timer_init();
        APP_ERROR_CHECK(err_code);
    
        uart_init();
    		spi_init();
    		InitADS119x();
    		nrf_delay_us(200);			//4tclock
    		SPITxCommand(0x11);
    		nrf_delay_us(200);  //error component
    		ADS1x9x_Reg_Init();		//ads register initialization
    		ADS119x_Enable_start();
    		SPITxCommand(0x1a);  //Channel Offset Calibration
    		SPITxCommand(0x10);  //0x10 = RDATAC(Read Data Command)(Enable Read Data Continuous mode)
    		nrf_delay_us(8);
        log_init();
    
        buttons_leds_init(&erase_bonds);
        ble_stack_init();
        gap_params_init();
        gatt_init();
        services_init();
        advertising_init();
        conn_params_init();
    		
        printf("\r\nUART Start!");
        NRF_LOG_INFO("UART Start!");
        err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    
        // Enter main loop.
        for (;;)
        {
    			if(0 == nrf_gpio_pin_read(30)){
    				SPITxDummy(0x00); //Dummy_Data LOFFSTAT
    				SPITxDummy1(0x00); //Dummy_Data CH1
    				SPITxDummy(0x00); //Dummy_Data CH1
    			}
            power_manage();
        }
    }

  • In general there should not be any issue with using delays in the application. Do you get any warnings when compiling? Is the issue only present when debugging the application, or always when the delay function is used?

  • thank you for your reply!

    This problem is caused by delay after  spi data transmission.

    Compilation warning is not displayed, it occurs only by debugging.

    thank you in advanced!!

    #edit

    This error does not occur only by using delay, it occurs only by delay after data transmission by SPI

  • Can you post higher resolution screenshot? Are you using BLE in your application?

Related