This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC 1114 UART help...

Hi there Keil forums, I have a question about how my LPC 1114 responds to data over a Uart connection.

This is my UART interrupt code:

/* UART Data Received Interrupt */
void UART_IRQHandler(void) {
        static NetworkLayerState networkState = Network_Idle;
        unsigned int interruptId = LPC_UART->IIR;

        while((interruptId & 1) == 0)
        {
                switch((interruptId >> 1) & 0x07)
                {

                        case 0x02: //Receive Data Available
                        case 0x06: //Character time-out indicator (buffer flush)
                                networkState = NetworkStateMachine(LPC_UART->RBR & 0xFF, networkState);
                                break;

                        case 0x03: //Receive Line Status interrupt
                                break; //Not handling frame errors
                }

                interruptId = LPC_UART->IIR;
        }
}

My computer and mcu are connected via a usb to uart cable. I want to know what kind of data I need to send to my mcu in order to trigger this interrupt. For example if I want to send the integer "1" to my mcu how would I do that and then I can store that integer value in a variable within the firmware of the MCU.
My GUI is done in C# and it is what I use to communicate with the mcu.

Parents
  • A microcontroller's UART (and a PC's COM port) just sends and receives bytes - it neither knows nor cares anything of the meaning or interpretation of those bytes.

    When a microcontroller's UART (and a PC's COM port) sends a byte, it neither knows nor cares anything of the destination of that byte. It just sends; the destination is irrelevant.

    When a microcontroller's UART (and a PC's COM port) receives a byte, it neither knows nor cares anything of the source of that byte. It just receives; the source is irrelevant.

    So it's entirely up to you how you want to represent your data over the link.

    Sending a "1" is a trivial case - you can either send a single byte with the numerical value one (0x01), or you can send a single character '1'.

    Things get more interesting when you need to send stuff that can't be represented in a single byte, but you still have basically the same choice: either send as a "raw" numerical value, or send as a text string (a sequence of characters).

    To send characters, you would encode them using ASCII

    en.wikipedia.org/.../ASCII

    http://www.asciitable.com/

Reply
  • A microcontroller's UART (and a PC's COM port) just sends and receives bytes - it neither knows nor cares anything of the meaning or interpretation of those bytes.

    When a microcontroller's UART (and a PC's COM port) sends a byte, it neither knows nor cares anything of the destination of that byte. It just sends; the destination is irrelevant.

    When a microcontroller's UART (and a PC's COM port) receives a byte, it neither knows nor cares anything of the source of that byte. It just receives; the source is irrelevant.

    So it's entirely up to you how you want to represent your data over the link.

    Sending a "1" is a trivial case - you can either send a single byte with the numerical value one (0x01), or you can send a single character '1'.

    Things get more interesting when you need to send stuff that can't be represented in a single byte, but you still have basically the same choice: either send as a "raw" numerical value, or send as a text string (a sequence of characters).

    To send characters, you would encode them using ASCII

    en.wikipedia.org/.../ASCII

    http://www.asciitable.com/

Children