As we prepare for the ST Developers Conference 2018 on September 5 in Santa Clara, California, and as students get ready to go back to school, we are launching a new series of blog posts showing what universities do with our products and technologies to prepare the next generation of engineers. By seeing what’s possible and what others are doing to further innovation, we hope that those who can attend our conference will be emboldened with new ideas and look for precise solutions, while those who can’t come will be inspired to work on new and exciting projects. To start this new series of blog posts, we’ll take a deep dive into the course “Embedded Systems with ARM Cortex-M Microcontrollers in Assembly Language and C” taught at the University of Maine by Professor Yifeng Zhu who uses a 32L476GDISCOVERY, a 32L152CDISCOVERY, and a STM32F4DISCOVERY as foundational pedagogical tools.
This course acts as a fantastic addition to the online curriculum on SensorTile that is currently gaining ground in many universities, and that is leading students to create impressive projects that have the potential to shake many disciplines. Indeed, Introduction to Embedded Systems with SensorTile doesn’t assume any knowledge of C while giving students a tremendous foundation. On the other hand, the course by Professor Zhu builds on top of these introductory concepts to go beyond the basics and prepare engineers to standout and solve problems that only a few can. Those that can’t attend his lecture can still grab his textbook and experience some of the labs on his website. There’s also a YouTube channel that will cover some of the concepts and help students walk through some of the most critical aspects of the course.
A course on embedded systems in assembly language may seem counterintuitive to some if we look at the current trends. A ranking of the most popular programming languages by sites like Redmonk don’t even list this low-level paradigm in their top 20 and assembly is in the vicinity of Fortran or F#. Why should the language still matter to developers working on embedded systems? As Professor Zhu explained:
“Developers still have to use assembly when they are performing manual implementations of functions that don’t have a C equivalent or when working on the kernel, and there’s just no way around it. Students and professionals also get a much better in-depth understanding of embedded systems. ST does provide very nice Hardware Level Abstraction layers, which greatly facilitate the use of USB or Bluetooth classes for instance. However, we want engineering students to understand what’s going on behind-the-scene.
Assembly on STM32: The Secret Weapon of Machine Learning Application
The new Eldorado that represents Artificial Intelligence is also giving a new purpose to assembly languages on embedded systems, especially in the case of Machine Learning. Indeed, new sensors with integrated decision trees are coming, and System-on-Chips with a neural network are already on their way. Professor William Kaiser at UCLA recently shared how embedded systems like SensorTile could help train applications and feed engineers with data for years. However, as Professor Zhu explained, computational power and memory resources are quite limited on these platforms. Hence, low-level programming languages offer the efficiency and optimizations to ensure teams can use learning and inference algorithms while balancing the need for performance and the inherent limitations of embedded systems.
Many modern frameworks and libraries make Machine Learning very accessible. However, the nature of embedded systems will often demand that developers make specific and complex adjustments to fit a particular microcontroller (MCU) or edge case. For instance, engineers might want to change a library to use a different type of operations to adapt to a specific architecture and save resources, especially if the loss of precision is not that important for the task at hand. Similarly, they may want to change the code to take advantage of specific SIMD instructions (Single Instruction Multiple Data) that can significantly accelerate computations. This means that to really enjoy groundbreaking innovation, developers must sometimes tweak libraries at a really low-level and assembly can be a secret weapon in the race for the next revolution.
Reverse Engineering ST
The lecture and textbook of Professor Zhu are also fascinating because they approach this subject matter from an unexpected angle. It’s clear that the goal of the class is to teach the use of assembly on embedded systems. However, instead of just diving into the low-level programming language, the professor explains that it’s often more beneficial for the students to start in C, then to transition to assembly. The point is really to help students understand how things work, which is why he chose our products. As he explains, ST offers convenient kits, such as those that serve in his lab. Configuring a platform then pushing a button and seeing a LED light up is an immediate reward that dramatically enhances the learning experience.
Similarly, Professor Zhu also uses our open source libraries to help students reverse engineer specific approaches and strategies. For instance, it is common to start a “while” loop that will run until the system encounters a flag. Unfortunately, if the flag never appears, the while loop is just an infinite loop. By looking at ST libraries, students learn how to write a counter that will put an end to the control flow statement if the condition they are looking for never rises. Looking at ST libraries also helps students write more portable applications, on top of teaching them how to find solutions to the typical challenges they will face when designing their embedded systems.
The Best Tool to Teach Clock Trees
Using STM32 MCUs also led to the introduction of new subject matters. As Professor Zhu told us, before using our components, the class didn’t dive into clock trees. However, thanks to our ecosystem and tools like STM32CubeMX, students can now play with the frequencies to optimize their system’s energy efficiency. Teachers can thus challenge students to ensure they understand how to find the best compromises. As he explains:
“STM32CubeMX is the best industry tool I’ve seen to visualize and configure the clock tree. It’s really intuitive and it really shows students how they can use low-level programming to set registers that will in turn adjust the frequencies.
Professor Zhu also surprised us when he revealed how he usedin his classroom. Traditionally, the software helps engineers configure their peripherals and clock tree, then generate a header file in C. However, the professor does things a little differently:
“We use the graphical interface of STM32CubeMX as a study guideline for the clock tree and to assign the MCU’s pins to specific functions. It thus provides an essential visual guide and can help prevent pinout conflict. However, students don’t generate a C file, but write everything in assembly. Hence, STM32CubeMX works as an interesting stepping stone to learn how to initialize a system using a low-level language.”