Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 2 months ago.
Interrupt pin in KL46Z. It does not detect some interrupt.Nearly 1 in 20 interrupt are not detected.
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 }
Any alternative suggestion to achieve the same goal will also be highly appreciated.. Thanking you,
Dheeraj M Pai dheerajmpai23@gmail.com
1 Answer
9 years, 2 months ago.
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.
BTW You have also raised the same problem as a topic. Once is enough...
Hi Wim,
I tried with PulUp,PullDown and also with PullNone.Still it doesn't work.I tried with other PIns and other mbed KL46Z Boards also.Still I am facing the same problem.Can I Please know any other reason why it is caused.
And Also I checked the time required for rising of Interrupt Pin in Transmitter.It is less than 20ns.I Think that is steep enough
Can I please know any other reason for this problem.
Thank You
Dheeraj M Pai
posted by 06 Jul 2015Are you sure there is a rising edge at the time when the interrupt is missed. Did you check on a logic analyser that the irq pin does not get stuck at high or low level? Could the mbed miss the interrupt because it is busy handling another interrupt or ticker/timer callback function.
posted by 06 Jul 2015