DEV Community

Sushma B R
Sushma B R

Posted on

Introduction to MCAL(Microcontroller Abstraction Layer) in AUTOSAR

Hey, I am Sushma B R, working as Software Engineer at Luxoft. In this article, I have tried to give a explanation about MCAL in AUTOSAR.

Introduction:

AUTOSAR (AUTomotive Open System ARchitecture) is an open and standardized software architecture that is widely used in the automotive industry. One of the key components of AUTOSAR is the MCAL (MicroController Abstraction Layer) layer, which provides a standardized interface between the hardware and software components of a vehicle's electronic systems. In this article, we will take a closer look at the MCAL layer and its importance in the context of AUTOSAR.

What is the MCAL Layer?

The MCAL layer is responsible for abstracting the hardware-specific details of a microcontroller from the software components of an electronic system. This abstraction allows software developers to write code that is independent of the specific hardware platform being used, which makes it easier to develop and maintain software across different hardware platforms.

The MCAL layer provides a standardized interface for accessing the low-level hardware peripherals of a microcontroller, such as timers, GPIO (General Purpose Input/Output) ports, and ADC (Analog to Digital Converter) modules. By using this standardized interface, software developers can write code that is hardware-independent, which reduces the effort required to port software to different hardware platforms.

The MCAL layer also provides a mechanism for configuring the hardware peripherals of a microcontroller. This configuration is typically done through a set of configuration structures that are provided by the MCAL layer. These structures define the configuration parameters for each peripheral, such as the clock source, prescaler settings, and interrupt priorities.
Hey, I am Sushma B R, working as Software Engineer at Luxoft. In this article, I have tried to give a explanation about MCAL in AUTOSAR.

Image description

Why is the MCAL Layer Important?

The MCAL layer is an essential component of AUTOSAR because it provides a standardized interface between the hardware and software components of a vehicle's electronic systems. This interface allows software developers to write code that is independent of the specific hardware platform being used, which makes it easier to develop and maintain software across different hardware platforms.

In addition to this, the MCAL layer provides a mechanism for configuring the hardware peripherals of a microcontroller. This configuration is typically done through a set of configuration structures that are provided by the MCAL layer. These structures define the configuration parameters for each peripheral, such as the clock source, prescaler settings, and interrupt priorities.

Another important aspect of the MCAL layer is that it enables software developers to write code that is highly optimized for performance. By using the low-level hardware peripherals provided by the MCAL layer, software developers can implement highly efficient algorithms and data structures that take full advantage of the capabilities of the underlying hardware platform.

The software architecture of AUTOSAR MCAL consists of three layers:

The hardware abstraction layer (HAL): This layer provides an abstraction of the hardware peripherals of the microcontroller. It consists of a set of drivers that communicate with the hardware peripherals and provide a standardized interface for the upper layers of the software.

The microcontroller abstraction layer (MCAL): This layer provides a standardized interface between the application software and the hardware peripherals of the microcontroller. It is responsible for initializing and configuring the hardware peripherals, and for providing low-level services such as interrupt handling, memory management, and clock management.

The basic software module (BSW): This layer provides higher-level services such as communication, diagnostics, and software update. It is built on top of the MCAL layer and provides a standardized interface for the application software.

The AUTOSAR MCAL architecture is designed to be flexible and customizable, allowing automotive system developers to configure the software according to their specific needs. The modular architecture also enables developers to easily replace or upgrade individual software components without affecting the rest of the system.

Image description

Modules in MCAL:

Microcontroller Drivers:

  • GPT Driver: GPT (General Purpose Timer) hardware module is a timer/counter that can be used for a variety of purposes such as generating periodic interrupts, measuring time intervals, or generating PWM (Pulse Width Modulation) signals. The GPT driver abstracts the low-level hardware details of the GPT module and provides a high-level API (Application Programming Interface) that allows the application software to configure and use the GPT module in a convenient and efficient manner.

  • WDG Driver: Using a Watchdog Timer in MCAL is important for ensuring the reliability and safety of the overall system. It helps to prevent the system from getting stuck in an infinite loop or hanging, which could potentially cause damage or harm. However, it is important to configure the Watchdog Timer correctly to avoid false resets or other unintended consequences.

  • MCU Driver: Micro Controller Unit Driver, this device driver helps configure MCU settings, initializes clock and helps configure power mode settings.

Memory Drivers:

  • FLS Driver: Flash Driver initializes FLS and reads or writes to the FLS memory.

Communication Drivers:

  • SPI Handler/Driver: Serial Peripheral Interfaceis a Handler/Driver Device with on-chip clock serial function that Initializes SPI, performs SPI input/output and SPI I/O buffer settings.

  • LIN Driver: Local Interconnected network is a device driver that initializes LIN and performs LIN input/output.

  • CAN Driver: Controller Area Network is a device driver that initializes CAN and performs CAN input/output.

  • FlexRay Driver: FlexRaydevice driver initializes FlexRay and performs FlexRay input/output.

  • Ethernet Driver: Ethernet device driver initializes Ethernet Driver and performs Ethernet Driver input/output.

IO Drivers:

  • ICU Driver: Input Capture Unit is a device driver using on-chip MCU timer and initializes ICU. It also measures PWM waveforms.

  • PWM Driver: Pulse Width Modulation is a device driver using on-chip MCU timer. It initializes PWM and sends PWM waveforms as output.

  • ADC Driver: Analog Digital Converter is a device driver for on-chip ADC. It Initializes ADC, starts/stops AD conversion, sets AD conversion result buffer and reads AD conversion results.

  • DIO Driver: Digital Input/Output is an MCU port device driver that performs port signal (input/output).

  • PORT Driver: PORT Driver is a MCU port device driver that performs MCU pin settings (I/O, shared functions).

Conclusion:

The MCAL layer is a critical component of AUTOSAR that provides a standardized interface between the hardware and software components of a vehicle's electronic systems. By abstracting the hardware-specific details of a microcontroller from the software components, the MCAL layer enables software developers to write code that is independent of the specific hardware platform being used, which makes it easier to develop and maintain software across different hardware platforms.

In addition to this, the MCAL layer provides a mechanism for configuring the hardware peripherals of a microcontroller and enables software developers to write highly optimized code for performance. Overall, the MCAL layer plays a crucial role in the development of modern automotive electronic systems, and its importance is only set to increase as the complexity of these systems continues to grow.

Top comments (0)