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
  • Update - more surprises! We moved over to HF timer to try it there.. Timer0 works like a charm but..could not get the ANT to start back up.

    We removed ALL timer configs and startups (and all references to the timer) and cannot get the softdevice to start back up. Went back to prior versions of the source without the timer0 with no luck..

    we see: while trying to start up the ant...

    1. enabling the softdevice error code %d4097 (base + x1)
    2. the nvic_set_prior... produces 0x1 error.
    3. subsequent enable_irq.. gets %d 0x2 code..

    ?? ANT THOUGHTS?? It seems like the IRQ evaporated??

    Is there an example of running ANT on a timer cycle??

    Thank you!!

Reply
  • Update - more surprises! We moved over to HF timer to try it there.. Timer0 works like a charm but..could not get the ANT to start back up.

    We removed ALL timer configs and startups (and all references to the timer) and cannot get the softdevice to start back up. Went back to prior versions of the source without the timer0 with no luck..

    we see: while trying to start up the ant...

    1. enabling the softdevice error code %d4097 (base + x1)
    2. the nvic_set_prior... produces 0x1 error.
    3. subsequent enable_irq.. gets %d 0x2 code..

    ?? ANT THOUGHTS?? It seems like the IRQ evaporated??

    Is there an example of running ANT on a timer cycle??

    Thank you!!

Children
No Data
Related