5 years, 4 months ago.

Modserial & interrupts

Hi everyone, I need help with interrupts while using modserial.

The problem I am having is it appears NVIC_DisableIRQ(UART1_IRQn); && NVIC_EnableIRQ(UART1_IRQn); are not disabling/enabling the interrupts. I have also tried: disable_interrupt() enable_interrupt()

Specifically when I call the disableIRQ and transmit over serial I am capturing the talk back from my own Tx. This intern is causing another IRQ RX call and I get stuck in a forever loop of the same data transmitted over and over.

interrupt attach

    line.attach(&txCallback, MODSERIAL::TxIrq);
    line.attach(&rxCallback, MODSERIAL::RxIrq);
    line.attach(&txEmpty,    MODSERIAL::TxEmpty);

I notice the documentation shows SERIAL instead of MODSERIAL in the attach. I am wondering if this is the cause of the IRQ not disabling.

I also tried uart1-3 with no luck based on this post: https://developer.mbed.org/questions/135/UART-and-pins/

So what do you do when you are transmitting a 5 to 10 bytes and do not want to receive your own transmission? Is there a way to only disable the Rx interrupt? Not sure if this is needed since the line is only half duplex but just a thought.

Rob

Can you post a simple program where it is going wrong? Since it is unlikely those functions are broken.

posted by Erik - 23 Jul 2015

Usage would be as follows, disable IRQ - send selected bytes based on requester - re-enable IRQ.

Example usage

void lineRequestData(char requestVal)
{
    switch(requestVal) {
        case(0x01): {
        NVIC_DisableIRQ(UART1_IRQn);
              line.putc(byte0);
              line.putc(byte1);
              line.putc(byte2);
              line.putc(byte3);
              line.putc(byte4);
        NVIC_EnableIRQ(UART1_IRQn); 
            break;
        }
        case(0x02): {
        NVIC_DisableIRQ(UART1_IRQn);
            line.putc(byte0);
            line.putc(byte1);
            line.putc(byte2);
            line.putc(byte3);
            line.putc(byte4);
       NVIC_EnableIRQ(UART1_IRQn); 
            break;
        }
     }
 
}
posted by Rob Crain 23 Jul 2015
Be the first to answer this question.