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

How to get second FX2 serial port to work?

Hello,

I have read all the info regarding how to get the 2nd serial port to work with putchar (printf). I have updated the 'PUTCHAR.C' file like recommended by Keil:

char putchar (char c)  {
  while (!TI1);
  TI1 = 0;
  return (SBUF1 = c);
}

My main function looks like this:

void main()
{
        unsigned long ul;

#ifndef MONITOR51
    SCON  = 0x50;                       /* SCON: mode 1, 8-bit UART, enable rcvr      */
    TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
    TH1   = 221;                /* TH1:  reload value for 1200 baud @ 16MHz   */
    TR1   = 1;                  /* TR1:  timer 1 run                          */
    TI    = 1;                  /* TI:   set TI to send first char of UART    */
#endif

        // Initialize the second serial port on the FX2 eval board.
        // NOTE that we are sharing timer 1 with serial port 0.
    SCON1  = 0x50;                      /* SCON1: mode 1, 8-bit UART, enable rcvr      */
    TI1    = 1;                 /* TI1:   set TI1 to send first char of UART    */

        while(1)
        {
                for(ul=0; ul<0xffff; ul++)
                {
                        //PRINTF(("%ld\r\n", ul));
                        printf("Testing...");
                }
        }
}

Both serial ports 0 and 1 are using timer 1 as baudrate generator. The problem with the above code is that the code hangs on this statement in putchar: "while (!TI1);". I have tried to set TI1 but it immediately gets cleared again...

I want to get printf to work on serial port 1 because i want to be able to stop a running application via uVision3 (i'm using Mon51).

0