6 years, 8 months ago.

How can clear th irq ----- Serial::TxIrq

Hello one. I have a demo code with Realese 149 of Mbed library.

affter call the line: pc.attach(&o_uart_send_,Serial::TxIrq); then cpu run the funtion all the time: o_uart_send_();

the led2 on and off all the time. How can clear th irq of TxIrq?

The code is flowed. ---------------------

#include "mbed.h"

DigitalOut led1(PC_13);
DigitalOut led2(PB_7);
Serial pc(SERIAL_TX, SERIAL_RX);


int time1;
void o_uart_send_()
{
    pc.writeable();
    if(time1++>10000){
        time1=0;
        led1=!led1;
    }
}
void o_uart_recv()
{
	if(pc.readable()){
		pc.putc(pc.getc());
	}
}
void o_uart_init()
{
    pc.baud(115200);
    pc.attach(&o_uart_recv,Serial::RxIrq);
    pc.attach(&o_uart_send_,Serial::TxIrq);
}

int main() {
	o_uart_init();
    while(1) {
        led2 = 1; // LED is ON
        wait(0.2); // 200 ms
        led2 = 0; // LED is OFF
        wait(1.0); // 1 sec
    }
}

Rather than posting images or code with no formatting use

<<code>>
your code
<</code>>
posted by Andy A 24 Aug 2017

Thanks

posted by miao jb 24 Aug 2017

1 Answer

6 years, 8 months ago.

You can pass NULL into attach to remove a previously attached IRQ handler. See: https://github.com/ARMmbed/mbed-os/blob/master/drivers/SerialBase.cpp#L79


Assigned to Jan Jongboom 6 years, 8 months ago.

This means that the question has been accepted and is being worked on.