I am currently working on a project where I have to receive 128 MB of data from the serial port. I have PCB where there is 128MB FLASH and a Microcontroller on it. I connected a FTDI board from microcontroller to my PC. My basic algorithms work like this:
Basically that's it.
On my PC I wrote simple program in C# that configures and opens the port of serial channel then transmit address when I click the button.
However, I have noticed that some of the data is wrong. For example I got 0x09 0x00 instead of 0x09 0xcf. Some of the data are zeros.
pseudo code is below:
while (Page < End_Of_Memory)
{
SerialPort.Write(Command_n_PageAddress);
SerialPort.Read(InputBuffer,0,256);
Stream.Write(MyTxtFile.txt,0,256);
Page++;
}
Baudrate of Serial Channel = 2Mbps
Why am I receiving 0x00 sometimes? Also is this the correct way to read from serial port? Should I wait for some time so that data transmission is complete and then read the buffer? What else can I do to make sure the correct data is received when dealing with this much of data(Maybe simple checksum)?
User contributions licensed under CC BY-SA 3.0