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
解決済! 解決策の投稿を見る。
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!
-----------------------------------------------------------------------------------------------------------------------
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!
-----------------------------------------------------------------------------------------------------------------------
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
you are welcome!
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------