SpenceKonde / megaTinyCore

Arduino core for the tinyAVR 0/1/2-series - Ones's digit 2,4,5,7 (pincount, 8,14,20,24), tens digit 0, 1, or 2 (featureset), preceded by flash in kb. Library maintainers: porting help available!
Other
554 stars 144 forks source link

Bug Report: Serial.write() Skips Bytes in Transmission #1070

Closed Sandvoxel closed 7 months ago

Sandvoxel commented 7 months ago

Title: Bytes Skipped During Serial Transmission with ATtiny3227 on Custom Board

Environment:

Description: I've encountered an issue where Serial.write() appears to skip some bytes during transmission on a custom board utilizing an ATtiny3227 microcontroller. This issue was observed when transmitting a specific set of bytes via serial communication at a baud rate of 115200. Despite the expectation that all bytes are sent sequentially without omission, some bytes seem to be missing from the output.

Steps to Reproduce:

  1. Initialize the serial communication with Serial.begin(115200);.
  2. Transmit a predefined byte array using Serial.write() inside the setup() function without any loop.
  3. Observe the transmitted bytes on the serial monitor or through a serial terminal program.

Expected Result: All bytes in the array are transmitted correctly and can be seen on the receiving end in their entirety.

Actual Result: Some bytes appear to be skipped in the transmitted sequence. The expected output was [1, 1, 17, 77, 83, 53, 54, 49, 49, 32, 102, 111, 117, 110, 100, 46, 10, 211, 91, 0] but the observed output was [1, 1, 77, 83, 53, 54, 49, 49, 32, 102, 111, 117, 110, 100, 46, 10, 211, 91, 0] indicating that the byte 17 (0x11) is missing from the sequence. This seems to always be the case and 17 (0x11) is always left out no matter where it is in the array.

Example Code:

void setup() {
    Serial.begin(115200);

    uint8_t data[] = {0x01, 0x01, 0x11, 0x4D, 0x53, 0x35, 0x36, 0x31, 0x31, 0x20, 0x66, 0x6F, 0x75, 0x6E, 0x64, 0x2E, 0x0A, 0xD3, 0x5B};
    for (unsigned char i : data) {
        Serial.write(i);
    }
    Serial.write(0);
}

void loop() {}

Additional Information:

hmeijdam commented 7 months ago

Check with a better terminal emulator. When I run your sketch and print it to HTerm I get the characters exactly as you describe

image

Sandvoxel commented 7 months ago

My mistake this was caused by the ftdi chip being in Xon Xoff mode causing the missing bytes