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

After power turn off and on. Chip is not working

Hi 

I made a custom board. (using nrRF52832) 

At frist, I tested my code on 52DK(PCCA10040). It is worked.

And then I tested my code on custom board.
I changed my code in <sdk_config.h>.
Because my custom board haven`t optional 32kHz crystal.

// <h> Clock - SoftDevice clock configuration
// <o> NRF_SDH_CLOCK_LF_SRC - SoftDevice clock source.


#define NRF_SDH_CLOCK_LF_SRC 0

#define NRF_SDH_CLOCK_LF_RC_CTIV 16

#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 2

#define NRF_SDH_CLOCK_LF_XTAL_ACCURACY 7

I used my custom board well.
(mpu6050 sensor(accel,gyro) + BLE)

But, Now my board is not working.

When <Build and Run> click in SES, it is works.
Sending for sensor value to BLE.

After <Build and Run>, I disconnected the j-link. and I connected power supply to 3V.
But It not works. Why?

(When connected to a power supply, the current shows that 0.008A is being applied. But Bluetooth is not advertised.

I found that there were a lot of problems with custom board such as Uart or Log. Therefore, they were all disabled.)

Let me know what part of what I'm missing.

Thank you for reading.

ps.  I used download to 52Dk board. 

*Additional information*

I have a another computer(laptop).
and I have saved code in the laptop before problem.

So, I try the download for my custom board. but, problem is the same.

When I Debug or <Build and run>, It is sending the value to BLE.

but, When a custom boards turn off and on, it is not works.(switch on/off)

I think.. maybe sensor has broken?

so, I have 15 custom board. (spare)
I try other.

but, still not working.

Why?

Even....

Custom boards that previously downloaded code work well when powered on.

However, when I put the code back in, it doesn't work the same way.

I don`t know what I wrong ....

please help me. 

Parents
  • Hi

    Okay, so there's definitely your project code that is causing this. Can you upload a snippet of where in your code you do advertising initialization and where you start advertising?

    Best regards,

    Simon

  • int main(void)
    {
    bool erase_bonds;
    
    // Initialize.
    
    timers_init();
    
    ble_stack_init();
    gap_params_init();
    gatt_init();
    advertising_init();
    services_init();
    conn_params_init();
    peer_manager_init();
    mpu_setup();
    
    
    advertising_start(erase_bonds);
    
    sum_values_t sum_values;
    
    // Enter main loop.
    for (;;)
      {
          if (NRF_LOG_PROCESS() == false)
             {
                  power_manage();
                  if(start_accel_update_flag == true)
                      {
    
                          mpu_read_sum(&sum_values);
                          ble_mpu_update(&m_mpu, &sum_values);
    
    
                    start_accel_update_flag = false;
    
                      }
                 }
       }
    }
    
    

    In the middle, there is a part that initializes mpu6050. However, when debugging, it doesn't matter.

Reply
  • int main(void)
    {
    bool erase_bonds;
    
    // Initialize.
    
    timers_init();
    
    ble_stack_init();
    gap_params_init();
    gatt_init();
    advertising_init();
    services_init();
    conn_params_init();
    peer_manager_init();
    mpu_setup();
    
    
    advertising_start(erase_bonds);
    
    sum_values_t sum_values;
    
    // Enter main loop.
    for (;;)
      {
          if (NRF_LOG_PROCESS() == false)
             {
                  power_manage();
                  if(start_accel_update_flag == true)
                      {
    
                          mpu_read_sum(&sum_values);
                          ble_mpu_update(&m_mpu, &sum_values);
    
    
                    start_accel_update_flag = false;
    
                      }
                 }
       }
    }
    
    

    In the middle, there is a part that initializes mpu6050. However, when debugging, it doesn't matter.

