RS232 output always follow with an extra 0x0b

fpgars232

I have downloaded the minsoc from opencores and it comes with a microprocessor along with a rs232 cores. I have configure all the toolchains and download the design on my FPGA.

I run a simple program that adds 1 to whatever the rs232 receives and send it back to computer. So I can see the letters I type being sent back to the computer. But there is always a trailing byte 0x0b whenever I send something.

e.g. If I send A, I will get A0x0b.
If I send AAAA, I will get AAAA0x0b.

Then I write a C program to run on the processor as below.

  while (1){  //endless looping
    //send 16 bytes from computer
    for(i = 0; i < 16; i++) {
        //save the received byte to an array of 16 bytes
        B[i] = uart_getc();

        //pass array value to the AES core
        //this is an IO module using memory map.
        REG8(AES_BASE + AES_DR) = B[i];
    }

    //send the received 16 bytes back to computer
    for(i = 0; i < 16; i++) {
        uart_putc(B[i]);
    }

After programming the FPGA, if I send the first 16 bytes, I will get all the bytes back. But when I send the second 16 bytes, it will insert some extra characters 0x0a 0x0b.
e.g. If I send 3333333333333333, I will receive 0xa0xb3333333333333333

When I send the third 16 bytes (also 3333333333333333), I will receive 30xa0xb333333333333333. And this pattern keeps going as I send the next 16 bytes, 330xa0xb333333333333333…and so on. The 0x0a0x0b keep shifting to the latter bytes.

What are the possible reasons for this?

Best Answer

Are you sure it's 0x0B? If it was 0x0A or 0x0D that would just mean you're appending a newline/carriage-return somewhere in the MCU's code (I would look at whether the printf you're using does this automatically).

As it is, 0x0B is the ASCII VT (vertical tab) character. This really smells like something is appending a trailing "end of line"/"end of serial buffer" flag character somewhere.

Assuming this is reliably and predictably appended at the end of every set of writes to the serial port, you may be able to just treat it as a bonus "end-of-packet" flag for your serial interface.

Considering the behaviour you are seeing, I would look into how the serial interface is implemented. It's also possible that whatever software you are using to send serial data to the MCU, your serial terminal (or other software) is appending the trailing character.

Have you put a logic analyser or DSO on the serial lines, to confirm the 0x0B is indeed coming from the MCU in the FPGA?

Also, do you have the ability to add standard digital-IO on the MCU? If you do, you could write a small bit-bang serial routine, to localize whether the 0x0b is being appended in the serial receive or serial transmit section of the MCU.


We won't be able to give much more advice without knowing the specifics of your setup.
What toolchain/FPGA soft-core/FPGA-type are you using?