Arduino Uno R4 WiFi in Higher Education

Arduino recently introduced revision 4 of the classic UNO microcontroller which includes the Arduino UNO R4 Minima and WiFi, as pictured in Figure 1. Both feature the 32-bit Renesas RA4M1 Arm Cortex M4 processor, which significantly expands the capabilities when compared to the previous 8-bit ATMega328p. The additional horsepower, peripherals, and a Hardware Abstraction Layer (HAL) expand the range and depth of experiments that may be conducted with the UNO.

As always, the UNO R4 is backwards compatible with the previous generation. Therefore, it has the potential to maintain the UNO’s role as de facto standard for high school projects, 2-year electronics technicians/technologists, mechanical engineers, and electrical engineers up to about their second year of study. We can leverage 15 years’ worth of education material and the tremendous legacy left by the open-source community.

This engineering brief provides an exploration of the possibilities of the RA4M1-equipped UNO. It suggests a path forward for advanced technologists, computer science students interested in embedded technology, and electrical engineering students in advanced microcontroller classes.

Figure 1: Side-by-side image of the Arduino UNO R4 Minima (left) and WiFi (right).

Tech Tip: The DigiKey Application Engineering (AE) division occasionally receives questions asking for assistance in selecting the “best” microcontroller or FPGA for the lab environment. It’s not an easy question for a first-time instructor or graduate student as there are many things to consider including your student’s prior experience, equipment cost, availability of education materials, and responsiveness of the larger support community. Please consider the content of this article as you make your decision.

Will the Arduino UNO R4 replace the Arduino UNO R3?

The new R4 is slightly less capable when it comes to sinking and sourcing current. The original ATmega328p was able to handle up to 40 mA per pin with a total combined current of about 200 mA. The R7FA4M1AB3CFM#AA0 is limited to 8 mA per pin with a total combined current of about 60 mA. While this is not a significant change, you will need to evaluate your designs to prevent damage to the microcontroller.

For this reason alone, I suspect the UNO R3 with its robust I/O will be available for a long time into the future. We can safely state that tens or perhaps hundreds of millions of ATmega328p have been manufactured in the last two decades. Going one step further, the ATmega328p has likely crossed into the category of a jellybean part. Based on these observations, we can reasonably assume that the yeoman 8-bit device will be with us for another decade or two.

On a related note, the “Arduino UNO R3” is not a single source product. For example, the original functionality and form factor are captured in products such as the DFRobot FFR0216. These products, along with a multitude of “mini” form factor devices will ensure continued availability of R3-like devices.

Backwards hardware compatibility of the Arduino UNO R4 Minima and WiFi

The original UNO was designed with expansion in mind to accommodate a range of shields. This form factor remains popular today with “Arduino shield compatible” devices from other microcontroller and even FPGA manufacturers.

The UNO R4 is no exception. It retains the original form factor, allowing your shields to be reused. The R4 is also a 5 VDC device, allowing familiar shields and hardware to be used provided we account for the current.

Backwards software compatibility of the Arduino UNO R4 Minima and WiFi

Software compatibility between products is certainly one of the reasons for Arduino’s success. This Arduino Hardware Abstraction Layer (HAL) ensures that a statement such as digitalWrite(D13, HIGH) operates on every member of the Arduino family. This Arduino UNO R4 Minima and WiFi continue this tradition. This fact ensures that basic functionality is maintained.

There may be exceptions, especially when we consider code that was designed for a specific microcontroller. An example of this non-portable code is the Fast PWM technique used to increase the performance of the Pulse Width Modulator (PWM) on the ATmega328p. As explained in the linked article, this hardware specific technique must be changed to accommodate the new microcontroller. However, the fast PWM is not part of the Arduino HAL. In contrast, the analogWrite( ) function will operate across all Arduino members as it is part of the HAL.

Hardware features worthy of advanced study

The Arduino R5 WiFi equipped with its 32-bit Renesas RA4M1 provides many opportunities for advanced study. This is a partial list of items you may wish to study in your 3rd and 4th year electrical engineering and computer science classes.

RA4M1 Hardware

The RA4M1 is a modern 32-bit general-purpose microcontroller. Consequently, it features a rich set of hardware peripherals to match the 48 MHz Arm Cortex M4 core. This is captured in the Datasheet’s block diagram included as Figure 2. See datasheet page 1 for additional information. You can refer to the Renesas RA4M1 Group User’s Manual: Hardware for a complete description.

Suffice to say, the RA4M1 as installed on the Arduino UNO R4 Minima and WiFi, is a capable modern microcontroller. It provides ample opportunity to explore advanced microcontroller concepts. For example, consider how your students could explore the Nested Vectored Interrupt Controller (NVIC) or the Direct Memory Access Controller (DMAC) to meet real-time constraints.

Figure 2: Block diagram of the RA4M1 microcontroller as shown in the RA4M1 Group datasheet.

Renesas Hardware Abstraction Layer

