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

Software Interrupt Handler nRF52832

Hi,

Good day!

Statement of porblem: We are developing appliction using nrf52832. In our application we have Capacitive touch button and capacitive wheel sensor for user input and other pheripheral LED, TEMP.. interrupts are available. At the moment application interrupts are run through a while loop in main.c (which is for sure not the best way to do it). and using app_timer. 

Query: 

I would appreciate suggestions, in determinig what is the best approach to this implementation part.  I looked up google found out that Software interrupts(SWI) can be used for this purpose. But i could not find any example which describes the SWI use in SDK. 

If more inforamtion required please do let me know.

Thank you

Aim High.

Parents
  • HI Aim High, 

    the nRF52832 has a EGU — Event generator unit ( i.e. Software interrupt unit) that you can use to trigger SW interrupts, see snippet below.

    void SWI3_EGU3_IRQHandler(void)
    {   
        // Clear SWI Event. 
        NRF_EGU3->EVENTS_TRIGGERED[0] = 0;
                 
        // Place code here
    
    }
    
    static void init_egu()
    {  
        // Enable TRIGGERED0 interrupt
        NRF_EGU3->INTENSET = EGU_INTENSET_TRIGGERED0_Enabled << EGU_INTENSET_TRIGGERED0_Pos;
        
        // Set EGU3 Interrupt pririty to 6.
        NVIC_SetPriority(SWI3_EGU3_IRQn,6);
        
        //Enable SWI3_EGU3 interrupt. 
        NVIC_EnableIRQ(SWI3_EGU3_IRQn);
    }
    
    
    int main(void)
    {
        bool erase_bonds;
        uint32_t err_code;
        
        // Initialize.
        log_init();
        timers_init();
        buttons_leds_init(&erase_bonds);
        ble_stack_init();
        gap_params_init();
        gatt_init();
        advertising_init();
        services_init();
        conn_params_init();
        egu_init();
        
        // Trigger event
        NRF_EGU3->TASKS_TRIGGER[0] = 1;
        
        // Enter main loop.
        for (;;)
        {
            if (NRF_LOG_PROCESS() == false)
            {
                power_manage();
            }
        }
    }
    Best regards
    Bjørn
Reply
  • HI Aim High, 

    the nRF52832 has a EGU — Event generator unit ( i.e. Software interrupt unit) that you can use to trigger SW interrupts, see snippet below.

    void SWI3_EGU3_IRQHandler(void)
    {   
        // Clear SWI Event. 
        NRF_EGU3->EVENTS_TRIGGERED[0] = 0;
                 
        // Place code here
    
    }
    
    static void init_egu()
    {  
        // Enable TRIGGERED0 interrupt
        NRF_EGU3->INTENSET = EGU_INTENSET_TRIGGERED0_Enabled << EGU_INTENSET_TRIGGERED0_Pos;
        
        // Set EGU3 Interrupt pririty to 6.
        NVIC_SetPriority(SWI3_EGU3_IRQn,6);
        
        //Enable SWI3_EGU3 interrupt. 
        NVIC_EnableIRQ(SWI3_EGU3_IRQn);
    }
    
    
    int main(void)
    {
        bool erase_bonds;
        uint32_t err_code;
        
        // Initialize.
        log_init();
        timers_init();
        buttons_leds_init(&erase_bonds);
        ble_stack_init();
        gap_params_init();
        gatt_init();
        advertising_init();
        services_init();
        conn_params_init();
        egu_init();
        
        // Trigger event
        NRF_EGU3->TASKS_TRIGGER[0] = 1;
        
        // Enter main loop.
        for (;;)
        {
            if (NRF_LOG_PROCESS() == false)
            {
                power_manage();
            }
        }
    }
    Best regards
    Bjørn
Children
Related