0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

DISCO-F746NG探索套件讓擴(kuò)展能力大幅提升

jf_cVC5iyAO ? 來源:易心Microbit編程 ? 作者:易心Microbit編程 ? 2022-11-03 15:07 ? 次閱讀

筆者最近取得一個(gè)有趣的套件,是國內(nèi)開發(fā)者不陌生的STM32系列之一的IoT開發(fā)工具包- STM32F746G-DISCOVERY(DISCO-F746NG)探索套件。它的功能相當(dāng)完整,其運(yùn)算核心是基于 Arm Cortex-M7 的 STM32F746NG微控制器,具備強(qiáng)大的運(yùn)算能力。它同時(shí)整合了4.3吋的彩色電容式觸控屏幕、USB OTG、Audio Codec、Micro SD 插槽、雙數(shù)字麥克風(fēng),也內(nèi)建以太網(wǎng)絡(luò)10/100Mb來延伸網(wǎng)絡(luò)應(yīng)用,從而簡化應(yīng)用程序的開發(fā),能快速驗(yàn)證產(chǎn)品與想法。

繼承STM32的優(yōu)良傳統(tǒng),此套件也支持易于開發(fā)的Arduino IDE環(huán)境,讓原本使用Arduino的Maker可以快速上手,更可以直接使用兼容于Arduino開源函式庫,共享相關(guān)社群的開發(fā)資源。不僅如此,這個(gè)套件提供兼容于ARDUINO Uno V3的擴(kuò)充插槽,讓擴(kuò)展能力大幅提升。

2c639666-58f4-11ed-a3b6-dac502259ad0.png

本開發(fā)板引出的GPIO如下圖:

2cb07080-58f4-11ed-a3b6-dac502259ad0.png

Arduino 開發(fā)環(huán)境安裝

看到這樣強(qiáng)大的功能與完善的支持接口,你是不是和筆者一樣躍躍欲試了呢?別急,先把Arduino開發(fā)環(huán)境安裝起來吧。

(1) 請先下載Arduino IDE開發(fā)環(huán)境

https://www.arduino.cc/en/software

2d851394-58f4-11ed-a3b6-dac502259ad0.png

(2) 為Arduino IDE安裝STM32的支持,從Github下載最新的版本,解壓縮至

C:Program Files (x86)Arduinohardware

https://github.com/fw-box/STM32GENERIC

(注:這個(gè)路徑依照你的Arduino安裝路徑可能略有不同)

2dc02b1e-58f4-11ed-a3b6-dac502259ad0.png

(3) 安裝編譯程序arm-none-eabi-gcc,從開發(fā)板管理員搜尋并安裝Arduino SAMD Boards (32-bits Arm Cortex-M0+) 版本1.8.11

2ddc1de2-58f4-11ed-a3b6-dac502259ad0.png

(4) 編譯STM32GENERIC時(shí)會有錯(cuò)誤,請使用patch檔覆寫arm-none-eabi-gcc里的原始碼,共有4個(gè)檔會被覆寫。

Patch文件下載路徑:

https://github.com/fw-box/arm-none-eabi

解壓縮并覆寫到

C:UsersmynameAppDataLocalArduino15packagesarduino oolsarm-none-eabi-gcc7-2017q4arm-none-eabi

(注:myname要改成你的使用者名稱)

(5) 下載下列4個(gè)必需的函式庫并解壓縮至

C:UsersmynameDocumentsArduinolibraries

(注:myname要改成你的使用者名稱)

https://github.com/adafruit/Adafruit-GFX-Library

https://github.com/fw-box/Adafruit_BusIO

https://github.com/stm32duino/LwIP

https://github.com/fw-box/STM32Ethernet

下載方法如下圖,下載下來會是一個(gè)壓縮文件。解壓縮一個(gè)新的函式庫至libraries后,需要重新啟動Arduino IDE來掃描加載新的函式庫。

2e03d440-58f4-11ed-a3b6-dac502259ad0.png

2e39a552-58f4-11ed-a3b6-dac502259ad0.png

下載并安裝開發(fā)板的驅(qū)動程序

請到ST官網(wǎng)介紹此套件的「工具與軟件」區(qū),找到ST-LINK驅(qū)動程序,

https://www.st.com/zh/evaluation-tools/32f746gdiscovery.html?fbclid=IwAR2Kjh0Qf59IpkKOTpz7iNKo6AX13nPNFPWxFGhgnGSilr07reN2-XJTyZU#tools-software

