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

Scan the network for beacons for a limited time slot and then send it to sleep mode in IEEE 802.15.4

I am working on 802.15.4 using nrf52840 and sdk 15.2. I want the receiver node to scan the network for beacons transmitted by the transmitter node for 100ms, go to sleep for 2 sec and then wake up again to scan the network. How can I implement it using timers. Are there any code snippets to help me begin with.

I've looked at several examples and questions in the devzone however most of them seem complicated to implement and I think I might be going about it the wrong way.

For now, some help with just scanning the network for beacons for a limited time slot will also help. 

Parents
  • __WFE() is normally called in an endless while-loop in main(), after initialization of peripherals/modules are completed. Whenever an event is generated in an enabled peripheral, the CPU will wakeup to handle the event. The app_timer library runs on top of the RTC, which will generate an interrupt at a given timeout. The interrupt will trigger the timeout handler, where you start/do whatever you want to happen at this interval. When the interrupt handler is exited, the CPU will continue executing code in while-loop in main(), eventually again calling WFE() to go back to sleep whenever all work is done.

    A simple code example would be like this:

    timeout_handler()
    {
        // do stuff at timer timeout interval
    }
    
    timer_init()
    {
        // initialize app_timer library
        // start the timer
    }
    
    main()
    {
        timer_init();
        while(1)
        {
            __WFE();
        }
    }

    Note that there is also __WFI() alternative, and it is good practice to call __SEV() to make sure no pending events will wake the CPU prematurely, see this post (and the linked post).

Reply
  • __WFE() is normally called in an endless while-loop in main(), after initialization of peripherals/modules are completed. Whenever an event is generated in an enabled peripheral, the CPU will wakeup to handle the event. The app_timer library runs on top of the RTC, which will generate an interrupt at a given timeout. The interrupt will trigger the timeout handler, where you start/do whatever you want to happen at this interval. When the interrupt handler is exited, the CPU will continue executing code in while-loop in main(), eventually again calling WFE() to go back to sleep whenever all work is done.

    A simple code example would be like this:

    timeout_handler()
    {
        // do stuff at timer timeout interval
    }
    
    timer_init()
    {
        // initialize app_timer library
        // start the timer
    }
    
    main()
    {
        timer_init();
        while(1)
        {
            __WFE();
        }
    }

    Note that there is also __WFI() alternative, and it is good practice to call __SEV() to make sure no pending events will wake the CPU prematurely, see this post (and the linked post).

Children
No Data
Related