[riot-users] Radio Interrupt Handler

Navneet Pandey navneet.pandey at outlook.in
Fri Nov 16 12:44:10 CET 2018


Hello Joakim, thanks again for answering the questions. I am sorry, I have couple of more questions.

Firstly, I do not set the NETOPT_TX_START_IRQ flag. There is no need to tell the threads or mcu that transmission is starting in all cases?

> This is also signaled to the upper layers via the netdev->event_callback(netdev, NETDEV_EVENT_TX_STARTED); call in at86rf2xx_tx_exec (at86rf2xx.c).
> When the transmission is finished, the transceiver will issue an IRQ to the CPU and the CPU will run the IRQ handler.
No Interrupt required to start transmission?
(I was assuming so because, from what you described in the earlier messages, INTRRUPT flips the GPIO pin which informs the CPU about an event to read from some register, after which the transmission would start, but I can clearly see that all the bus requests and calls happen in exec()/prepare() and load() methods. This is what created the confusion about the need for INTERRUTP. But then, if I disable the Interrupt, I do not receive packet I am able to send only). 

Basically, still confused about the role of Interrupt/ISR for sending a packet. It may be pretty straightforward but please help me out. And I think it would be awesome if sending process is also added to "netdev.h" documentation just like receiving process.

> The end of the _send method (in at86rf2xx_netdev.c) means that the frame has been loaded in the transceiver buffer and the transceiver is going to send it at the 
> next opportunity.
Actually, the thing is I am experiencing some jitter post at86rf2xx::exec() method. I am trying pin point the cause but since I am not able locate a point which could actually be causing jitters. Is there a way to timestamp the wait process (after frame is loaded) until the frame transmission starts.

