原文請參考http://grauonline.de/wordpress/?page_id=1004
STM32F103C8T6使用Arduino IDE 進行UART通訊成果 |
1.請依照下面的電路圖進行串接
在這邊要注意一點,就是電源要接上,要不然無法使用!!
將這個資料夾解壓縮後會得到‘Arduino_STM32-master’這個資料夾,並將這個資料夾的內容放到你的Arduino硬體資料夾 (C:\Programs\Arduino\hardware).
4. 打開 Arduino IDE, 可以看到在板子的選項中可以選擇:
‘Board: Generic STM32F103C series‘
‘Variant: STM32F103C8 (20k RAM, 64k Flash)’
‘Upload method: Serial‘
‘Port: <the COM port of your USB-to-serial adapter>’
‘Board: Generic STM32F103C series‘
‘Variant: STM32F103C8 (20k RAM, 64k Flash)’
‘Upload method: Serial‘
‘Port: <the COM port of your USB-to-serial adapter>’
5. Compile this sketch:
#define pinLED PC13
void setup() {
Serial.begin(9600);
pinMode(pinLED, OUTPUT);
Serial.println("START");
}
void loop() {
digitalWrite(pinLED, HIGH);
delay(1000);
digitalWrite(pinLED, LOW);
Serial.println("Hello World");
}
然後就會開始啟動。二、多埠連結
既然STM32F103C8T6有三個USART埠,要如何啟動呢?
對於初始狀態而言,A9,A10(板子上可看到的IO)是初始USB對電腦的(TX,RX)
這個答案請參考下列
http://wiki.stm32duino.com/index.php?title=API#Serial_.26_USB_Serial
我把內容貼出來
Serial & USB Serial
Serial USB is enabled for all F103 boards when uploading using the bootloader, it is also available when uploading by ST-Link (SWD)
In these cases:
- Serial.print("Hello world"); will print via Serial USB (CDC).
- Serial1 prints to hardware USART 1
- Serial2 prints to hardware USART 2
- etc
換句話說若是要使用USART1,就打Serial1,要使用USART2,就打Serail2
沒有留言:
張貼留言