Using printf for MCS08

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Using printf for MCS08

ソリューションへジャンプ
1,040件の閲覧回数
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 解決策
902件の閲覧回数
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 返答(返信)
903件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------

902件の閲覧回数
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 件の賞賛
返信
902件の閲覧回数
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 件の賞賛
返信