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

Can't get TI flag to be set when writing into SBUF

Hi,

I'm trying to simulate working of a UART.
When I write into SBUF, the TI flag doesn't
go high even though I have enabled interrupts.

Is there any way I can simulate it using SOUT VTREG. can't find example how to use SOUT.

Parents
  • Hey Guys,

    That was not the problem. It can work
    at any Baud rate. Finally got it
    working by seeing the HELLO.c in Examples,
    but I don't know how!.

    Here is my code:-
    if (TI == 1) /* check for transmit interrupt flag */
    {
    TI = 0;
    P1 ^= 0x01; /* Toggle P1.0 each time we print */
    SBUF = "H";
    }

    Also Need to keep the serial window open for
    the output to print.

    Still can't understand why TI flag doesn't
    raise if I don't toggle port pin 1.0 (T2).

    Thanks.

Reply
  • Hey Guys,

    That was not the problem. It can work
    at any Baud rate. Finally got it
    working by seeing the HELLO.c in Examples,
    but I don't know how!.

    Here is my code:-
    if (TI == 1) /* check for transmit interrupt flag */
    {
    TI = 0;
    P1 ^= 0x01; /* Toggle P1.0 each time we print */
    SBUF = "H";
    }

    Also Need to keep the serial window open for
    the output to print.

    Still can't understand why TI flag doesn't
    raise if I don't toggle port pin 1.0 (T2).

    Thanks.

Children