Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Can disabling interrupts cause radio to hang?


Is it generally a bad idea to disable all interrupts, just temporarily, in an application that also uses the radio queue library?

For example, after receiving a radio packet I’m trying to measure how long something takes using the timer. I want this to be accurate, so I disable all interrupts. When I’m done, I enable them again. Here’s some simplified pseudocode.

while (1) {
  if (rxPacket = radioQueueRxCurrentPacket()) {
    // do stuff with rxPacket here
    EA = 0;
    // start Timer 1
    // do some timing-sensitive stuff during which we want no interrupts
    // ...
    // stop Timer 1
    // we're done, enable interrupts again
    EA = 1;

The problem is that the Wixel eventually locks up (within 10 or 20 seconds of starting up) and stops receiving packets. Just for reference, I’ve got a transmitter Wixel sending packets every 50ms.

Is what I’m trying to do just a bad idea? In other words, is there an obvious concurrency issue with the radio library that could be causing this?



I am sorry you are having trouble with the Wixel. I do not see anything wrong with the plan you described. How long are you disabling interrupts for? Does the problem go away if you leave the interrupts enabled?



I have the interrupts disabled for about 20 ms. There is no problem if I leave the interrupts enabled.


I do not think we tested the radio_queue library in an application like yours that disables interrupts, so it is possible there is a bug in that library or one of its dependencies. It is also possible there is a bug in some other part of your code. If you post some simplified, minimal example code that demonstrates the problem and can be run on two Wixels without any extra hardware, then I might be able to look into it and figure out what is wrong.



Thanks, David. Let me do some more debugging first, which I probably won’t get around to for another week or so. If I can’t figure it out then I’ll post a simplified example demonstrating the problem, as you suggested.