This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

HFCLK timer issue

Hi Nordic Engineers,

I have few queries over HFCLK 16 MHz timer.

I am using nrf52840 custom board. IDE - segger embedded studio

#define TIME_IN_US  2600


/**
 * @brief Handler for timer events.
 */
void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
      switch (event_type)
      {
          case NRF_TIMER_EVENT_COMPARE3:
              timerenabled = 1;
              if(!cal_HR_ir_enabled)
              {
                  DisableHRMLed();       //Disabling RED and Enabling IR
                  EnableHRMLed(HR_IR_LED);
                   //printf("Timer IR\r\n");
              }
              else if(!cal_HR_red_enabled)
              {
                  DisableHRMLed();       //Disabling IR and Enabling RED
                  EnableHRMLed(HR_RED_LED);
                   //printf("Timer RED\r\n");
              }
              break;

          default:
              //Do nothing.
              break;
      }
}

void enable_HR_LED_timer(void)
{ 
      uint32_t time_ticks;
      uint32_t err_code = NRF_SUCCESS;

      //Configure TIMER_LED for generating simple light effect - leds on board will invert his state one after the other.
      nrf_drv_timer_config_t led_timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
      err_code = nrf_drv_timer_init(&TIMER_LED, &led_timer_cfg, timer_led_event_handler);
      APP_ERROR_CHECK(err_code);

      //Time(in microseconds) between consecutive compare events.
      time_ticks = nrf_drv_timer_us_to_ticks(&TIMER_LED, TIME_IN_US);

      nrf_drv_timer_extended_compare(
           &TIMER_LED, NRF_TIMER_CC_CHANNEL3, time_ticks, NRF_TIMER_SHORT_COMPARE3_CLEAR_MASK, true);

      nrf_drv_timer_enable(&TIMER_LED);
}

I have enabled HFCLK timer and able to reach timer callback.

The problem is...If I set the Timeout as 2600 us, it seemed only timer callback was running (not even while(1) ) 

But in 2700 us or greater, each and every functionalities were working fine.

I have to generate ~250us time delay. 

I have attached my code snippet and I am using Timer 3

Looking forward for your suggestion.

Regards

Sudharsan

Parents Reply Children
No Data
Related