SCI port and printf()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SCI port and printf()

跳至解决方案
5,987 次查看
gautier
Contributor II
Hello,
 
I use codewarrior to program a MC9S12 and I use the software stationnery.
 
The exemple for communicate with a hyperterminal running correctly.(SerialCommProject_DP256.mcp)
 
But it's run with the SCI0 port and I want to use the SCI1 port of the microcontroller.
 
 
I don't understand what modification must be execute to use printf() function on the SCI1 port.
 
Can you help me to solve this problem??
 
Thanks for your answers.
 
 
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,031 次查看
CrasyCat
Specialist III
Hello
 
Low level PutChar & GetChar functions are implemented in file termio.c, which is located in your {Install}\lib\hc12c\src directory.
To use SCI1 as stdout, you have to create a new source file (termio_SCI1 for example) where you implement the TERMIO_PutChar, TERMIO_GetChar and TERMIO_Init for SCI1.
 
Then just add your own terminal io file (termio_SCI1.c in your project and remove Termio.c.
 
This should do it.
 
CrasyCat

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,031 次查看
gautier
Contributor II
thanks for your answer, I will try to do that, but Do you think the twice SCI port can be active in the same time??
0 项奖励
回复
1,031 次查看
CrasyCat
Specialist III
Hello
 
No you have to decide if you want to use SCI0 or SCI1 as stdout.
Only 1 stdout can be used at a given time.
 
Also once the application is running, there is no library function allowing you to
switch easily to another stdout.
 
Now if you want to have the same output on both SCI port, just change the code to send the same character to both port. SCI0 first and then SCI1.
 
For reading this might be more complicated. I am even not sure it can work.
I hope this helps. 
 
CrasyCat
0 项奖励
回复
1,031 次查看
gautier
Contributor II

Okay it's what I have just discover with an anlyse of termio.C

But I think it's possible to use SCI0 with termio and SCI1 with others functions using sprintf() or to put the text in a buffer and after ussing this buffer to put on SCI1 port.

 

Do you thinks this is a solution is hardly to realise ???????

 

0 项奖励
回复
1,031 次查看
CrasyCat
Specialist III
No this is fine too and should be working.
Just you cannot use printf for both port.
 
You can use printf for one and then some separate function to write to the other port.
 
CrasyCat
0 项奖励
回复
1,032 次查看
CrasyCat
Specialist III
Hello
 
Low level PutChar & GetChar functions are implemented in file termio.c, which is located in your {Install}\lib\hc12c\src directory.
To use SCI1 as stdout, you have to create a new source file (termio_SCI1 for example) where you implement the TERMIO_PutChar, TERMIO_GetChar and TERMIO_Init for SCI1.
 
Then just add your own terminal io file (termio_SCI1.c in your project and remove Termio.c.
 
This should do it.
 
CrasyCat
0 项奖励
回复