Children
  • Seng ju Han said:
    However, when debugging, it doesn't matter.

     What do you mean that it "doesn't matter"? Does the application skip it, or what. Please clarify. Also, if you could post a snippet showing the advertising initialization that would be great!

    Best regards,

    Simon

  • Hi
    First, I'm sorry for using the expression "it doesn`t matter" to exclude the answer to check the connection of the mpu6050 from my custom board.
    The sensor is working. I succeeded in getting data through the line in the sensor of the custom board in Arduino.
    I don`t know how to "Also, if you could post a snippet showing the advertising initialization that would be great!"
    If it is related to "advertising_init" and "advertising_star"
     
    uint32_t ble_advertising_init(ble_advertising_t * const p_advertising,
    ble_advertising_init_t const * const p_init)
       {
    uint32_t ret;
    if ((p_init == NULL) || (p_advertising == NULL))
       {
            return NRF_ERROR_NULL;
       }
    
    p_advertising->initialized = true;
    p_advertising->adv_mode_current = BLE_ADV_MODE_IDLE;
    p_advertising->adv_modes_config = p_init->config;
    p_advertising->conn_cfg_tag = BLE_CONN_CFG_TAG_DEFAULT;
    p_advertising->evt_handler = p_init->evt_handler;
    p_advertising->error_handler = p_init->error_handler;
    p_advertising->current_slave_link_conn_handle = BLE_CONN_HANDLE_INVALID;
    
    memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address));
    memset(&p_advertising->advdata, 0, sizeof(p_advertising->advdata));
    
    // Copy advertising data.
    p_advertising->advdata.name_type = p_init->advdata.name_type;
    p_advertising->advdata.include_appearance = p_init->advdata.include_appearance;
    p_advertising->advdata.flags = p_init->advdata.flags;
    p_advertising->advdata.short_name_len = p_init->advdata.short_name_len;
    
    p_advertising->advdata.uuids_complete = p_init->advdata.uuids_complete;
    p_advertising->advdata.uuids_more_available = p_init->advdata.uuids_more_available;
    p_advertising->advdata.uuids_solicited = p_init->advdata.uuids_solicited;
    p_advertising->advdata.include_ble_device_addr = p_init->advdata.include_ble_device_addr;
    
    if (p_init->advdata.p_manuf_specific_data != NULL)
    {
    p_advertising->advdata.p_manuf_specific_data = &(p_advertising->manuf_specific_data);
    p_advertising->manuf_specific_data.data.p_data = p_advertising->manuf_data_array;
    p_advertising->advdata.p_manuf_specific_data->company_identifier =
    p_init->advdata.p_manuf_specific_data->company_identifier;
    p_advertising->advdata.p_manuf_specific_data->data.size = p_init->advdata.p_manuf_specific_data->data.size;
    
    for (uint32_t i = 0; i < p_advertising->advdata.p_manuf_specific_data->data.size; i++)
    {
    p_advertising->manuf_data_array[i] = p_init->advdata.p_manuf_specific_data->data.p_data[i];
    }
    }
    
    if (p_init->advdata.p_service_data_array != NULL)
    {
    p_advertising->service_data.data.p_data = p_advertising->service_data_array;
    p_advertising->advdata.p_service_data_array = &(p_advertising->service_data);
    p_advertising->advdata.p_service_data_array->data.p_data = p_advertising->service_data_array;
    p_advertising->advdata.p_service_data_array->data.size = p_init->advdata.p_service_data_array->data.size;
    p_advertising->advdata.p_service_data_array->service_uuid = p_init->advdata.p_service_data_array->service_uuid;
    
    for (uint32_t i = 0; i < p_advertising->advdata.p_service_data_array->data.size; i++)
    {
    p_advertising->service_data_array[i] = p_init->advdata.p_service_data_array->data.p_data[i];
    }
    
    p_advertising->advdata.service_data_count = p_init->advdata.service_data_count;
    }
    
    if (p_init->advdata.p_slave_conn_int != NULL)
    {
    p_advertising->advdata.p_slave_conn_int = &(p_advertising->slave_conn_int);
    p_advertising->advdata.p_slave_conn_int->max_conn_interval = p_init->advdata.p_slave_conn_int->max_conn_interval;
    p_advertising->advdata.p_slave_conn_int->min_conn_interval = p_init->advdata.p_slave_conn_int->min_conn_interval;
    }
    
    if (p_init->advdata.p_tx_power_level != NULL)
    {
    p_advertising->advdata.p_tx_power_level = p_init->advdata.p_tx_power_level;
    }
    
    #if (NRF_SD_BLE_API_VERSION <= 2)
    for (int i = 0; i <BLE_GAP_WHITELIST_ADDR_MAX_COUNT ; i++)
    {
    p_advertising->whitelist.pp_addrs[i] = &p_advertising->whitelist_addrs[i];
    }
    
    for (int i = 0; i <BLE_GAP_WHITELIST_IRK_MAX_COUNT ; i++)
    {
    p_advertising->whitelist.pp_irks[i] = &p_advertising->whitelist_irks[i];
    }
    #endif
    ret = ble_advdata_set(&(p_advertising->advdata), &(p_init->srdata));
    return ret;
    }
    
    
    uint32_t ble_advertising_start(ble_advertising_t * const p_advertising,
    ble_adv_mode_t advertising_mode)
    {
    uint32_t ret;
    ble_gap_adv_params_t adv_params;
    
    if (p_advertising->initialized == false)
    {
    return NRF_ERROR_INVALID_STATE;
    }
    
    p_advertising->adv_mode_current = advertising_mode;
    
    // Delay starting advertising until the flash operations are complete.
    if (flash_access_in_progress())
    {
    p_advertising->advertising_start_pending = true;
    return NRF_SUCCESS;
    }
    
    memset(&p_advertising->peer_address, 0, sizeof(p_advertising->peer_address));
    
    if ( ((p_advertising->adv_modes_config.ble_adv_directed_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED))
    ||((p_advertising->adv_modes_config.ble_adv_directed_slow_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED))
    ||((p_advertising->adv_modes_config.ble_adv_directed_slow_enabled) && (p_advertising->adv_mode_current == BLE_ADV_MODE_DIRECTED_SLOW))
    )
    {
    if (p_advertising->evt_handler != NULL)
    {
    p_advertising->peer_addr_reply_expected = true;
    p_advertising->evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST);
    }
    else
    {
    p_advertising->peer_addr_reply_expected = false;
    }
    }
    
    p_advertising->adv_mode_current = adv_mode_next_avail_get(p_advertising, advertising_mode);
    
    // Fetch the whitelist.
    if ((p_advertising->evt_handler != NULL) &&
    (p_advertising->adv_mode_current == BLE_ADV_MODE_FAST || p_advertising->adv_mode_current == BLE_ADV_MODE_SLOW) &&
    (p_advertising->adv_modes_config.ble_adv_whitelist_enabled) &&
    (!p_advertising->whitelist_temporarily_disabled))
    {
    #if (NRF_SD_BLE_API_VERSION >= 3)
    p_advertising->whitelist_in_use = false;
    #endif
    p_advertising->whitelist_reply_expected = true;
    p_advertising->evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST);
    }
    else
    {
    p_advertising->whitelist_reply_expected = false;
    }
    
    // Initialize advertising parameters with default values.
    memset(&adv_params, 0, sizeof(adv_params));
    
    adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
    adv_params.fp = BLE_GAP_ADV_FP_ANY;
    
    // Set advertising parameters and events according to selected advertising mode.
    switch (p_advertising->adv_mode_current)
    {
    case BLE_ADV_MODE_DIRECTED:
    ret = set_adv_mode_directed(p_advertising, &adv_params);
    break;
    
    case BLE_ADV_MODE_DIRECTED_SLOW:
    ret = set_adv_mode_directed_slow(p_advertising, &adv_params);
    break;
    
    case BLE_ADV_MODE_FAST:
    ret = set_adv_mode_fast(p_advertising, &adv_params);
    break;
    
    case BLE_ADV_MODE_SLOW:
    ret = set_adv_mode_slow(p_advertising, &adv_params);
    break;
    
    case BLE_ADV_MODE_IDLE:
    p_advertising->adv_evt = BLE_ADV_EVT_IDLE;
    break;
    
    default:
    break;
    }
    
    if (p_advertising->adv_mode_current != BLE_ADV_MODE_IDLE)
    {
    ret = sd_ble_gap_adv_start(&adv_params, p_advertising->conn_cfg_tag);
    if (ret != NRF_SUCCESS)
    {
    return ret;
    }
    }
    
    if (p_advertising->evt_handler != NULL)
    {
    p_advertising->evt_handler(p_advertising->adv_evt);
    }
    
    return NRF_SUCCESS;
    } 
    
    OR? 
    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
        init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
        init.advdata.include_appearance      = true;
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
        
        
        
        
    static void advertising_start(bool erase_bonds)
    {
        if (erase_bonds == true)
        {
            delete_bonds();
            // Advertising is started by PM_EVT_PEERS_DELETED_SUCEEDED evetnt
        }
        else
        {
            ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
    
            APP_ERROR_CHECK(err_code);
        }
    }
    }
    I`m right? 
    I hope that's the answer you want.
    Today as well, Thank you for reply.
    Best regards, 
    Han 
Related