欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 用bascom-avr調試arduino板 [打印本頁]

作者: wu111111mi    時間: 2021-5-2 23:56
標題: 用bascom-avr調試arduino板
bascom-avr語句簡潔易學,部分語句兼容VB、excel的VBA函數,部分程序可以參考移植學習。
下面用bascom-avr調試arduino板
一、
1、編譯
用bascom-avr打開實例inkey.bas,程序共18行,按F7編譯。


程序運行過程:串口接收一個字節變量A,通過串口輸出接收的字符和對應的ASCII碼,接著判斷其是否是十進制27=十六進制1B=鍵盤ESC的ASCII碼,如果不是則繼續接收和輸出串口變量A,如果是27則串口輸出ASCII碼,進入只接收27后終止接收程序。(共接收3次27結束程序)
2、仿真
編譯后按F2進入仿真見面,按F5仿真運行,在串口窗口輸入字符,程序運行相應結果

3、選擇寫固件軟件


4、設置寫固件軟件


5、寫固件


6、串口測試


源程序如下:
  1. '------------BASCOM-AVR串口inkey實例----------------------------------------------
  2. 'name                     : inkey.bas
  3. 'copyright                : (c) 1995-2020, MCS Electronics
  4. 'purpose                  : demo: INKEY , WAITKEY
  5. 'micro                    : Mega328p
  6. 'suited for demo          : yes
  7. 'commercial addon needed  : no
  8. '----------------初始化硬件配置--使用arduino開發板-------------------------------------------------------------

  9. $regfile = "m328pdef.dat"                                     'atmega328p硬件
  10. $crystal = 16000000                                          ' 16MHZ時鐘
  11. $baud = 19200                                               ' 串口波特率
  12. $hwstack = 32                                               ' default use 32 for the hardware stack
  13. $swstack = 10                                               ' default use 10 for the SW stack
  14. $framesize = 40                                             ' default use 40 for the frame space
  15. '-----------------變量定義---------------------------------------------------------------
  16. Dim A As Byte , S As String * 2
  17. '-----程序運行----串口接收一個字節變量A,通過串口輸出接收的字符和對應的ASCII碼,接著判斷其是否是十進制27=十六進制1B=鍵盤ESC的ASCII碼,如果不是則繼續接收和輸出串口變量A,如果是27則串口輸出ASCII碼,進入只接收27后終止接收程序。(共接收3次27結束串口接收程序)
  18. Do
  19.    A = Inkey()                                              '從串口獲得ASCII變量’get ascii value from serial port
  20.    's = Inkey()
  21.    If A > 0 Then
  22.       '------循環判斷如果大于0則輸出字符和對應的ASCII碼,如果是27則停止循環接收-----------------------------------------------------------------------                                             'we got something
  23.       Print Chr(a);" ASCII code " ; A ; " from serial"
  24.    End If
  25. Loop Until A = 27                                           '是27則停止循環接收(直到按下ESC)

  26. A = Waitkey()                                               '等待接收到字符
  27. 's = waitkey()
  28. Print Chr(a)                                                '串口輸出字符

  29. 'wait until ESC is pressed
  30. Do                          ' 循環接收=27則結束程序
  31. Loop Until Inkey() = 27

  32. 'When you need to receive binary data and the bibary value 0 ,
  33. 'you can use the IScharwaiting() function.
  34. 'This will return 1 when there is a char waiting and 0 if there is no char waiting.
  35. 'You can get the char with inkey or waitkey then.
  36. '-----------------程序結束-----------------------------------------------------------------
  37. End
復制代碼

全部資料51hei下載地址:
inkey源程序.rar (1.13 KB, 下載次數: 7)





歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1