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

ASC0 & ASC1 simultaneously using with PRINTF

I want to use PRINTF function to send different data to ASC0 and ASC1 simultaneosly. If i change _getkey and putchar in LIB for ASC1, so PRINTF will send data to ASC1. How to write new PRINTF_1 for ASC1 while using PRINTF from stdio.h with ASC0?

Parents
  • If you can guarantee that in your application printf for ASC0 and ASC1 will not be called simultaneously (no reentrancy for printf), then you can do a simple trick:

    /* define a global flag somewhere */
    bit asc_to_use = 0;
    
    char putchar(char c)
    {
        switch ( asc_to_use )
        {
        case 0:
            /* send byte using ASC0 */
            break;
        case 1:
            /* send byte using ASC1 */
        }
    }
    
    then assign required asc_to_use channel before each call to printf.

    - mike

Reply
  • If you can guarantee that in your application printf for ASC0 and ASC1 will not be called simultaneously (no reentrancy for printf), then you can do a simple trick:

    /* define a global flag somewhere */
    bit asc_to_use = 0;
    
    char putchar(char c)
    {
        switch ( asc_to_use )
        {
        case 0:
            /* send byte using ASC0 */
            break;
        case 1:
            /* send byte using ASC1 */
        }
    }
    
    then assign required asc_to_use channel before each call to printf.

    - mike

Children