The increased complexity of the 32-bit microcontroller, coupled with the increased pressure to reduce time to market, has changed the way programmers think about microcontrollers.

In the past, embedded programmers were very good at interpreting the datasheet. This allowed them to configure the hardware by setting bits in the associated Special Function Registers (SFR). This is a tedious process. While it can provide good performance it is costly in terms of time and lack of portability. Today it is increasingly common for programmers to use a Hardware Description Language (HAL) to configure the SFR.

The Arduino language is an example of a high-level easy-to-use HAL. However, it may be too generalized for higher education purposes. As an alternative, Renesas provides the Flexible Software Package (FSP). This HAL is a step closer to the hardware providing “efficient drivers that meet common use cases in embedded systems.” The FSP is described in a 5519-page document. A detailed description is beyond the scope of this article. However, Figure 3 provides a good preview by exploring a motor control application.

Relationship between Arduino HAL and the FSP HAL

The Arduino HAL appears to be built on top of the FSP HAL – an abstraction layer built on an abstraction layer. Consequently, the FSP HAL is accessible directly from the Arduino IDE. This allows code such listing 1 this to be included in your Arduino sketch.

Pedagogical advantages of combining the Arduino HAL and the FSP HAL

This ability to slide in and out of the FSP facilitates a flexible learning environment. It allows you to selectively focus on the important hardware aspects, while using familiar supporting Arduino structures. This can be advantageous when we consider the limited lab time. Some programmers would go a step further and state that this flexibility is key to quickly developing a functional prototype or even a finalized product to market.

#define ROW_0 BSP_IO_PORT_02_PIN_05
#define ROW_1 BSP_IO_PORT_00_PIN_12
void setup() {
  ;
}

void loop() {
  R_IOPORT_PinCfg(NULL, ROW_0, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
  R_IOPORT_PinCfg(NULL, ROW_1, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
  R_IOPORT_PinWrite(&g_ioport_ctrl, ROW_0, BSP_IO_LEVEL_HIGH);
  R_IOPORT_PinWrite(&g_ioport_ctrl, ROW_1, BSP_IO_LEVEL_LOW);
}

Listing 1: Example Arduino sketch featuring the Renesas FSP HAL elements.

Figure 3: Block diagram of an induction motor application from the Renesas FSP User’s Manual V5.4.0.

Software and system level aspects worthy of advanced study

The computational power of the RA4M1 opens several new areas of exploration. Perhaps the greatest higher education microcontroller challenge involves meeting real-time constraints. This is a complex undertaking that “lives” at the hardware and software level.

Real-time processing at a hardware level

The previously mentioned NVIC and DMAC are essential elements for meeting the fast microsecond-level events. These could be considered reflexive – akin to the autonomic nervous system. The ARM NVIC provides a hierarchical interrupt response to handle the most important events first. The DMAC may be used to offload select processor-intensive tasks to intelligent peripherals.

Real-time processing at the software level

The RA4M1 and associated FSP were developed with real-time OS including FreeRTOS and Azure RTOS (ThreadX). The Renesas FSP literature includes examples supporting both OSs. This can be beneficial as your students move from the Arduino HAL to the FSP HAL to the high-level OS.

Edge (IoT) computing

The Arduino UNO R4 WiFi is equipped with a WiFi/Bluetooth transceiver. This capability adds yet another educational opportunity as your students can explore Internet of Things (IoT) and edge computing. Your experiments are well supported with the real-time OS running on top of the ARM Cortex M4 with access to capable peripherals.

Conclusion

The R4 Minima and WiFi are the newest editions to Arduino’s line of classic UNO form factor devices. It preserves many of the hardware and software features of the earlier UNO devices. At the same time, the Renesas RA4M1 provides new educational opportunities applicable to advanced electrical engineering students. They are free to explore advanced peripherals using FSP, middle ground such as the NVIC and DMAC, and upper levels with a real-time OS leading to higher level IoT applications.

Best wishes,

APDahlen

Helpful links

Follow these links for related and useful information:

About this author

Aaron Dahlen, LCDR USCG (Ret.), serves as an application engineer at DigiKey. He has a unique electronics and automation foundation built over a 27-year military career as a technician and engineer which was further enhanced by 12 years of teaching (partially interwoven with military experience). With an MSEE degree from Minnesota State University, Mankato, Dahlen has taught in an ABET-accredited EE program, served as the program coordinator for an EET program, and taught component-level repair to military electronics technicians. Dahlen has returned to his Northern Minnesota home and thoroughly enjoys researching and writing educational articles about electronics and automation.

Highlighted experience

Dahlen is an active contributor to the DigiKey TechForum. At the time of this writing, he has created over 170 unique posts and provided an additional 570 forum posts. Dahlen shares his insights on a wide variety of topics including microcontrollers, FPGA programming in Verilog, and a large body of work on industrial controls.

A collection of Dahlen’s Arduino educational articles can be found at Arduino education content.