x プルアップ抵抗を忘れずに10kΩがおすすめ
x 過去ログを見よ->
x cubeMXは、disco-g0316
x VSCoedは、nucleo-g031
x 4ピンは、リセットを解除してGPIOにする
x シリアルの速度は、中途半端な209700bps
x SWDは、気持ち設定した。
目的
I2Cスレーブのテスト
参考
I2C_SLAVE_TEST1_031_1内を適当にコピー
main内のwhile内
uint8_t aRxBuffer[1] = {0};
char *str1 = 0;
//aRxBuffer[0] = 0 ;
if(HAL_I2C_Slave_Receive(&hi2c2,(uint8_t*)aRxBuffer, 1, 1000) == HAL_OK) {
str1="OK\r\n";
} else {
str1="NG\r\n";
}
//ステータスの表示
HAL_UART_Transmit(&hlpuart1, (uint8_t *)str1, 4, 10);
//I2Cスレーブの受信データの表示
HAL_UART_Transmit(&hlpuart1, (uint8_t *)"\tRead A: ", 9, 10);
uint8_t n1 = '0' + (aRxBuffer[0] % 10);
uint8_t n10 = '0' + (aRxBuffer[0] / 10);
HAL_UART_Transmit(&hlpuart1, &n10, 1, 10);
HAL_UART_Transmit(&hlpuart1, &n1, 1, 10);
HAL_UART_Transmit(&hlpuart1, (uint8_t *)"\r\n", 2, 10);
HAL_Delay(200);//0.2秒待つ
I2C内
hi2c2.Init.OwnAddress1 = 0x80;