Using printf for MCS08

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

Using printf for MCS08

跳至解决方案
1,052 次查看
pawankumar
Contributor III

Hi Friends,

 

I would like to know how to use the stdio.h Header file and use the printf function in my code.

 

I am using Codewarrior 10.6 to program a MC9S08DZ60 controller.

 

I am successful in making my own sendstr function and communicating with the PC.

 

Your Suggestions will help me.

 

Thanks,

Pawan

标签 (1)
1 解答
914 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

hi Pawan,

printf() is not possible since there is NO "standard output" in embedded system in CW for 8bit MCU. User has to implement their own "pseudo" prinf() function, i.e. to format the output in memory and then print out through SCI.

I made the sample code on QG8.  In sample code, baud rate=4800. you need open a SCI HyperTerminal on your PC to see the output of the sample code printf. Of cause a SCI cable is needed to connect both PC and QG8 board SCI ports.

it was developed under QG8, but the method is exact same for MC9S08DZ60.

For other related information about this issue, HI-WAVE supports a command FPRINTF which can be used in that case. FPRINTF is the standard ANSI C command: Writes formatted output string to a file. Syntax is pretty similar to ANSI C fprintf.

You can have a command as follows:

fprintf (test.txt,"%s %2d","The value of the counter is:",counter)

can this help you?


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

3 回复数
915 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

hi Pawan,

printf() is not possible since there is NO "standard output" in embedded system in CW for 8bit MCU. User has to implement their own "pseudo" prinf() function, i.e. to format the output in memory and then print out through SCI.

I made the sample code on QG8.  In sample code, baud rate=4800. you need open a SCI HyperTerminal on your PC to see the output of the sample code printf. Of cause a SCI cable is needed to connect both PC and QG8 board SCI ports.

it was developed under QG8, but the method is exact same for MC9S08DZ60.

For other related information about this issue, HI-WAVE supports a command FPRINTF which can be used in that case. FPRINTF is the standard ANSI C command: Writes formatted output string to a file. Syntax is pretty similar to ANSI C fprintf.

You can have a command as follows:

fprintf (test.txt,"%s %2d","The value of the counter is:",counter)

can this help you?


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

914 次查看
pawankumar
Contributor III

Dear Zhang Jun,

Thanks a lot!! This is exactly what I needed. I saw your code. I will implement this for me and let you know.

Appreciate your swift response.

Update: I used the functions and configured for 9600 BAUD. It works for me. Kudos!

Pawan

0 项奖励
回复
914 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

you are welcome!


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复