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

Using Printf statement for both serial ports

Hello All,

I am using MSC1212Y5 Microcontroller. It has two serial ports. I have directed printf to second serial port by changing putchar.c file in keil library. At the same time I am using first port for transmitting single characters only. i.e. 'T' ..'R'..etc. But whenever i try to use printf for both ports, of course by disabling one port for some time then it is not working..it sends data to only second serial port.

Parents
  • If you want to use both USARTs alternatingly, then you will have to add a software mux layer.

    You may create a new function:
    switch_to_usart(port);

    This could affect a global variable used by your modified putchar() to decide if the data should be put into one or the other USART, or - if you use interrupt-based transmission - which transmit buffer to put the data in.

    Basically the switch_to_usart(port) would redirect "stdout" to different hardware.

Reply
  • If you want to use both USARTs alternatingly, then you will have to add a software mux layer.

    You may create a new function:
    switch_to_usart(port);

    This could affect a global variable used by your modified putchar() to decide if the data should be put into one or the other USART, or - if you use interrupt-based transmission - which transmit buffer to put the data in.

    Basically the switch_to_usart(port) would redirect "stdout" to different hardware.

Children