printf At CodeWarrior HC12

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

printf At CodeWarrior HC12

跳至解决方案
4,587 次查看
codewarrier
Contributor I
I tried to use printf function  The compilation succed but the Linking at debug stage fail.
Does anyone has  working example ?
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,877 次查看
vectorio
Contributor II
Of course printf() is useful indeed in microcontroller systems, and you surely don't need a file system for it. I use it a lot for terminal output to a serial port on SCI0. To make it work, it's necessary to implement a function called "void TERMIO_PutChar(char ch)" (must not be declared static, of course). Have a look at the file embedded.c (provided by Codewarrior).

Furthermore, if you use printf in banked memory model, be sure you allocate the STRINGS in non banked ROM, it won't work otherwise.

Let me know if you have problems.

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,877 次查看
CrasyCat
Specialist III

Hello

In fact we do not deliver implementation of file management function in our CodeWarrior for HC12 tool.

Extract from the Compiler manual:

"In microcontroller applications however, one usually does not need file I/O. In the few cases where one would need it, the implementation depends on the actual setup of the target system.
It is therefore impossible for Freescale to provide an implementation for these features that the user has to specifically implement."

Basically usage of file I/O functions would require a file system to be available on the target system. Not sure this is ever possible on a HC12 CPU.

Why do you want to use file I/O?

CrasyCat

0 项奖励
回复
1,878 次查看
vectorio
Contributor II
Of course printf() is useful indeed in microcontroller systems, and you surely don't need a file system for it. I use it a lot for terminal output to a serial port on SCI0. To make it work, it's necessary to implement a function called "void TERMIO_PutChar(char ch)" (must not be declared static, of course). Have a look at the file embedded.c (provided by Codewarrior).

Furthermore, if you use printf in banked memory model, be sure you allocate the STRINGS in non banked ROM, it won't work otherwise.

Let me know if you have problems.
0 项奖励
回复
1,877 次查看
CrasyCat
Specialist III
Oups
apologies guy. I did read fprintf instead of printf in the original post.
 
Was probable not really woken up :smileysad:
 
vectorio is completely right here.
 
CrasyCat
0 项奖励
回复