📜 ⬆️ ⬇️

Programming modern microcontrollers - new course MIREA, Samsung and Unwired Devices

Hi, Giktayms! With this half-chair, Master Gambs ... With this post, we - the IoT project Samsung Academy and Unwired Devices - begin a cycle of publications based on the new practical course on programming microcontrollers on the core Cortex-M3, which will be read from tomorrow at the Moscow Technological University known as MIREA).

The goal of the course is to acquaint students with modern Cortex-M3 microcontrollers and to give them basic programming skills in C language for the operating system. Requirements for students - familiarity with the language C (not necessarily on microcontrollers) and a basic understanding of electronics (at the level of ability to connect the LED).

image
')
Initially, the IoT Academy program was conceived as quite high-level - students should work with ready data transfer modules for LoRa and 6LoWPAN networks, which already had firmware loaded with the support of the necessary sensors and the necessary logic to work with them. In fact, the course consists in setting up these modules and writing high-level software for processing incoming data on the Samsung Artik + Tizen platform.

However, as practice has shown, many students are interested in more seriously delving into what is happening inside the microcontroller. At the same time, with Cortex-M controllers paired with operating systems, everything is quite bad at the moment: in fact, nine out of ten such courses are devoted to writing a simple application using StdPeriphLib and / or CubeMX, and half of the text falls on initialization questions controller and its peripherals.

Modern reality, however, looks different - most commercial projects (we’ll talk about this statistics in the next article, it’s not taken from the ceiling) already use RTOS, which bring hardware abstraction, hardware virtualization, multitasking into the development of microcontrollers. and many other useful things.

What is particularly interesting is the use of RTOS can significantly reduce the threshold of entry - namely, it often lies the main problem. The main principle of educational programs - development from simple to complex - when studying modern microcontrollers at the very first lesson, breaks the STM32 clocking scheme (A4 page entirely with a not too large font) and the need to write half a page of code just to get the microcontroller running. Yes, you can do a series of lectures, starting with an assembler, registers and clocking schemes - but let's be frank: students who were initially seriously not interested in studying this topic will reach the end unless under the threat of passing the exam.

Yes, code generators solve the input threshold problem, but they also lead us to work with the “black box”, depriving us of an understanding of the internal structure of the system. But modern RTOS, distributed in source codes, on the one hand, allows you to quickly start with fairly simple things, and on the other - to dig as much as you like into the internal structure of the system as you study various nuances.

Last December, we already had a test lesson — it is recorded on YouTube — by telling students a little about what modern microcontrollers are, and also how to flash them with a LED. I have to say that success was impressive: we started at half past ten in the morning, while there were not a single person in the audience with STM32 programming experience and only a few with experience with Arduino, but finished at five in the evening at the IoT Academy laboratory, where some of the students already moved to writing on STM32 toys with buttons and RGB-rulers.

As a result, we - Unwired Devices, IoT Samsung Academy and IT Institute MIREA - came to the conclusion that it is time to do a full-fledged course of practical introduction to work with modern microcontrollers. And they did.

The course begins to be delivered to students of the Institute of IT MIREA tomorrow, March 3, and will consist of a cycle of 6 lectures and 5 practical classes with a gradual deepening in topics related to controllers.

Moreover, the institute will keep a video recording of all lectures and a selective video of practical exercises. In the IoT blog of the Samsung Academy there will be summaries of past lectures adapted for use of ST Nucleo-L152 boards, available for sale to all comers at a price of 1200-1400 rubles Unwired Devices github repositories will display the code used in the classroom.

In all practical classes, we will use only the base code of the OS. So, although the full stack for LoRa networks is available to students, in the last lesson the task will not be to use it, but to write its own data transfer protocol and ensure its protection from basic attacks.

We will not use StdPeriphLib, CubeMX and even LL - if we need to talk about the work of the microcontroller, we will talk about registers and CMSIS. The OS HAL code also does not use anything other than CMSIS.

So what will be included in the course?

0. Introductory lecture. Modern microcontrollers, programming tools, real-time operating systems. STM32 family of controllers.

1. Multitasking in embedded OS. Preemptive and non-preemptive multitasking, tickless systems. Threads, timers, interrupts.

Practice: writing a simple application that works with buttons and LEDs by passing messages from interrupts to a separate thread.

2. I / O ports and interfaces SPI, I2C, UART. Clocking, synchronous and asynchronous interfaces, hardware and software implementation.

Practice: device driver illumination sensor TI OPT3001 (I2C) and work with him from the user application. Adding to the driver the function of generating interrupts by a user-defined threshold.

3. Work with analog and quasi-analog signals. PWM, ADC, DAC. Ways to generate an analog signal. Signal digitization, sampling frequency and Kotelnikov theorem.

Practice: adjusting the lamp brightness using PWM according to the size of the incoming analog signal. Digitization of a time-varying analog signal and uploading the obtained values ​​to the UART.

4. Energy saving. The modes of the processor core are RUN, SLEEP, STOP, STANDBY. Awakening from external and internal sources. Saving the state of the controller's RAM, RTC backup registers. Work with low-power modes in the OS.

Practice: “sleeping” pulse counter application with periodic polling of the state of a given GPIO and accumulation of values. Saving the accumulated value in the EEPROM and backup registers.

5. Wireless data networks. Work with the radio channel LoRa. Protection of transmitted data from typical attacks.

Practice: transmitting messages between two microcontrollers using the ready-made driver of a LoRa transceiver SX1276. Encryption of messages, protection against forgery of messages, protection against replay attacks.

6. An additional practical lesson in free form. Question-answer, advice on students' own projects.

Do you think that something important and necessary is missing? Write about it in the comments.

Source: https://habr.com/ru/post/410765/


All Articles