This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Printf() size, questions?

How many bytes will printf() take up in a non debug-monitor
environment?

Also, is it easy to set up printf() to map to a second UART?
I will need control of the UART ISR so that I can handle receives
appropriately. How will this confict with printf()?

Parents Reply Children
  • I'd write my own putchar() like this:

    char putchar(char outChar)
    {
        TI   = 0;
        SBUF = outChar;
        while (!TI);
        return outChar;
    }
    And the escaped version would escape any control chars like STX or DLE with DLE, which stands for Data Link Escape.
    void putFiltByte(U8 outByte)
    {
        if (STX == outByte || DLE == outByte)
        {
            // Escape this data char.
            putchar(DLE);
    
            // Ensure this data char. is never an STX or DLE.
            outByte += ' ';
        }
    
        putchar(outByte);
    }
    Now, on the receive end, when ever you see an STX you know it means Start of Transmission (of a new packet). And when ever you see a DLE you know to subtract ' ' (space) from the next char received.

    - Mark