Try   HackMD

[STM32] [Mbed] 開發環境

開啟IDE

  • 網路搜尋mbed,進入mbed官方網站
    https://www.mbed.com/zh-cn/

  • mbed官網提供線上的IDE,但需要有mbed帳號才可使用。尚未擁有帳號的同學,請註冊一份並登錄。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • 登錄帳號後,點擊帳戶icon左邊的「Complier」黃色方塊,進入mbed的線上IDE。

選擇要被燒錄的裝置型號

  1. 點擊IDE右上角的「No Device selected」,

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 點擊「Add Board」

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 搜尋列上打你手上板子的型號NUCLEO-F207ZG,搜尋後點擊搜尋結果的NUCLEO-F207ZG圖示。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  1. 點擊頁面右方的「Add to your Mbed compiler」,匯入到IDE。回到IDE,再次選擇裝置NUCLEO-F207ZG,設定完成。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • 另外在第4步驟的頁面,可以查看Board的型號、規格、Pinout等。之後再編程的時候,可在這裡查詢Pin腳的位置與代號。

新增專案(New Program)

  • 點擊IDE左上角的「NEW」;或者在「My Program」右鍵

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 開啟選單後,點擊「New Program」

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 確定Platform無誤後,Template選「Empty Program」,然後決定你的Program名稱吧。

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

    platform:板子型號(IDE通常會幫你填上)
    Template:一些範例專案與空白專案
    Program Name:專案名稱

新增檔案(New File)

  • 對Program右鍵開啟選單,點擊「New File」

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 決定File的名稱 (名稱後面加上.cpp才能按下OK)

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 一個Program內只能有一個File.cpp

匯入函式庫(Import Library)

  • 在你的Program右鍵開啟選單,點選「Import Library」,IDE會幫你切換到搜尋Library的畫面。
  1. 在搜尋列打上要匯入的Library名稱,搜尋。
  2. 下方會出現搜尋結果,點選你要的Library。
  3. 按下「Import」。
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →
  • 匯入成功後,可以在Program Workspace看到Library了
  • 匯入mbed library後,在cpp文件中打上 #include "mbed.h",便能開始撰寫mbed程式了。
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

燒錄(Compile and Setup)

  • 測試用程式碼
#include "mbed.h"

int main()
{
    printf("Hello My Darkness Friend");
}
  • 程式碼完成後,點擊上方的「Compile」,如果沒有報錯的話,IDE會給你程式轉換後的二進位檔(.bin)的下載連結。

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 將下載後的二進位檔,丟入到裝置內(跟你放東西到隨身碟一樣)

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 程式燒入過程中,Board的LD4 LED會發彩虹光,等待變綠燈代表燒錄完畢。(板子不同可能就不是LD4)


Tera Term安裝(Mac電腦則安裝Screen coolterm minicom)

  1. 電腦沒「ST-Link」驅動程式則需要填寫信箱獲得下載連結,下載安裝驅動程式後重新開機。(沒安裝Tera Term無法獲得STM32板子的printf訊息)

  2. 下載並安裝tera term後,開啟tera term,點選Serial,選擇連接Board的COM。(不清楚哪個COM,可以在"你的作業系統/控制台/裝置管理員/連接阜查看")

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 如果沒安裝ST-Link驅動程式,會看不到COM的名稱
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

成功畫面 (゚∀゚)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →