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

Programming nRF52840 on custom board

I am currently downloading softdevice (S140) on our custom board using P19 connector on nRF52840 DK. Our custom board also has nRF52840. It seems the dsoftdevice is downloaded correctly on the custom board. I hav verified by erasing the DK and then program the custom board and then reading the DK again to see if it still stayed erased. I am using nRFGo studio.

After I downloaded the softdevice, when I load and run my application, it does not return from ble_stack_init. After enabling some breakpoints, I traced it all the way to the line in the function softdevice_handler_init

err_code = sd_softdevice_enable(p_clock_lf_cfg, softdevice_fault_handler);

It does not return from the function sd_softdevice_enable.

Sometimes, the program breaks into app_error_handler_bare. When I look at the call stack an uart interrupt was triggered before it returned from the ble_stack_init function.

My main function looks like this:

int main(void)
{
    uint32_t ticks;

    // Enable the constant latency sub power mode to minimize the time it takes
    // for the SPIS peripheral to become active after the CSN line is asserted
    // (when the CPU is in sleep mode).
    NRF_POWER->TASKS_CONSTLAT = 1;

    bsp_board_leds_init();
    nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0,8)); //nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0,30));
    nrf_gpio_cfg_output(NRF_GPIO_PIN_MAP(0,31)); // test point

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_INFO("SPIS example\r\n");

    nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;

    spis_config.csn_pin               = 6;//29;//APP_SPIS_CS_PIN;
    spis_config.miso_pin              = 20; //28;//APP_SPIS_MISO_PIN;
    spis_config.mosi_pin              = 22;//4;//APP_SPIS_MOSI_PIN;   15
    spis_config.sck_pin               = 24;//3;//APP_SPIS_SCK_PIN;

    APP_ERROR_CHECK(nrf_drv_spis_init(&spis, &spis_config, spis_event_handler));


    leds_init();
    timer_init();
    counter_init();
    buttons_init();

    uart_init();

    ble_stack_init();

    gap_params_init();
    conn_params_init();
    gatt_init();
    advertising_data_set();

    server_init();
    client_init();

    gatt_mtu_set(m_test_params.att_mtu);
    data_len_ext_set(m_test_params.data_len_ext_enabled);
    conn_evt_len_ext_set(m_test_params.conn_evt_len_ext_enabled);
    preferred_phy_set(m_test_params.rxtx_phy);
    tx_power_set();

    advertising_start();

    for (;;)
    {

This same piece of code works perfectly on the nRF52840 DK. We have 32KHz crystal connected on our custom board. I have also tried using internal RC clock configuration. But this did not help too.

Any thoughts on this issue?

Related