按下下圖紅框內(nèi)的連結(jié)后會跳出注冊畫面,注冊后www.st.com會發(fā)送下載的網(wǎng)址到注冊信箱。下載后解壓縮,并以系統(tǒng)管理員身份執(zhí)行stlink_winusb_install.bat安裝驅(qū)動程序。

2e5d01a0-58f4-11ed-a3b6-dac502259ad0.png

編譯刻錄設(shè)定

選擇開發(fā)板Discovery F746NG;Upload method改成Mass Storage:

2e80ef7a-58f4-11ed-a3b6-dac502259ad0.png

開始上傳(刻錄)前,請用mini USB線連接PC與開發(fā)板的USB ST-LINK。然后把串行端口改成新出現(xiàn)的COM port,上圖的范例是COM20。

程序范例

安裝好了,我們來執(zhí)行幾個(gè)程序范例吧。

1. 數(shù)位GPIO read, write

這功能與一般Arduino模式一樣,按鈕USER_BTN是背面的藍(lán)色按鈕,可供用戶自定義功能。

LED_BUILTIN在黑色按鈕旁邊,范例程序運(yùn)作后會開始閃爍,按下藍(lán)色按鈕后閃爍速度會變快。

1. void setup()

2. {

3. pinMode(USER_BTN, INPUT);

4. pinMode(LED_BUILTIN, OUTPUT);

5. }

6.

7. void loop()

8. {

9. digitalWrite( LED_BUILTIN , HIGH ); // led on

10.

11. if ( digitalRead( USER_BTN ) )

12. delay(10); // blink faster if button is pressed

13. else

14. delay(100);

15.

16. digitalWrite( LED_BUILTIN, LOW ); // led off

17. delay(100);

18. }

程序代碼來源 : UserButton.ino

https://github.com/danieleff/STM32GENERIC/blob/master/STM32/libraries/BoardExamples/examples/Discovery746NG/UserButton/UserButton.ino

2. ADC讀取

此套件ADC的分辨率最高為12 bits,數(shù)值范圍是0 ~ 4096。為保持與Arduino UNO的兼容性,A0 ~ A5皆有被定義,可以直接使用。程序代碼中P開頭的GPIO名是為本開發(fā)板所定義,A0可以用PA0取代、A1可以用PF10取代,其它GPIO對應(yīng)如程序代碼所示。此范例會不斷地把A0讀到的數(shù)值寫到串行端口,請開啟串行端口監(jiān)控窗口查看結(jié)果。

// thesetup routine runs once when you press reset:

2. void setup() {

3. // initialize serial communication at115200 bits per second:

4. Serial.begin(115200);

5. delay(1000);

6.

7. // configure the ADC for 12 Bits

8. analogReadResolution(12);

9.

10. Serial.println();

11. Serial.printf("PA0:%d, A0:%d ",PA0, A0);

12. Serial.printf("PF10:%d, A1:%d ",PF10, A1);

13. Serial.printf("PF9:%d, A2:%d ",PF9, A2);

14. Serial.printf("PF8:%d, A3:%d ",PF8, A3);

15. Serial.printf("PF7:%d, A4:%d ",PF7, A4);

16. Serial.printf("PF6:%d, A5:%d ",PF6, A5);

17. }

18.

19. //the loop routine runs over and over again forever:

20. voidloop() {

21. // read the input on analog pin 0:

22. int sensorValue = analogRead(PA0);

23. // print out the value you read:

24. Serial.printf("PA0=%d ",sensorValue);

25. delay(1000); // delay in between reads forstability

26. }

程序代碼來源 : AnalogtReadSerial_12bit.ino

https://github.com/danieleff/STM32GENERIC/blob/master/STM32/libraries/BoardExamples/examples/Discovery746NG/AnalogtReadSerial_12bit/AnalogtReadSerial_12bit.ino

3. 使用SDRAM

DISCO-F746NG擁有8MB(64 Mbits)可用的SDRAM,但系統(tǒng)會用掉一些,所以無法完整配置8MB內(nèi)存。下列程序代碼是配置7MB的內(nèi)存的范例。

1. voidsetup()

2. {

3. Serial.begin(115200);

4. }

5. void loop()

6. {

7. uint32_t size = 7 * 1024 * 1024; // 7MB

8. Serial.printf("Allocating %dbuffer ", size);

9.

10. uint8_t *data = (uint8_t*)malloc(size);

11. if (data == NULL)

12. Serial.println("Mallocfailed!");

13. else

14. Serial.println("Success");

15.

16. free(data);

17. delay(5000);

18. }

