Below is a quick reference for the Renesas RA boards. If it is your first time
working with this board, it may be useful to get an overview of the microcontroller and the board:
..toctree::
:maxdepth:1
general.rst
tutorial/index.rst
Installing MicroPython
----------------------
See the corresponding section of tutorial: :ref:`renesas-ra_intro`. It also includes a troubleshooting subsection.
General board control
---------------------
The MicroPython REPL is accessed via the USB serial port. Tab-completion is useful to find out what methods an object has. Paste mode (ctrl-E) is useful to paste a large slab of Python code into the REPL. Some of features are not implemented for Renesas RA boards yet, please refer to the tutorial for more details.
The :mod:`machine` module::
import machine
machine.freq() # get the current frequency of the CPU
Following functions are supported::
machine.freq()
machine.reset()
machine.soft_reset()
machine.unique_id()
Following functions are not supported at the present::
start = time.ticks_ms() # get value of millisecond counter
delta = time.ticks_diff(time.ticks_ms(), start) # compute time difference
Timers
------
The RA MCU's system timer peripheral provides a global microsecond timebase and generates interrupts for it. The software timer is available currently and there are unlimited number of them (memory permitting). There is no need to specify the timer id (id=-1 is supported at the moment) as it will default to this.
p5 = Pin('P005', Pin.OUT, value=1) # set pin high on creation
Pin id is available corresponding to the RA MCU's pin name which are Pin.cpu.P106 and 'P106'. The RA MCU has many feature's pins. However, there are some cases that pin feature is fixed or not connected by the board. Please confirm the board manual for the pin mapping.
Following functions are not supported at the present::
UART.init(baudrate) # now only 115200 is confirmed
UART.init(cts, rts) # Pins are fixed.
UART.init(invert)
UART.init(tx,rx) # Pins are fixed.
UART.init(txbuf)
UART.init(flow)
UART.irq(handler)
UART.irq(trigger=RX_ANY)
UART.irq(priority)
UART.irq(wake=machine.IDLE)
Real time clock (RTC)
---------------------
See :ref:`machine.RTC <machine.RTC>` ::
from machine import RTC
rtc = RTC()
rtc.datetime((2017, 8, 23, 1, 12, 48, 0, 0)) # set a specific date and time
# time, eg 2017/8/23 1:12:48
rtc.datetime() # get date and time
Following functions are not supported at the present::
RTC.init(datetime)
RTC.now()
RTC.deinit()
RTC.alarm()
RTC.alarm_left()
RTC.cancel()
RTC.irq()
ADC (analog to digital conversion)
----------------------------------
See :ref:`machine.ADC <machine.ADC>` ::
from machine import ADC
adc = ADC('P000') # create an ADC object acting on a pin
adc.read_u16() # read a raw analog value in the range 0-65535
Pin id is available corresponding to the RA MCU's pin name which are 'P000' as AN000 (analog channel 000). The RA MCU has many analog channels. However, there are some cases that pin feature is fixed or not available by the board. Please confirm the MCU and board manual for the pin mapping.
Following functions are not supported at the present::
ADC.init()
ADC(sample_ns)
ADC(atten)
ADC.read_uv()
ADC.block()
SPI bus
-------
The RA MCU has some hardware SPIs (Serial Peripheral Interface).
SPI id is available corresponding to the RA MCU's SPI number which are SPI(0) as SPI0 and SPI(1) as SPI1. If with no additional parameters, machine.SoftSPI() is called.
See :ref:`machine.SPI <machine.SPI>`. ::
from machine import SPI, Pin
spi = SPI(0, baudrate=500000)
cs = Pin.cpu.P103
cs(0)
spi.write(b"12345678")
cs(1)
Available SPIs and pins on the board are fixed and follows.
============= ====
EK-RA4M1 SPI0
============= ====
sck P102
mosi P101
miso P100
cs P206
============= ====
============= ====
EK-RA4W1 SPI0
============= ====
sck P102
mosi P101
miso P100
cs P103
============= ====
============= ====
EK-RA6M1 SPI0
============= ====
sck P102
mosi P101
miso P100
cs P103
============= ====
============= ==== ====
EK-RA6M2 SPI0 SPI1
============= ==== ====
sck P102 P702
mosi P101 P701
miso P100 P700
cs P103 P703
============= ==== ====
============= ====
RA4M1-CLICKER SPI0
============= ====
sck P102
mosi P101
miso P100
cs P103
============= ====
Following functions are not supported at the present::
SPI.init(firstbit) # now fixed with SPI.LSB
SPI.init(baudrate) # now confirmed only 500000
I2C bus
-------
The RA MCU has some hardware IIC (Inter-Integrated Circuit Bus).
I2C id is available corresponding to the RA MCU's I2C number which are I2C(0) as IIC0 and I2C(1) as IIC1. If with no additional parameters, machine.SoftI2C() is called.