Community Translation - Using the printf Function in PSoC® 3 - KBA83472

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

cross mob
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi,               

I would like to translate KBA83472 into Japanese.

Please confirm to my work.

Thanks,

Kenshow

0 Likes
2 Replies
JennaJo
Moderator
Moderator
Moderator
1000 replies posted 750 replies posted 500 replies posted

Hi, Kenshow-san

Confirm to work this KBA.

Thanks

Jenna

Jenna Jo
0 Likes
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi Jenna-san,

                                

Japanese translation was over.
Please check below.

Original KBA:

Using the printf Function in PSoC® 3 - KBA83472

Thanks.

Kenshow

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

タイトル: PSoC®3でのprintf関数の使用 - KBA83472

バージョン:*B

質問:

stdio.hprintf関数を使用してPSoC®3デバイスのUARTにデータを送信するにはどうすればよいでしょうか?

回答:

Keilprintf関数はputchar()を呼び出して文字を送信しますが、デフォルトのputchar()PSoC®3にはないUARTベースの特殊機能レジスタ(SFR)を使用します。したがって、printfを使用するには、プログラムでKeilの組み込みputchar関数をオーバーライドする必要があります。

たとえば、「UART」がプロジェクトのUARTコンポーネントのインスタンス名である場合、main.cファイルに次の関数を記述して、Keilの組み込みputchar関数をオーバーライドします。

char putchar(char c) {         UART_WriteTxData((uint8)c);         return c; }

次に、printfを使用して次の方法でUART経由でデータを送信できます(適切に実行するには、printf()関数を最初に呼び出す前にputchar()関数を定義または宣言する必要があります)。

int main()
{
        UART_Start();
        while(1)
        {
            printf(“Hello world”); // uses the new putchar() function to stream data over UART
            while(!(UART_ReadTxStatus() & UART_TX_STS_COMPLETE)); // wait until transfer is complete
        }
}

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

28-August-2020

  Kenshow

0 Likes