Help me Pls. UART does not work after I pressed reset button!

Can anyone help me?, I have a problem.

When I deployed the program that have “UART_DataReceived” event. First time, It can receive the character from UART correctly. But after I pressed the reset button, UART did not work.

How should I do?, Help me Pleas…

I connected a wire from TX to RX on FEZ Domino board.

*Here is the code


static SerialPort UART ;
static byte[] tx = System.Text.Encoding.UTF8.GetBytes("Test");

static void UART_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{

            Debug.Print("Data Received");                   
          
 }

 public static void Main()
 {   
            UART = new SerialPort("COM1", 9600);
            UART.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived);
            UART.Open();
            while (true)
            {
    
                UART.Write(tx, 0, tx.Length);
                Thread.Sleep(100);                
            }
}

Try to open the port before you attach the event.


UART.Open();
UART.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived);

Oh…I do follow you, It works correctly.!!!

Thank you very much for your reply _/|_