Transmitted serial data not outputting correctly

85 Views Asked by At

I'm having an issue with transmitting serial data using C#.

The below code is a simple example that transmits the byte value 0x00 which comes out inverted 0xFF;

namespace Serialwrite
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SerialPort SP = new SerialPort("COM7", 9600, Parity.None, 8, StopBits.One);
            SP.Open();
            SP.Write(new byte[] { 0x00 }, 0, 1);
            Thread.Sleep(1000);
            SP.Close();
        }
    }
}

The problem is that the 8 high bits appear before the start bit as shown in the 1st image. When I was expecting the waveform to look like the 2nd image.

I'm not sure whyt this is the case.

enter image description here

enter image description here

enter image description here

0

There are 0 best solutions below