LoginSignup
0
0

More than 1 year has passed since last update.

STM32G031J6M6用の俺の考えた最強の「hello...」(PA_2シリアル出力)(mbed-os)(STM32)

Last updated at Posted at 2022-08-18

x 超超重要 なぜか秋月STM32G031J6M6がうり切れていた。注意!!(2022/8/27現在)

x 過去ログを見よ
x PA_2をOBでGPIOに出来る人むけ
x STM32G031は、秋月で売っているSTM32G031J6M6の事

目的
シリアルのテスト
mbed-osのシリアルをソースを見ていたら
PA_2,PA_3が有効なので作ってみた。

o_con683.jpg

o_con684.jpg

o_con685.jpg

o_con686.jpg

o_con687.jpg




//ser_test_1_031_1

#include "mbed.h"

//シリアルの定義
UnbufferedSerial serial_port(PA_2, PA_3); //031

//メイン関数
int main()
{

    //シリアルの初期化
    serial_port.baud(9600);
    serial_port.format(
        /* bits */ 8,
        /* parity */ SerialBase::None,
        /* stop bit */ 1
    );

    char data_read[256];  //バッファー

    //無限ループ
    while(1) {

        //文字列の表示
        //                 12345678901
        serial_port.write("hello world\r\n", 11+2);

        //数値の表示
        sprintf( data_read, "%d\r\n", 1234 );
        serial_port.write(data_read, 4+2);

        //1秒待つ
        wait_us(1000*1000);

    } //while

} //main




0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0