I2C存取

請把I2C模塊的SCL、SDA接至下面的腳位– I2C1_SCL、I2C1_SDA,記得模塊的3V3、GND也要接上。

2ea1c57e-58f4-11ed-a3b6-dac502259ad0.png

以下程序會掃描出模塊的I2C地址。請注意在呼叫Wire.begin();之前要先呼叫Wire.stm32SetInstance(I2C1); Wire.stm32SetSDA(PB9);Wire.stm32SetSCL(PB8); 來設(shè)定I2C連接的腳位,因?yàn)镈ISCO-F746NG擁有4組I2C(I2C1 ~ I2C4),對應(yīng)到Arduino UNO擴(kuò)充插槽I2C腳位的是I2C1。

#include

2.

3. void setup()

4. {

5. Wire.stm32SetInstance(I2C1);

6. Wire.stm32SetSDA(PB9);

7. Wire.stm32SetSCL(PB8);

8. Wire.begin();

9.

10. Serial.begin(115200);

11. delay(5000);

12. Serial.println(" I2C Scanner");

13. }

14.

15. voidloop()

16. {

17. byte error, address;

18. int nDevices;

19.

20. Serial.println("Scanning...");

21. delay(2000);

22.

23. nDevices = 0;

24. for (address = 1; address < 127;address++ ) {

25. // The i2c_scanner uses the return valueof

26. // the Write.endTransmisstion to see if

27. // a device did acknowledge to theaddress.

28. Wire.beginTransmission(address);

29. Wire.write(0);

30. error = Wire.endTransmission();

31.

32. if (error == 0) {

33. Serial.print("I2C device found ataddress 0x");

34. if (address < 16) Serial.print("0");

35. Serial.print(address, HEX);

36. Serial.println(" !");

37. nDevices++;

38. }

39. else if (error == 4) {

40. Serial.print("no device found ataddress 0x");

41. if (address < 16)Serial.print("0");

42. Serial.println(address, HEX);

43. }

44. }

45. if (nDevices == 0) {

46. Serial.println("No I2C devicesfound ");

47. Serial.println("Did you configure thechip select for your device? ");

48. }

49. else

50. Serial.println("done ");

51.

52. delay(5000); // wait 5 seconds for next scan

53. }

程序代碼修改自 : I2cScanner.ino

https://github.com/danieleff/STM32GENERIC/blob/master/STM32/libraries/BoardExamples/examples/all_boards/I2cScanner/I2cScanner.ino

繪圖與觸控屏幕

觸控IC接在I2C3的位置,所以要先做I2C的初始化。因?yàn)槠年P(guān)系,僅列出主程序,請從Github取得stm32_ub_touch_480x272.h與stm32_ub_touch_480x272.cpp,與主程序放在同一個(gè)目錄。

https://github.com/danieleff/STM32GENERIC/tree/master/STM32/libraries/BoardExamples/examples/Discovery746NG/TFT/TouchDisplay

1. #include

2. #include "stm32_ub_touch_480x272.h"http:// 觸控屏幕

3. #include "LTDC_F746_Discovery.h" //繪圖

4.

5. LTDC_F746_Discovery tft;

6.

7. uint8_t UB_I2C3_ReadByte(uint8_taddressI2cDevice, uint8_t registerId)

8. {

9. uint8_t result;

10. addressI2cDevice = addressI2cDevice>> 1;

11.

12. Wire.beginTransmission(addressI2cDevice );

13. Wire.write( registerId );

14. uint8_t error;

15. error = Wire.endTransmission();

16.

17. Wire.requestFrom( addressI2cDevice,(uint8_t) 1 , (uint8_t) true );

18.

19. while ( Wire.available() < 1 );

20.

21. result = Wire.read() ;

22.

23. if (error)Serial.println("I2Cerror");

24.

25. return result;

26. }

27.

28. voidsetup()

29. {

30. Serial.begin(115200);

31. delay(1000);

32.

33. Wire.stm32SetInstance(I2C3);

34. Wire.stm32SetSDA(PH8);

35. Wire.stm32SetSCL(PH7);

36.

37. Wire.begin();

38.

39. UB_Touch_Init();

40.

41. // The buffer is memory mapped

42. // You can directly draw on the display bywriting to the buffer

43. uint16_t *buffer = (uint16_t*)malloc(2*LTDC_F746_ROKOTECH.width * LTDC_F746_ROKOTECH.height);

44.

45. tft.begin((uint16_t *)buffer);

46. tft.fillScreen(LTDC_WHITE);

47. }

