Source code is the same as stm32f407.
I used this board.
This board is called a pyboard.
Pin out is here.
GPIO is irregular, but you can use it in the Arduino environment.
This board does not have PA11/PA12 pin headers.
You definitely need to remap.
CAN1_RX mapped to PB8 , CAN1_TX mapped to PB9 (not available on 36-pin package)
CAN2_RX mapped to PB12, CAN2_TX mapped to PB13(not available on 36-pin package)
CANInit(CAN_1000KBPS, 2); // CAN_RX mapped to PB8, CAN_TX mapped to PB9
The following GPIOs can be used as STLINK.
STLINK | GPIO | MARK |
---|---|---|
SWDIO | PA13 | P5 |
SDCLK | PA14 | P4 |
STM32F405 can use a Virtual COM port.
If you enable Virtual COM port, you can use the USB port as a serial port.
Basic Extended CAN(BxCan) and Virtual COM port can be used at the same time.
USB port can be used for power supply.
Do not supply power from both the USB port and the ST-LINK module.
The output destination of Serial.print differs depending on the Board Part Number.
- genericSTM32F405RG:PA0
You need to check variant_generic.h for your board.
https://github.com/stm32duino/Arduino_Core_STM32/blob/main/variants/STM32F4xx/
git clone https://github.com/nopnop2002/Arduino-STM32-CAN
cd Arduino-STM32-CAN/stm32f407
pio init --board genericSTM32F405RG
cp _platformio.ini platformio.ini
cp stm32f407.ino src/
# Without Virtual COM port
pio run -t upload -e genericSTM32F405RG
# With Virtual COM port
pio run -t upload -e genericSTM32F405RG_usbcon