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.
I want to use the both USARTS for with printf statement.
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.
I didn't get you.Please tell in detail. Actually I have modified the file Putchar.c which is used by Printf directly to the RI_1 and TI_1..Does this make problem??
You have to modify putchar() to do:
if (output == UART1) { ... } else { ... }
and you have to switch output to specify UART1 or UART2 depending on which serial port that should get the data from printf().
Each individual branch has to make use of the registers for that specific UART.