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

using ANT with RTC timers - softdevice conflicting with LFClk

We are trying to get the ANT feature to run based on RTC as follows:

a. Timer RTC0 or 1 (1 for this example - tick is disabled, compare is on.) b. Timer initialized (all works very well). c. Start timer - go for 10-second IRQ in compart cc[0] - works great.

The Clock startup works ok and IRQ for RTC1 enables ok (taken from the example codes)..

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_LFCLKSRC_Xtal << CLOCK_LFCLKSRC_LFCLKSRC_Pos); NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; NRF_CLOCK->TASKS_LFCLKSTART = 1; while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {}

NRF_POWER->PERPOWER |= (POWER_PERPOWER_RTC1_Power << POWER_PERPOWER_RTC1_Pos);

while ((NRF_POWER->PERRDY & POWER_PERRDY_RTC1_Msk)!= (POWER_PERRDY_RTC1_Ready << POWER_PERRDY_RTC1_Pos)) { }

NVIC_EnableIRQ(RTC1_IRQn); NRF_RTC1->PRESCALER = COUNTER_PRESCALER;
NRF_RTC1->CC[0] = COMPARE_COUNTERTIME * RTC_FREQUENCY;

The problems lies where we try to initialize the ANT - particularly on the softdevice.. We consistently get a hard fault when the softdevice enable is attempted.

return_value = nrf_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback);

if (return_value != NRF_SUCCESS) yellow_error();

return_value = nrf_nvic_SetPriority(PROTOCOL_EVENT_IRQn, NRF_APP_PRIORITY_LOW); if (return_value != NRF_SUCCESS) yellow_error();

return_value = nrf_nvic_EnableIRQ(PROTOCOL_EVENT_IRQn); if (return_value != NRF_SUCCESS) purple_error();

return_value != ant_channel_assign(CHANNEL_0,
CHANNEL_TYPE_SHARED_MASTER, ANT_CHANNEL_DEFAULT_NETWORK, EXT_PARAM_FAST_START_MODE); if (return_value != NRF_SUCCESS) purple_error(); return_value != ant_channel_id_set(CHANNEL_0, CHANNEL_0_CHAN_ID_DEV_NUM, CHANNEL_0_CHAN_ID_DEV_TYPE, CHANNEL_0_CHAN_ID_TRANS_TYPE); if (return_value != NRF_SUCCESS) purple_error();

return_value = ant_channel_open(CHANNEL_0);

WE NOTE THE FOLLOWING IN THE .SDM.H FILE. REGARDING nrf_softdevice_enable ROUTINE - SPECIFICALLY, THE NOTE REGARDING THE LfClk "already running."

@brief Enables the softdevice and by extension the protocol stack. *

  • Idempotent function to enable the softdevice.
  • @note Some care must be taken if a low frequency clock source is already running when calling this function: If the LF clock has a different source then the one currently running, it will be stopped. Then, the new clock source will be started.
  • @note This function has no effect when returning with an error.
  • @post If return code is ::NRF_SUCCESS
  •   - SoC library and protocol stack APIs are made available
    
  •   - A portion of RAM will be unavailable (see the relevant SDS documentation)
    
  •   - Some peripherals will be unavailable or available only through the SoC API (see the relevant SDS documentation)
    
  •   - Interrupts will not arrive from protected peripherals or interrupts
    
  •   - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice.
    
  •   - Interrupt latency may be affected by the softdevice  (see your device's documentation)
    
  •   - Chosen LF clock source will be running
    
  • @param clock_source Low frequency clock source and accuracy. (Note: In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock).
  • @param assertion_handler Callback for softdevice assertions.

We've used both of the features (independently) with no problems, but when they are both enabled, one runs over the other...

What is the correct way to use the RTC (or other) timer to time execution cycles which include ANT involvement?

Can they both be enabled at the same time? Examples!!???

If not: how can one use a Timer -and-/-or- ANT interrupt to wake momma back up?

Thank you!!! roger

Parents Reply Children
No Data
Related