DigiKey-emag-Wireless Modules-Vol-8

Zephyr OS is an open-source real- time operating system (RTOS) that, while developed as a project hosted by the Linux Foundation, operates independently within its ecosystem. Primarily designed for embedded devices, Zephyr OS has attracted contributions from a diverse range of industry leaders, establishing itself as a key player in embedded systems and IoT. This article will introduce developers to Zephyr, outline core concepts, and help readers execute their first ‘Hello World’ project. What is an RTOS and why use it? For many simple applications, such as constantly reading a sensor and displaying the results, a developer may decide to program using a straightforward ‘bare metal’ approach. With this method, the program executes in a single ‘round

robin’ or ‘super loop’. This offers development simplicity but is not particularly efficient, either in terms of power consumption or utilization of the microcontroller’s resources. Interrupt service routines (ISR) provide a means to interrupt program flow based on defined events – see Figure 1 left. As use cases become more complicated, for example, using more sophisticated sensors and lots of different system functions or tasks, implementing a state machine is a popular way to program embedded systems. Based on modelling an embedded system behavior according to defined conditions and transitions, state machines are used widely. As application complexity grows, and particularly where the system is required to control time-constrained events, using an RTOS becomes essential. By real-time, the inference is that the

application requires a predictable and deterministic response to performing tasks. This might include reading sensors and controlling associated actuators within a given time window rather than when the microcontroller has finished some other tasks. An RTOS provides an embedded developer with the capability to manage and schedule multiple tasks and control communications between individual tasks. Essentially, the RTOS ‘sits above’ the application code and takes control of the hardware domain, such as the processor resources, I/O, and peripheral interfaces, effectively decoupling the application from the physical hardware. The RTOS schedules individual threads tasks according to priority and resource availability – see Figure 1 right. An RTOS is utilized for anything that requires a predictable and reliable behavior, such as controlling the

Written by: Bill Schweber, Contributing Author at DigiKey

Figure 1: Program flow using a bare-metal approach (left) and an RTOS (right) Image source: Nordic Semiconductor

Getting started with Zephyr: a developer’s guide to your first project

Written by: Paige West, Editor at Electronic Specifier

we get technical

60

61

Powered by