AUTOSAR MCAL PARTT-2
Published: 2023-12-29 05:58:05

Hello Readers,
My name is Sana, and I’m working at Luxoft India as a Junior Software Developer. Luxoft has given me several opportunities to work on numerous projects, which has stimulated me to discuss the crucial strategies concerned in AUTOSAR MCAL. Here we will speak about the in-detail AUTOSAR MCAL Part2. 

**Introduction**
MCAL stand for Microcontroller Abstraction Layer. The MCAL layer is one of the four layers of the AUTOSAR architecture, the other three are Application Layer, the RTE Layer, and the ECU Abstraction Layer.  MCAL is the lowest layer of BSW(Basic Software). It contains driver with direct access to microcontroller , internal peripheral and memory mapped microcontroller external device. Its act as bridge between Application software and hardware. MCAL is hardware specific layer that ensures a standard interface to the basic software. Its makes higher software layer independent of microcontroller.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukjsl2lvmv5zqscnh7g6.png)



- The Microcontroller Abstraction Layer sub divided into four parts:

Controller Driver
Memory Driver
Com Driver
I/O Driver

**Microcontroller Driver**
A microcontroller driver is a software module that provides an interface to the hardware peripherals of a microcontroller. It allows the upper software layers to access the peripherals without having to know the specific details of the hardware.

- _GPT Driver:_
GPT (General Purpose Timer) device driver uses on-chip microcontroller timer. Initializes GPT and performs timer count. The GPT driver is an essential part of any embedded system that can accurately measure time and generate interrupts at precise intervals.

- _WDG Driver:_
WDG (Watchdog) Driver, The primary purpose of a watchdog timer is to detect and recover from software or system failures, such as code execution errors, infinite loops, or other unexpected behavior.it is a hardware peripheral that is used to prevent software errors from causing the system to become unresponsive. 
• The watchdog driver is responsible for initializing, configuring, and triggering watchdog timer.
• The watchdog driver produce an API that can be used by the upper software layers to interface with the watchdog timer.

- _MCU (Micro Controller Unit):_
MCU (Micro Controller Unit) Driver module provides interface for accessing the microcontroller, including its core functions and its integrated peripherals (e.g., ADC, PWM, CAN, SPI, and FLS).Its designed to perform specific operation in an embedded system.
**Memory Driver**
Memory Drivers provides standardized interface for get back the memory of the ECU, which includes RAM, ROM, and flash memory.

The memory driver provides the following services:

1. Initialization of the memory devices
2. Reading and writing to memory
3. Erasing memory
4. Managing memory protection
5. Testing the memory devices

- _Flash Driver:_ 
Flash drivers are an essential part of any system that uses flash memory. This will help to make and act like that our software is portable, reliable, and productive. Its initialize Flash and reads/writes to Flash memory.

**Communication Drivers**
The communication driver in MCAL  modules that handle communication protocols and provide interfaces between different Electronic Control Units (ECUs) within the vehicle or with external devices.
This module Provides a standardized interface for retrieve the communication interfaces used in the ECU, such as CAN, LIN, and FlexRay.

- _CAN (Controller Area Network):_
A widely used communication protocol in automotive applications for inter-ECU communication. It allows multiple ECUs to communicate with each other over a shared bus. Driver that initializes and performs CAN input/output. CAN is multi master anyone can send the data. Its carries 8 bytes for traditional CAN.

- _LIN (Local Interconnect Network):_ 
A simple and cost-effective communication protocol commonly used for communication with less critical ECUs in the vehicle. Its cost effective and low-end multiplexed communication in automotive networks. It use the serial universal asynchronous receiver/transmitter (UART) embedded into most modern low-cost 8-bit microcontrollers.

- _FlexRay:_ 
A high-speed communication protocol used in advanced driver assistance systems (ADAS) and other safety-critical applications. Its single network cable run that connects multiple ECUs together.
Its initializes FlexRay and performs FlexRay input/output.

- _Ethernet:_
Ethernet is becoming more popular for in-vehicle communication due to its higher data rates and ability to handle multiple protocols simultaneously. Its used for sending data along with cables is faster, more reliable, and more secure than sending it as radio waves, as Wi-Fi does. With the increasing complication of automotive systems.
 
**I/O Driver:**
An I/O driver in MCAL is a software module that provides access to the microcontroller's (MCU) I/O ports. It abstracts physical layer of I/O port, making it simple for the upper software layer to interconnect with them.

- _ICU(Input Capture Unit):_
The ICU is software module in MCAL layer that handles the capture of input signals, usually related time measurements, on a microcontroller. The primary purpose of the ICU is to exactly capture the time of particular events or pulses that occur on external pins or signals connected to microcontroller. 


- _PWM (Pulse Width Modulation):_ 
PWM driver is software module responsible for generating and controlling PWM signals on a microcontroller. The objective of deriving PWM (Pulse Width Modulation) using timers and interrupts is to achieve exact control of the output pulse width and frequency. PWM is a commonly used technique in embedded systems and electronic devices to control the speed of motors, brightness of LEDs, Heating and cooling control, and various other applications where precise control of the output signal is required.

-  _ADC Driver:_     
ADC allows the microcontroller to convert analog signals (voltage) to digital signals from sensors, transducers, and other analog devices into digital values that can be processed and make use of the digital circuitry of the microcontroller.
The ADC driver is being an essential part of an automotive applications, where it is used to read analog signals from various sensors, such as temperature sensors, pressure sensors, position sensors, and other transducers.

**Conclusion**
In this Article I have Tried to explain about Autosar MCAL. Please let me know if you have any queries.


Thanks for reading.