48.

49. voidloop()

50. {

51. UB_Touch_Read();

52.

53. int x = Touch_Data.xp;

54. int y = Touch_Data.yp;

55.

56. Serial.printf("(%d, %d) ", x, y);

57. tft.fillCircle(x, y, 3, LTDC_BLUE);

58.

59. delay(10);

60. }

程序代碼修改自 : TouchDisplay.ino

https://github.com/danieleff/STM32GENERIC/blob/master/STM32/libraries/BoardExamples/examples/Discovery746NG/TFT/TouchDisplay/TouchDisplay.ino

程序執(zhí)行畫面,用手指在觸控屏幕上畫圖,類似小畫家的效果。

2ef3f65a-58f4-11ed-a3b6-dac502259ad0.png

透過Ethernet連接至因特網(wǎng)

以下是一個(gè)使用HTTP GET聯(lián)機(jī)至http://example.com的范例,執(zhí)行后會把Server的響應(yīng)顯示在串行端口監(jiān)控窗口。

1. #include

2. #include

3.

4. EthernetClient client;

5.

6. // random MAC address

7. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE,0xED };

8.

9. void setup() {

10. Serial.begin(115200);

11.

12. Serial.println("Connecting toEthernet");

13.

14. if (!Ethernet.begin(mac)) {

15. Serial.println("ERROR: Could notconnect to ethernet!");

16. while(1);

17. }

18.

19. Serial.println("Connecting toexample.com");

20.

21. if (!client.connect("example.com",80)) {

22. Serial.println("ERROR: Could notconnect to example.com!");

23. while(1);

24. }

25.

26. Serial.println("Connected, sendingrequest");

27.

28. client.println("GET /HTTP/1.1");

29. client.println("Host:example.com");

30. client.println();

31. client.flush();

32.

33. Serial.println("Request sent,printing response");

34. }

35.

36. voidloop() {

37. if (client.available()) {

38. char c = client.read();

39. Serial.print(c);

40. }

41.

42. if (!client.connected()) {

43. Serial.println();

44.Serial.println("disconnecting.");

45. client.stop();

46. while (1);

47. }

48. }

更多范例

可以從以下位置找到更多范例:

Arduino ID選單的檔案=>范例=>DiscoveryF746NG的范例

2f2d0c9c-58f4-11ed-a3b6-dac502259ad0.png

結(jié)語

DISCO-F746NG使用Arm架構(gòu)的M7微控制器,效能強(qiáng)大,運(yùn)作起來相當(dāng)流暢,而且本身已經(jīng)具備彩色觸控屏幕、Audio、麥克風(fēng)與Ethernet,不用再另外接模塊。筆者測試過其觸控定位功能,相當(dāng)精準(zhǔn)且反應(yīng)快速,很適合擔(dān)任顯示與人機(jī)互動的主機(jī)。再加上它支持易入門的Arduino IDE,開發(fā)者可在網(wǎng)絡(luò)上找到很多參考數(shù)據(jù),不怕碰到問題時(shí)搜尋不到解決方法。

看完本文的介紹,你是不是發(fā)現(xiàn)這個(gè)套件相當(dāng)適合來實(shí)現(xiàn)你心中「某個(gè)」創(chuàng)意的原型設(shè)計(jì)呢?

審核編輯:彭靜
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • 微控制器
    +關(guān)注

    關(guān)注

    48

    文章

    7334

    瀏覽量

    150088
  • 以太網(wǎng)
    +關(guān)注

    關(guān)注

    40

    文章

    5287

    瀏覽量

    169635
  • Arduino
    +關(guān)注

    關(guān)注

    187

    文章

    6453

    瀏覽量

    185915
  • 套件
    +關(guān)注

    關(guān)注

    0

    文章

    20

    瀏覽量

    18025

原文標(biāo)題:上手DISCO-F746NG探索套件,Arduino也兼容!

