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

One of the APP_TIMER seems to be not working properly.

Hello

I'm working on SDK v17, and I'm using the nRF52832 custom board.
I use several APP_TIMERs. One of those timers doesn't seem to be working properly. Timer calls are being made, but the LED is not output.

This timer will be toggled repeatedly during Bluetooth advertising. When Bluetooth is paired, the timer must be shut down and the LED should be on.

Firmware test completed successfully with nRF52DK.  And through the example of Blinky, I have confirmed that the LED is working.

Debugging also does not print errors.

void gpio_init(void)
{
  nrf_gpio_cfg_output(BAT_LED_1); 
  nrf_gpio_pin_clear(BAT_LED_1);

  nrf_gpio_cfg_output(BAT_LED_2); 
  nrf_gpio_pin_clear(BAT_LED_2);

  nrf_gpio_cfg_output(BAT_LED_3); 
  nrf_gpio_pin_clear(BAT_LED_3);

  nrf_gpio_cfg_output(BAT_LED_4); 
  nrf_gpio_pin_clear(BAT_LED_4);

  nrf_gpio_cfg_output(BAT_LED_5); 
  nrf_gpio_pin_clear(BAT_LED_5);

  nrf_gpio_cfg_input(APP_BTN_1,NRF_GPIO_PIN_PULLUP);
  nrf_gpio_cfg_input(bat_state, NRF_GPIO_PIN_PULLDOWN); //battery charge state`
  nrf_gpio_cfg_output(POWER_OFF); //POWER_HOLD pin
}

static void PairLED_timer_handler(void * p_context)
{
  nrf_gpio_pin_toggle(Pairing_LED); //toggle led
  //printf("Pairing LED....\n");
}


static void timers_init(void)
{
    ret_code_t err_code;

    // Initialize timer module.
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
/*
    // Create Battery timers.
    err_code = app_timer_create(&m_battery_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                battery_level_meas_timeout_handler);
    APP_ERROR_CHECK(err_code);
*/

    // Create Left LED timers.
    err_code = app_timer_create(&m_LeftLED_timer_id,
                                APP_TIMER_MODE_REPEATED, //SINGLE_SHOT or REPEATED //single shot timer
                                LeftLED_timer_handler);   
    APP_ERROR_CHECK(err_code); 


    // Create Right LED timers.
    err_code = app_timer_create(&m_RightLED_timer_id,
                                APP_TIMER_MODE_REPEATED, 
                                RightLED_timer_handler);   
    APP_ERROR_CHECK(err_code); 

    //Create Center LED timers
    err_code = app_timer_create(&m_CenterLED_timerid,
                                APP_TIMER_MODE_REPEATED,
                                CenterLED_timer_handler);
    APP_ERROR_CHECK(err_code);


   //Create Pairing LED timers/
    err_code = app_timer_create(&m_PairLED_timerid,
                                APP_TIMER_MODE_REPEATED,
                                PairLED_timer_handler);
    APP_ERROR_CHECK(err_code);

   //Create Crush LED timers/
    err_code = app_timer_create(&m_CrushLED_timerid,
                                APP_TIMER_MODE_REPEATED,
                                CrushLED_timer_handler);
    APP_ERROR_CHECK(err_code);


   //Create Press Time timers/
    err_code = app_timer_create(&m_LongPress_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                LongPress_timer_handler);
    APP_ERROR_CHECK(err_code);
}


static void PairLED_timers_start()
{
  ret_code_t err_code;

  err_code = app_timer_start(m_PairLED_timerid, APP_TIMER_TICKS(1000), NULL); //Toggle 1sec
  APP_ERROR_CHECK(err_code);
  printf("Scanning Start\n");
}


static void PairLED_timers_stop() //Stop Timer
{
    ret_code_t err_code;

    printf("Pairing Timer Stop!\n");
    err_code = app_timer_stop(m_PairLED_timerid); 
    APP_ERROR_CHECK(err_code);
}


static void on_adv_evt(ble_adv_evt_t ble_adv_evt) //Edit
{
    uint32_t err_code;

    switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:
            //err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
            //APP_ERROR_CHECK(err_code);
            PairLED_timers_start();
            break;// BLE_ADV_EVT_FAST

        case BLE_ADV_EVT_IDLE:
            sleep_mode_enter(); 
            break; // BLE_ADV_EVT_IDLE

        default:
            break;
    }
}


static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) 
{
    uint32_t err_code;
    pm_handler_secure_on_connection(p_ble_evt);

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_DISCONNECTED: //when disconnected
        {
            bool erase_bonds = false;

            NRF_LOG_INFO("Disconnected");
            printf("Disconnected\n");
            pairing_state = false;
            All_Stop();
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            // Check if the last connected peer had not used MITM, if so, delete its bond information.
            if (m_peer_to_be_deleted != PM_PEER_ID_INVALID)
            {
                err_code = pm_peer_delete(m_peer_to_be_deleted);
                APP_ERROR_CHECK(err_code);
                NRF_LOG_DEBUG("Collector's bond deleted");
                m_peer_to_be_deleted = PM_PEER_ID_INVALID;
            }

            //advertising_start(erase_bonds); //auto pairing test
        } break;
    }
}

//PCA10040.h

#define Pairing_LED  19

It's my first time use with a custom board, so it's hard to find a problem.  Is this a possible hardware issue?

Thank you.

Parents Reply Children
No Data
Related