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

Migration to SD functions

I have to update my non soft device source code to SD because now I will use Radio.

My question is if it is necessary to rewrite all functions which are in SD API. Like:

NVIC_SetPriority(ADC_IRQn, APP_IRQ_PRIORITY_LOW);
NVIC_ClearPendingIRQ(ADC_IRQn);
NVIC_EnableIRQ(ADC_IRQn);
NRF_POWER->SYSTEMOFF = 1;	
NRF_CLOCK->TASKS_HFCLKSTART = 1;
NRF_RTC1->EVENTS_COMPARE[0] = 0;
__WFI();
__WFE();
and similiar

I'm assume that SD alternate function has just some assert to control if I'm passing right arguments or so. So if I'm sure I didn't use any resources against SD, is it necessary to use strictly only SD functions?

  • The comment is only about SD_EVT_IRQn.

    You can read about it in nRF51 SDK_v6.0.0.43681\Nordic\Documentation\Introduction_to_the_S110_SoftDevice_v1.0.pdf "3 Handling events"

  • Great, that document explains that very clear.

  • I search for enum NRF_SOC_EVTS and that means that by sd_app_evt_wait() system go sleep and wake up at ANY generated event or interrupt, but sd_evt_get(p_evt_id) can get only those events in enum NRF_SOC_EVTS, right? So for non SD events I still can use own flags set in appropriate IRQ handler to know that particular event has occured.

  • Yes, for example, you want to send some data through UART and you send first byte by writing

    NRF_UART0->TXD = data[0]; 
    

    and then go to low-power mode with sd_app_evt_wait() then you will return from sd_app_evt_wait() when UART will send data and generate TXDRDY event so you can handle it like this:

    // Enter main loop.
    for (;;)
    {
        if (NRF_UART0->EVENTS_TXDRDY == 1)
        {
            NRF_UART0->EVENTS_TXDRDY = 0;
            NRF_UART0->TXD = data[next_byte]; 
            ...
        }
        sd_app_evt_wait();
    }
    
  • Great. Now I'm not sure only with __SEV(); Can I use this instruction withih SD enabled? I'm using this in IRQ handler after event_flag is set to avoid race condition.

Related