InterruptIn not perfect. Interrupt not detected everytime.One in ten interrupt is not detected

04 Jul 2015

Hi,

I am relatively new to mbed .I am interfacing mbed and a transmitter(ADF7023) using SPI and 1 interrupt pin(PTA13). The ADF7023 gives interrupt every time its buffer is full/Half full. And mbed should detect the interrupt and do some function.

If the mbed misses even one single interrupt generated by RF Transmitter. The whole mechanism used in transmission will be corrupted and transmitter transmits repeatedly transmits some junk data.

The problem is the same. mbed misses few interrupts and later the whole data is junk.

Any help regarding this issue will be duely appreciated

Quote:

The following code using interrupt works initially .later it misses an interrupt and all junk data is transmitted

mbed interfacing with RF Transmitter(adf). IRQ.rise not always detected

#include "mbed.h"
#include <iostream>
SPI adf(PTA16, PTA17, PTA15);//MOSI, MISO, CLOCK

DigitalOut CS(PTD4);
InterruptIn IRQ(PTA13); //Interrupt pin which I am facing problem
    int main()
{   
    IRQ.enable_irq();
    IRQ.rise(&write_data);
} 

 write_data(){
//  some function that clears interrupt .which **DOES NOT** contain any malloc,Printf,or any delaying function
}

Quote:

But when tried to poll the IRQ pin in infinite while loop.Everything works fine. with zero error.

mbed code using infinite while loop. Run by polling IRQ pin

#include "mbed.h"
#include <iostream>
SPI adf(PTA16, PTA17, PTA15);//MOSI, MISO, CLOCK

DigitalOut CS(PTD4);
InterruptIn IRQ(PTA13); //Interrupt pin which I am facing problem
    int main()
{   
  int x = IRQ
    while(1){
       x=IRQ;
       if(x)
       write_data();
       }
} 

 write_data(){
//  some function that clears interrupt .which **DOES NOT** contain any malloc,Printf,or any delaying function
}

Can anyone suggest me what is the error in the former code while the latter one with same logic is working fine.

Any alternative suggestion to achieve the same goal will also be highly appreciated.. Thanking you,

Dheeraj M Pai dheerajmpai23@gmail.com

04 Jul 2015

The interrupt version of the code only responds to rising edges whereas the polling version samples the logic level and then processes the data. Make sure that the mbed clears all sources of possible interrupts by resetting the appropriate bits in the transceiver. If you dont clear all interrupt sources the IRQ pin will remain high and no further rising edges will be detected. The polling version of the code may still work because it sees a permanent high pin and finds out what to do next. Also make sure the rising edges are clean and steep enough. Perhaps add a pull-up resistor.