x 動作確認済み2022/5/28 20:16
x OBでPA0をGPIOにするがわかる人むけ
x 場合によっては、二度と書き込めなくなります。
目的
動くかどうかわからないがやってみる
結果動いた
答え合わせ
Serial.setTx(PA2_ALT1);
//Serial.setTx(PA14);
//Serial.setTx(PB6);
Serial.setHalfDuplex();
Serial.begin(9600);
8
PB6 USART1_TX
PA14 USART2_TX
PA15 USART2_RX
1
PB7 USART1_RX
4
PA2 USART2_TX
PA2 LPUART_TX
名前は、まだない
STM32G031-DISCO
Enabled(generic Serial)
Serial1.begin(9600); OK?->NG
Serial2.begin(9600); NG
SerialLP1.begin(9600); NG
Enabled(no generic Serial)
Serial1.begin(9600); NG
Serial2.begin(9600); NG
SerialLP1.begin(9600); NG
Disabled(no Serial support)
Serial1.begin(9600); NG
Serial2.begin(9600); NG
SerialLP1.begin(9600); NG
Nucleo G031K8
Enabled(generic Serial)
Serial1.begin(9600); NG
Serial2.begin(9600); NG
SerialLP1.begin(9600); OK?->NG
Enabled(no generic Serial)
Serial1.begin(9600); NG
Serial2.begin(9600); NG
SerialLP1.begin(9600); NG
Disabled(no Serial support)
Serial1.begin(9600); NG
Serial2.begin(9600); NG
SerialLP1.begin(9600); NG
検証プログラム
//SER_PA_2_test_031_2
#include <Arduino.h>
#include <HardwareSerial.h>
//初期化
void setup() {
delay(3000); //not Delete
//extern HardwareSerial Serial;
//Serial.setTx(PA2);
//Serial.setRx(PA2);
//Serial.setHalfDuplex();
//Serial.begin(9600);
//while(1){Serial.println("0");delay(2000);}
//extern HardwareSerial Serial1;
//Serial1.setTx(PA2);
//Serial1.setRx(PA2);
//Serial1.setHalfDuplex();
//Serial1.begin(9600);
//while(1){Serial1.println("0");delay(2000);}
//extern HardwareSerial Serial2;
//Serial2.setTx(PA2);
//Serial2.setRx(PA2);
//Serial2.setHalfDuplex();
//Serial2.begin(9600);
//while(1){Serial2.println('0');delay(2000);}
//extern HardwareSerial SerialLP1;
SerialLP1.setTx(PA2);
SerialLP1.setRx(PA2);
SerialLP1.setHalfDuplex();
SerialLP1.begin(9600);
while(1){SerialLP1.println('0');delay(2000);}
}//setup
//メインループ
void loop(){
}//loop
(ちょとだけ前進)
PA14に注目
//SER_HalfDuplex_test_031_2
#include <Arduino.h>
#include <HardwareSerial.h>
//初期化
void setup() {
Serial.setTx(PA14);
//Serial.setTx(PB6);
Serial.setHalfDuplex();
Serial.begin(9600);
pinMode(PB7, OUTPUT);
}//setup
//メインループ
void loop() {
Serial.println("Hello World");
digitalWrite(PB7, HIGH);
delay(1000);
digitalWrite(PB7, LOW);
delay(1000);
}//loop
(完成) PA2からハローワールドの出力
//SER_HalfDuplex_test_031_2
#include <Arduino.h>
#include <HardwareSerial.h>
//初期化
void setup() {
delay(3000);
Serial.setTx(PA2_ALT1);
//Serial.setTx(PA14);
//Serial.setTx(PB6);
Serial.setHalfDuplex();
Serial.begin(9600);
pinMode(PB7, OUTPUT);
}//setup
//メインループ
void loop() {
Serial.println("Hello World");
digitalWrite(PB7, HIGH);
delay(1000);
digitalWrite(PB7, LOW);
delay(1000);
}//loop