Community Translation - Alternate printf Function for PSoC® 4 - KBA87093

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I'd like to translate KBA87093

moto

Original KBA: KBA87093

Alternate printf Function for PSoC® 4 - KBA87093

Translated by: MoTa_728816

=============================

タイトル:PSoC® 4 の printf の代替関数 - KBA87093

ヴァージョン: *B

質問:

PSoC® 4 では printf 関数はかなりのフラッシュメモリ容量を使用します。printf の代替となる関数は無いのですか?

回答:

printf 関数はツールチェーン (ARM® GCC)で提供されています。代替としては、このKBで紹介している iprintf() 関数を使用してください。この関数は printf 関数で使用頻度の高い機能を最適化されたコードで実装しています。

iprintf() 関数は下記の書式指定子しかサポートしていません。

表 1. iprintf() の書式指定子

%schar の配列
%d整数の10進数書式
%cchar 1文字
%x整数の16進数書式

以下の手順でコードをテストしてください:

1. “Design01”という名称のプロジェクトを作成します。

2. iprintf.zip をダウンロードして展開します。iprintf.c と iprintf.h を “Design01.cydsn” フォルダにコピーします。

3. iprintf.c と iprintf.h をプロジェクトに追加します。

4. ステップ 6 で示されるように main.c ファイルに #include "iprintf.h" という行を追加します。

5. 回路に SCBベースの UART コンポーネントを追加して必要に応じてパラメータを設定してください。コンポーネント名は “SCB_1” としてください。もし他の名称を使用したい場合には、iprintf.c ファイルにある iputc()  関数内の SCB_1_UartPutChar(ch) という関数コールを修正してください。

001-183066.jpg

ソフトウェア UART コンポーネント (SW_Tx_UART) をインスタンス名を SW_Tx_UART_ 1 で使用される場合には、iputc() 関数内で関数

SW_Tx_UART_1_PutChar() をお使いください。

6. main() 関数の中で下記のコードで示されるように iprintf() 関数をコールしてください。このコードは連続的に “abcd” という文字列と増加していく数字を、10進数書式、アスキー、16進数書式で表示します。

002-1.png

=============================

30-Apr-2020

moto

0 Likes
1 Reply
JennaJo
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hello, Tanaka-san

We receive your translation, it will be published to KBA to Community.

After upload, You will receive the points as the word of KBA.

Due to the current delay of processed work, Please bear with me for the delayed the response.

It could be delayed, but it will be processed soon.

Thanks for your contribution to CDC!

Will keep you update the status.

Thanks,

Jenna Jo

Jenna Jo
0 Likes