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

nRF52 radio bit counter

Hello, recently I've found an information about bit counter in Radio Module in nRF52 Product Specification. Unfortunatelly I can't find any reference at infocenter how to use it, neither can I find any example in the Internet or SDK.

In my project I am supposed to stop transmitting data after sending certain amount of packs and I think it could be helpful if I had access to this counter and in certain condition turn it on again. This information gives me lots of hope to solve my problem:

"The bit counter is started by triggering the BCSTART task, and stopped by triggering the BCSTOP task. A BCMATCH event will be generated when the bit counter has counted the number of bits specified in the BCC register."

So my question is: is there any library or example showing how to use interrupt generated by this counter?

Parents
  • Hi Oskar

    The bit counter is intended to count bits within the packet, and not entire packets. To count total packets you would be better of just updating a variable in the code (since you probably need to run some processing before/after each packet anyway), or set up a timer module in counter mode and have it count the END events through the PPI.

    We don't have any examples for the bit counter, no, but it is used internally by some of our stacks and libraries.

    Best regards
    Torbjørn

  • Hi Oskar
    Yes, events are used to generate interrupts. First you have to allow that event to create interrupts by setting the right bit in the NRF_RADIO->INTENSET register, enable the interrupt for the radio peripheral itself, and implement the interrupt handler.

    Example:

    NRF_RADIO->INTENSET = RADIO_INTENSET_END_Msk;        
    NVIC_EnableIRQ(RADIO_IRQn);     
         
    void RADIO_IRQHandler(void)           
    {        
      if(NRF_RADIO->EVENTS_END)       
      {         
        NRF_RADIO->EVENTS_END = 0;        
        // Count the events here      
      }        
    }
    
Reply
  • Hi Oskar
    Yes, events are used to generate interrupts. First you have to allow that event to create interrupts by setting the right bit in the NRF_RADIO->INTENSET register, enable the interrupt for the radio peripheral itself, and implement the interrupt handler.

    Example:

    NRF_RADIO->INTENSET = RADIO_INTENSET_END_Msk;        
    NVIC_EnableIRQ(RADIO_IRQn);     
         
    void RADIO_IRQHandler(void)           
    {        
      if(NRF_RADIO->EVENTS_END)       
      {         
        NRF_RADIO->EVENTS_END = 0;        
        // Count the events here      
      }        
    }
    
Children
No Data
Related