文章出處:【微信號:易心Microbit編程,微信公眾號:易心Microbit編程】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏

    評論

    相關(guān)推薦

    stm32f746g-disco顯示白屏的原因有哪些?

    你好,請問,我買了一塊藍(lán)色的stm32f746g開發(fā)板,前面序號是STM32F746G-DISCO DK32F746G$CU2,后面序號是MB1191-F746-C01。 上電可以正常
    發(fā)表于 03-12 07:14

    轉(zhuǎn):將STM32F746G-Disco開發(fā)板做助聽器

    ;AUDIO_DISCO_F746NG.h"#include "SDRAM_DISCO_F746NG.h"AUDIO_DISCO_F746NG audio;// audio
    發(fā)表于 07-11 17:57

    STM32F746Disco開發(fā)板的MicroPython固件

    STM32F746Disco是2015年最熱的開發(fā)板之一,Cotex-M7內(nèi)核加上大液晶屏,做各種演示效果很棒。下面是STM32F746Disco開發(fā)板的最新MicroPython固件,使用STM32 ST-LINK Utility將固件下載到開發(fā)板就可以運(yùn)行。
    發(fā)表于 09-27 11:17

    STM32F411E-DISCO,STM32F411系列探索套件

    STM32F411E-DISCO,STM32F411系列探索套件可幫助您發(fā)現(xiàn)STM32 F4系列的入門級微控制器,并輕松開發(fā)您的應(yīng)用。它為初
    發(fā)表于 04-19 06:19

    STM32F746G-DISCO是什么

    STM32F746G-DISCO是ST公司推出的一款針對STM32F7系列設(shè)計(jì)的開發(fā)板??蓭椭焖?b class='flag-5'>探索ARM?Cortex?-M7,并輕松開發(fā)自己的應(yīng)用。STM32F746G-DISCO
    發(fā)表于 08-04 07:28

    stm32f746ng如何入門

    stm32f746ng如何入門
    發(fā)表于 10-13 08:52

    STM32F746G-DISCO有何功能

    STM32F746G-DISCO是什么?STM32F746G-DISCO有何功能?
    發(fā)表于 10-14 09:47

    如何對STM32F746G-DISCO進(jìn)行燒寫

    如何對STM32F746G-DISCO進(jìn)行燒寫?燒寫步驟有哪些?
    發(fā)表于 10-14 06:56

    STM32F746G DISCO如何斷電記憶數(shù)據(jù)?

    STM32F746G DISCO如何斷電記憶數(shù)據(jù)?
    發(fā)表于 01-11 07:40

    Discovery_kit_for_STM32F7_Series_with_STM32F746NG_MCU

    The STM32F746G-DISCO discovery board (32F746GDISCOVERY) is a complete demonstration
    發(fā)表于 01-22 15:53 ?12次下載

    微雪電子32F746GDISCOVERY STM32F7開發(fā)板簡介

    STM32F746G-DISCO STM32F746NGH6開發(fā)板 評估板 板載ST-LINK/V2 支持仿真調(diào)試 型號 STM32F746G-DISCO
    的頭像 發(fā)表于 12-26 15:51 ?4067次閱讀
    微雪電子32<b class='flag-5'>F746</b>GDISCOVERY STM32<b class='flag-5'>F</b>7開發(fā)板簡介

    基于STM32F746G-DISCO微控制器的參考設(shè)計(jì)

    View the reference design for STM32F746G-DISCO. http://www.ttokpm.com/soft/ has thousands of reference designs to help bring your project to life.
    發(fā)表于 07-10 11:42 ?10次下載
    基于STM32<b class='flag-5'>F746G-DISCO</b>微控制器的參考設(shè)計(jì)

    UM1907_基于STM32F746NG的STM32F7系列探索套件

    UM1907_基于STM32F746NG的STM32F7系列探索套件
    發(fā)表于 11-22 08:22 ?2次下載
    UM1907_基于STM32<b class='flag-5'>F746NG</b>的STM32<b class='flag-5'>F</b>7系列<b class='flag-5'>探索</b><b class='flag-5'>套件</b>

    UM1902_基于STM32F746NG微控制器的評估板

    UM1902_基于STM32F746NG微控制器的評估板
    發(fā)表于 11-22 08:22 ?0次下載
    UM1902_基于STM32<b class='flag-5'>F746NG</b>微控制器的評估板

    UM1969_STM32F746G探索套件軟件開發(fā)工具入門指南

    UM1969_STM32F746G探索套件軟件開發(fā)工具入門指南
    發(fā)表于 11-22 19:08 ?0次下載
    UM1969_STM32<b class='flag-5'>F746</b>G<b class='flag-5'>探索</b><b class='flag-5'>套件</b>軟件開發(fā)工具入門指南