LoginSignup
0
0

More than 3 years have passed since last update.

NUCLEO-L476RGでmicropythonを動かす

Last updated at Posted at 2019-06-09

手順

環境はWindows10を利用しました。
基本的には、@boochowpさんのこちらのページを参照しながら手順通りに進めればできました。

  1. 前記のページからファームウェアupy-l476disco.zipをダウンロード
  2. ボードとPCをUSBケーブルで接続するとボードがSTLink Virtual COM Portとして認識される。
    もし認識しない場合は、STMのホームページからDriverをDownloadする。(Win10はインストール不要のようです)
  3. ボードのフォルダに解凍したファーム(.bin)をドラッグ&ドロップするとソフトが書き込まれる。
  4. Tera Termを立ち上げて、シリアルポートを選択接続し、設定を115200bps, 8bit ,パリティ無しに設定する。
  5. 下記のコマンドを入力するとボードのLEDのON/OFFができる。
>>> import pyb
>>> pyb.LED(1).on()
>>> pyb.LED(1).off()

IMG_0693.jpg
緑のランプをON/OFFできました。

  • 四則演算もできます。
>>> 1+2*3.14/2098-900
-898.997
  • Ctrl+Dでリブートされました。
>>>
PYB: sync filesystems
PYB: soft reboot
MicroPython v1.9.4-691-g4f25a8b-dirty on 2018-12-02; NUCLEO-L476RG with STM32L476RG
Type "help()" for more information.
>>>
  • help()で簡易マニュアルが表示されました。
>>> help()
Welcome to MicroPython!

For online help please visit http://micropython.org/help/.

Quick overview of commands for the board:
  pyb.info()    -- print some general information
  pyb.delay(n)  -- wait for n milliseconds
  pyb.millis()  -- get number of milliseconds since hard reset
  pyb.Switch()  -- create a switch object
                   Switch methods: (), callback(f)
  pyb.LED(n)    -- create an LED object for LED n (n=1,2,3,4)
                   LED methods: on(), off(), toggle(), intensity(<n>)
  pyb.Pin(pin)  -- get a pin, eg pyb.Pin('X1')
  pyb.Pin(pin, m, [p]) -- get a pin and configure it for IO mode m, pull mode p
                   Pin methods: init(..), value([v]), high(), low()
  pyb.ExtInt(pin, m, p, callback) -- create an external interrupt object
  pyb.ADC(pin)  -- make an analog object from a pin
                   ADC methods: read(), read_timed(buf, freq)
  pyb.DAC(port) -- make a DAC object
                   DAC methods: triangle(freq), write(n), write_timed(buf, freq)
  pyb.RTC()     -- make an RTC object; methods: datetime([val])
  pyb.rng()     -- get a 30-bit hardware random number
  pyb.Servo(n)  -- create Servo object for servo n (n=1,2,3,4)
                   Servo methods: calibration(..), angle([x, [t]]), speed([x, [t]])
  pyb.Accel()   -- create an Accelerometer object
                   Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()

Pins are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name
Pin IO modes are: pyb.Pin.IN, pyb.Pin.OUT_PP, pyb.Pin.OUT_OD
Pin pull modes are: pyb.Pin.PULL_NONE, pyb.Pin.PULL_UP, pyb.Pin.PULL_DOWN
Additional serial bus objects: pyb.I2C(n), pyb.SPI(n), pyb.UART(n)

Control commands:
  CTRL-A        -- on a blank line, enter raw REPL mode
  CTRL-B        -- on a blank line, enter normal REPL mode
  CTRL-C        -- interrupt a running program
  CTRL-D        -- on a blank line, do a soft reset of the board
  CTRL-E        -- on a blank line, enter paste mode

For further help on a specific object, type help(obj)
For a list of available modules, type help('modules')
>>>
  • Ctrl +E 貼り付けモードになります。貼り付けた後、Ctrl+Dで貼り付けモードを終了します。
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== def foo():
===     print('This is a test to show paste mode')
===     print('Here is a second line')
=== foo()
===
This is a test to show paste mode
Here is a second line
>>>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0