And, is there any file where I am forgetting to enable debugging to get the exact process flow. I am already debugging gnrc_netif, gnrc_netif_ieee802154, at86rf2xx/*, and gnrc_mac/internal.c.

Finally, I was expecting similar method definitions in other radio drivers as well. But, for cc2420_netdev, the _isr function only has RX_COMPLETE event.  I would like to know why are the other events missing and how do the upper layers, in this case, become aware of the events.

I know these are lot of question but, I hope these question would give me all the answers I need. Thank you.

Regards,
Navneet Pandey

-----Original Message-----
From: users <users-bounces at riot-os.org> On Behalf Of users-request at riot-os.org
Sent: Friday, November 16, 2018 5:00 AM
To: users at riot-os.org
Subject: users Digest, Vol 70, Issue 14

Send users mailing list submissions to
	users at riot-os.org

To subscribe or unsubscribe via the World Wide Web, visit
	https://lists.riot-os.org/mailman/listinfo/users
or, via email, send a message with subject or body 'help' to
	users-request at riot-os.org

You can reach the person managing the list at
	users-owner at riot-os.org

When replying, please edit your Subject line so it is more specific than "Re: Contents of users digest..."


Today's Topics:

   1. Re: Cortex Kinetis KW2xD Low Power Modes (Olivier Fauchon)
   2. Re: Cortex Kinetis KW2xD Low Power Modes (Joakim Nohlgård)
   3. Re: Radio Interrupt Handler (Joakim Nohlgård)


----------------------------------------------------------------------

Message: 1
Date: Thu, 15 Nov 2018 22:35:01 +0100
From: Olivier Fauchon <ofauchon2204 at gmail.com>
To: users <users at riot-os.org>
Subject: Re: [riot-users] Cortex Kinetis KW2xD Low Power Modes
Message-ID:
	<CAJ8U=Qtf-DWFNJXtjZcTEOsuXTemeJNFUZrnx4ri-6q=6qONmw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi.
It seems the board I use don't have LPTMR declared :

https://github.com/RIOT-OS/RIOT/blob/master/boards/pba-d-01-kw2x/include/periph_conf.h

#define PIT_NUMOF               (2U)
#define PIT_CONFIG {                 \
        {                            \
            .prescaler_ch = 0,       \
            .count_ch = 1,           \
        },                           \
        {                            \
            .prescaler_ch = 2,       \
            .count_ch = 3,           \
        },                           \
    }
#define LPTMR_NUMOF             (0U)
#define LPTMR_CONFIG {}
#define TIMER_NUMOF             ((PIT_NUMOF) + (LPTMR_NUMOF))


Can you confirm I need to declare LPTMR to get Low Power Mode working ?
Do you have example of working LPTMR declarations ?

Thanks
Olivier








Le mar. 13 nov. 2018 à 18:52, Joakim Nohlgård <joakim.nohlgard at eistec.se> a écrit :

> Hi again Oliver,
>
> Den tis 13 nov. 2018 16:48 skrev Olivier Fauchon <ofauchon2204 at gmail.com>:
> >
> > Hi Joakim,
> >
> > I have been busy designing my own board (based on phywave module)
> >
> https://github.com/ofauchon/oflmotes/blob/master/mote-devboard/kw2xd/c
> ircuit/v1/devboard_kw2xd_v1.0_board.png
>
> Cool!
>
> >
> > Now I'm back to RIOT-OS tests.
> > I can see your Low Power  contributions:
> >
> > [1]: https://github.com/RIOT-OS/RIOT/pull/7897
> > [2]: https://github.com/RIOT-OS/RIOT/pull/8930
> > [3]: https://github.com/RIOT-OS/RIOT/pull/8933
> > [4]: https://github.com/RIOT-OS/RIOT/pull/8814
> >
> > ... had been merged to Master. That's great!
>
> #7897 is still pending. If you would like to help you could run some 
> tests on your board with that PR and report your results. There is 
> still one issue reported in the PR discussion thread which I have not 
> looked into yet related to the phytec board and UART in low power 
> modes.
>
> >
> > Can you confirm me Kinetis Low Power Modes are fully supported in
> Riot/master ?
>
> Not yet, #7897 is still awaiting review and testing
>
> >
> > Should I switch my board from PIT to LPTMR to enable these low power
> modes ?
>
> Unless you have a reason for requiring better than 30.5 µs precision 
> on xtimer, I don't see any reason for not using LPTMR as XTIMER_DEV.
>
> Recently added is one more PR which improves the LPTMR, in particular 
> it will fix a timer rollover when timer_set is called with timeout=0.
> See https://github.com/RIOT-OS/RIOT/pull/10020
>
> Best regards,
> Joakim
> _______________________________________________
> users mailing list
> users at riot-os.org
> https://lists.riot-os.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/users/attachments/20181115/c174f747/attachment-0001.html>

------------------------------

Message: 2
Date: Fri, 16 Nov 2018 08:13:34 +0100
From: Joakim Nohlgård <joakim.nohlgard at eistec.se>
To: RIOT OS users <users at riot-os.org>
Subject: Re: [riot-users] Cortex Kinetis KW2xD Low Power Modes
Message-ID:
	<CAOy=vakXnZikpeFDhUPBkCv-zMh5bahHR0R6w3eHuHPxCu0w+g at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

Hi again,

On Thu, Nov 15, 2018 at 10:36 PM Olivier Fauchon <ofauchon2204 at gmail.com> wrote:
>
> Hi.
> It seems the board I use don't have LPTMR declared :
>
> https://github.com/RIOT-OS/RIOT/blob/master/boards/pba-d-01-kw2x/inclu
> de/periph_conf.h
>
> #define PIT_NUMOF               (2U)
> #define PIT_CONFIG {                 \
>         {                            \
>             .prescaler_ch = 0,       \
>             .count_ch = 1,           \
>         },                           \
>         {                            \
>             .prescaler_ch = 2,       \
>             .count_ch = 3,           \
>         },                           \
>     }
> #define LPTMR_NUMOF             (0U)
> #define LPTMR_CONFIG {}
> #define TIMER_NUMOF             ((PIT_NUMOF) + (LPTMR_NUMOF))
>
>
> Can you confirm I need to declare LPTMR to get Low Power Mode working ?

You will need LPTMR if you want to be able to use low power modes when you are using the xtimer module, which is usually required for things like network timeouts etc.

> Do you have example of working LPTMR declarations ?

Yes, look at the other Kinetis based boards in the tree. Here is one example from FRDM-K22F:
https://github.com/RIOT-OS/RIOT/blob/836fe3dbbaba8b65bf23110c8b56cbaf1558c022/boards/frdm-k22f/include/periph_conf.h#L82-L90

#define LPTMR_NUMOF             (1U)
#define LPTMR_CONFIG {          \
    {                           \
        .dev = LPTMR0,          \
        .irqn = LPTMR0_IRQn,    \
        .src = 2,               \
        .base_freq = 32768u,    \
    },                          \
}


/Joakim


------------------------------

Message: 3
Date: Fri, 16 Nov 2018 08:38:23 +0100
From: Joakim Nohlgård <joakim.nohlgard at eistec.se>
To: RIOT OS users <users at riot-os.org>
Subject: Re: [riot-users] Radio Interrupt Handler
Message-ID:
	<CAOy=va=Ew3+dQDNWyDGsjdtSPcuc_+7dRZrU4m=Y3wn4P94Ytw at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

Hi again Navneet,

On Wed, Nov 14, 2018 at 10:50 AM Navneet Pandey <navneet.pandey at outlook.in> wrote:
>
> Hello everyone, I have some confusion regarding the process flow of program at the driver level.
>
>
>
> I have the following debug logs from at86rf2xx (with some custom logs)
>
>
>
> CLIENT - m3-100;[at86rf2xx] at86rf2xx_tx_load
>
> CLIENT - m3-100;[at86rf2xx] PRELOADED at86rf2xx_tx_exec
>
> CLIENT - m3-100;PKT SENT // Represents end of _send method in 
> at86rf2xx_netdev.c
>
> server - m3-101;INTERRUPT
>
> server - m3-101;[at86rf2xx] EVT - ISR CALLED
>
> CLIENT - m3-100;INTERRUPT // Represents _irq_handler method in 
> at86rf2xx_netdev.c if (dev->event_callback) this is TRUE/1
>
> CLIENT - m3-100;[at86rf2xx] EVT - ISR CALLED // represents _isr method 
> being called
>
> CLIENT - m3-100;[at86rf2xx] return to idle state 0x16
>
> server - m3-101;[at86rf2xx] EVT - RX_END
>
> server - m3-101;PKT RECV
>
> server - m3-101;PKT RECV
>
> CLIENT - m3-100;[at86rf2xx] EVT - TX_END
>
> My question here is that,
>
> Firstly, does PKT_SENT i.e. the end of send method from netdev::send mean that data/packet was actually sent?

The end of the _send method (in at86rf2xx_netdev.c) means that the frame has been loaded in the transceiver buffer and the transceiver is going to send it at the next opportunity. This is also signaled to the upper layers via the netdev->event_callback(netdev, NETDEV_EVENT_TX_STARTED); call in at86rf2xx_tx_exec (at86rf2xx.c).
When the transmission is finished, the transceiver will issue an IRQ to the CPU and the CPU will run the IRQ handler. If you look at the _isr method you will find calls to netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE); and other similar events. This is the way that the driver tells the upper layers that the transmission has ended for some reason, the type of event signals what the status is, TX_COMPLETE means success, NOACK means that the frame was sent but there was no acknowledgment from the remote side, MEDIUM_BUSY means that there was someone else using the channel and we could not find a free slot before running out of retries (CSMA failure).
>
> Secondly, if the answer is yes to previous question, why does INTERRUPT occur after the packet was sent? If answer to the first question is no, then when/where does the packet/data actually gets transmitted?

The exact behavior depend on which radio you are using, but generally the data will begin transmitting as soon as the transceiver detects that the channel is free if you are using CSMA, which is the default setting on transceivers which support it. There may be a number of retries if the channel is busy so the time that this takes is indeterminate beforehand.

> I am aware that methods such as prepare/load/exec already start the transmission process, hence the dilemma about INTERRUPT being called after these modules/functions.
>
> Thirdly, In the logs (not present in the above log), I observed that 
> the following piece of code never gets executed even though packet 
> transmission starts
>
> if (netdev->event_callback &&
>
>         (dev->flags & AT86RF2XX_OPT_TELL_TX_START)) {
>
>         DEBUG("TX STARTED\n");
>
>         netdev->event_callback(netdev, NETDEV_EVENT_TX_STARTED);
>
>     }

Does your application enable the NETOPT_TX_START_IRQ option?
(Otherwise the (dev->flags & AT86RF2XX_OPT_TELL_TX_START) part is 0) The example applications in the RIOT repository do not enable this, only LWMAC seem to use it at present.

>
>
>
> I really appreciate any help in solving this small confusion. Thank you.
>

I hope this helps,
Joakim


------------------------------

Subject: Digest Footer

_______________________________________________
users mailing list
users at riot-os.org
https://lists.riot-os.org/mailman/listinfo/users


------------------------------

End of users Digest, Vol 70, Issue 14
*************************************


More information about the users mailing list