# 4.9. Hardware Abstraction Layer (HAL)

The HAL is used by the MCAF to decouple all knowledge of device-specific hardware registers, via well-known function calls. At this time of writing, the HAL is hand-coded to work with the dsPICDEM® MCLV‑2 Development Board, but future versions are intended to utilize Microchip’s MPLAB® Code Configurator and MPLAB® Harmony Configurator.

As long as the HAL function names and semantics are preserved, the HAL component can be swapped out and replaced with an alternative implementation.

More information is available in the HAL documentation.

## 4.9.1. Hardware-related behavior

Certain aspects of the MCAF utilize the functions provided by the HAL, but the choice of behavior lies within the MCAF.

### 4.9.1.1. PWM outputs

PWM outputs for the three-phase bridge are set in one of three modes:

- off — at device reset, and during severe faults, the bridge is turned off completely

- “minimal impact” — when not applying voltage across the motor terminals (in certain states of the state machine), the upper transistors are turned off completely, but the lower transistors are turned on at a low duty cycle (typically 1-3%), to maintain charge in bootstrap gate drive capacitors. See `MCAF_SetPwmMinimalImpact()` in the state_machine module.
- normal — when applying voltage across the motor terminals, all 6 of the transistors are switching, in three complementary pairs, one for each phase. Each phase has a dead-time between turn-off of one transistor and turn-on of the complementary transistor, to avoid shoot-through.