2. MCAL User Guide

2.1. About This Document

Document Title

User Guide of MCAL Driver

Release Version

MCAL_AM273_09.00.00

Document Version

Version 1.6

Company

Texas Instruments

Document Name

MCAL User Guide AM273

2.2. Document Revision History

Version

Date

Revision History

Status

1.1

04 Nov 2020

Initial draft

Approved

1.2

12 Jan 2021

Added PWM Driver

Approved

1.3

13 Jan 2021

Added CAN Driver

Approved

1.4

12 Jul 2022

Updates based on CLANG compiler

Approved

1.5

30 Sep 2022

MCAL 2.x specific changes

Approved

1.6

27 Feb 2023

Updated for Functional Safety Release.

Approved

1.7

28 Feb 2023

Updated for review comments

Approved

1.6

05 Aug 2023

Updated as per HTML format

Approved

2.3. Table of contents

  1. Acronyms and Definitions

  2. Introduction

  3. Supported Devices/Platforms

  4. MCAL Overview

  5. Directory Structure

  6. Tool Chain versions

  7. Build Steps

  8. Build Profiles

  9. Compiler Variants

  10. Compiler Options

  11. Cable Connections

  12. Setup UART Terminal

  13. BOOT MODE

  14. CCS Setup

  15. Hardware Setup

  16. Memory Usage

  17. Running the examples

2.4. Acronyms and Definitions

Acronyms and Definitions used are presented in below table.

Acronyms

Descriptions

BSW

Basic Software

DET

Default Error Tracer

DEM

Diagnostic Event Manager

MCU

Micro Controller Unit

OS

Operating System

API

Application Programming Interface

HW

Hardware

SW

Software

ISR

Interrupt Service Routine

INT

Interrupt

CDD

Complex Device Driver

ADC

Analogue Digital Converter

CAN

Control Area Network

DIO

Digital Input Output

DMA

Direct Memory Access

ETH

Ethernet

ETHTRCV

Ethernet Transceiver

FLS

Flash

GPT

General Purpose Timer

ICU

Input Capture Unit

PWM

Pulse Width Modulation

IPC

Inter Process Communication

I2C

Inter Integrated Circuit

UART

Universal Asynchronous Reciever Transmitter

SPI

Serial Pheripheral Interface

QSPI

Quad SPI

Tx

Transmitter

Rx

Reciever

2.5. Introduction

The purpose of this User Guide is to provide more detailed information regarding the usage of TI MCAL software on AM273x. The Microcontroller abstraction layer (MCAL) is the lowest layer of the AUTOSAR Basic Software architecture. MCAL contains drivers with direct access to the μC internal peripherals and memory mapped μC external devices. MCAL is a hardware specific layer that ensures a standard interface to the Basic Software. It manages the microcontroller peripherals and provides the components of the Basic Software with microcontroller independent values. MCAL also implements notification mechanisms to support the distribution of commands, responses, and information to processes. The figure below shows MCAL layer in the AUTOSAR BSW software stack

_images/Block_Autosar.png

This TI MCAL delivery is based on the AM273x platform.

AM273x is an SOC from TI targeted to address various AUTOMOTIVE markets. AUTOSAR is a key software which needs to run on ARM Cortex-R5 so that it can enable communication with other ECUs in the system. TI needs to provide the MCAL drivers for the AUTOSAR to run on the SOCs. Customers will need to procure the other AUTOSAR SW stack either internally or from third parties. These SOCs are expected to be used in safety-critical systems and hence needs to be compliant to ISO26262 specifications. The targeted compliance for the AUTOSAR MCAL is ASIL-B.

2.6. Supported Devices/Platforms

AM273x: This release supports AM273x SoC

2.7. MCAL Overview

A set of MCAL included in the package each controlling a specific peripheral. MCAL drivers included are

  1. MCU – Driver to control enabling of modules, PLL setting and basic microcontroller initialization.

  2. PORT – Driver for control of pinmux

  3. SPI – Spi handler and driver for Serial Peripheral Interfaces : MiBSPI

  4. CAN – Driver for the on-chip DCAN and MCAN controller peripheral

  5. GPT – Driver for General Purpose Timer

  6. WDG – Driver for General Purpose Timer

  7. DIO – Driver for control of GPIOs

  8. FLS – Driver provides services for reading, writing, erasing flash memory for external flash device

  9. ETH – Driver for Ethernet MAC

  10. ETHTRCV – Driver for Physical Layer Transceiver

  11. ADC – Driver for the reading the external GPADC signals connected to the device

  12. PWM – PWM driver for generating the waveforms with required duty cycle and period.

  13. ICU – Driver for input capture unit.

  14. CDD IPC – Driver for the inter process communication between the cores.

  15. CDD UART – Driver for communication over UART.

  16. CDD I2C – Driver for I2C communication between peripherals.

  17. CDD DMA – Not complete driver, currently only there to support DMA mode for Uart & Spi.

  18. QSPI– Driver for flash communication. (Async/DMA)

The MCAL drivers implement the Software specification as mentioned in the AUTOSAR 4.3.1 release. Additionally, examples to demonstrate MCAL driver usages have also been included.

2.8. Directory Structure

_images/FileStrt.png
  • Mcu - This directory contains the source files for the MCU MCAL.

  • Port - This directory contains the source files for the PORT MCAL.

  • Spi – This directory contains the source files for the SPI Driver handler.

  • Can – This directory contains the source files for the Can driver.

  • Gpt – This directory contains the source files for the GPT MCAL.

  • Wdg – This directory contains the source files for the Watchdog MCAL

  • Dio – This directory contains the source files for the DIO MCAL.

  • Fls – This directory contains the source files for the FLS driver.

  • Eth – This directory contains the source files for the ETH driver.

  • EthTrcv – This directory contains the source files for the ETH driver.

  • Adc - This directory contains the source files for the Adc driver

  • Pwm - This directory contains the source files for the PWM driver.

  • IPC - This directory contains the source files for the CDD IPC driver.

  • I2c - This directory contains the source files for Cdd_I2c driver

  • examples - Examples provided as part of the package to show MCAL driver usage.

  • examples_config – This directory contains configuration details(<Module>_Cfg.h / <Module>_Cfg.c) which are generated using EB Tresos tool for all drivers as per example use case. Refer - configurator_userguide for more details.

  • include – Contains include files referred by MCAL drivers.

  • autosar_include – These are include files part of the AUTOSAR BSW core. There include files should be replaced with the header files part of the AUTOSARstack into which the MCAL is integrated.

  • build – Makefiles for building the MCAL library.MCAL supports make based build

  • binary - The entire executables are placed in this directory. The generated library or executable/binary is placed in an appropriate path under targetspecific directory.

  • examples/Utils - Contains utility for plugin in ISRs and enabling/disabling interrupts to be used commonly across the examples.On a full AUTOSARsystem,these will be done by the AUTOSARstack

Note

FsiRx and FsiTx - This directory is applicable only for AM263 Variant.

2.9. Tool Chain versions

Refer corresponding Release notes for Tool chain information.

Please use link to request access to EB Tresos Studio and License ** https://www.ti.com/licreg/docs/swlicexportcontrol.tsp?form_id=339047&prod_no=PROCESSOR-SDK-MCAL-EB-TRESOS&ref_url=EP-Proc-Sitara-MPU

2.10. Build Steps

This section describes how to build the MCAL package. The package is built using “gmake” from Cygwin. Make sure that the Cygwin tools location is added to the PATH variable. Also, make file internally uses some binaries like rm, mkdir, echo etc. from Cygwin. Standard CCS installation comes with Cygwin, gmake and other utils as required to build MCAL.

Edit the Rules. Make file present in <MCAL_INSTALL_PATH>/build/Rules.make to give the appropriate paths for the tool chains and the current working directory. Make sure that CCS_PATH, and the TOOLCHAIN_PATH_R5 are updated with the proper path.

Edit paths for the below variables according to your system environment

  1. In case of windows machine edit CCS path according to CCS version,

    • CCS_PATH := C:/ti/ccs1210/ccs

    • TOOLCHAIN_PATH_R5 := $(CCS_PATH)/Compilers/ti-cgt-armllvm_2.1.3.LTS

  2. In case of Linux machine edit CCS path according to CCS version,

    • CCS_PATH := /opt/ti/ccs1210/ccs

    • TOOLCHAIN_PATH_R5 := $(CCS_PATH)/Compilers/ti-cgt-armllvm_2.1.3.LTS

  3. By default the above are for CLANG compiler, modify respective paths accordingly for using other compilers.

Also, the path to generated pre-compile headers for the MCAL modules and generated <Module>_Memmap.h needs to be set by modifying macro autosarConfig_PATH. The value can be list of directories separated by space.

By default, MCAL package provides pre-generated pre-compile config headers under <MCAL_INSTALL_PATH>/examples_config/<Module>_Demo_Cfg/soc/<SOC>/<Core>/include.

<SOC> should be with the following value(s): am263 / am273 in folder struture.

Sample <Module>_Memmap.h can be found under <MCAL_INSTALL_FOLDER>/include/memmap

Go to <MCAL_INSTALL_PATH>/build directory and type below command:

Description
Commands
Command to build all the libraries
gmake -s all PLATFORM=am273 / am2732s
Command to build an application given in examples folder


gmake -s <app_name> PLATFORM=am273 / am2732s

app_name can be found in the make file of the respective examples folder.
Command to clean all targets
gmake -s clean PLATFORM=am273 / am2732s
Command to clean individual targets
gmake -s $(target)_clean PLATFORM=am273 / am2732s

2.11. Build Profiles

MCAL package can be built in two profiles:

  1. Release Profile

  2. Debug Profile

Users can build in mode by setting parameter PROFILE while building.

Variant_Soc = am273 / am2732s

gmake all PLATFORM=<Variant_Soc> PROFILE=<release/debug>

PROFILE makefile macro can take either of the following values:

  1. release for Release Profile

  2. debug for Debug Profile

If PROFILE is not set during build, MCAL will be built for release profile by default.

To build all the examples and libraries in debug mode, you can give the following command.

gmake -s all PLATFORM=<Variant_Soc> PROFILE=debug

Similarly, PROFILE can be set in all the above build commands.

2.12. Compiler Variants

MCAL package can be built with the following compiler variant: CLANG.

Users can build with either compiler variants.

gmake all PLATFORM=<Variant_Soc> PROFILE=<release/debug> COMPILER_SELECT=<CLANG>

COMPILER_SELECT can take the following value(s): CLANG

If COMPILER_SELECT is not specified during the build, MCAL will be built for CLANG by default.

2.13. Compiler Options

2.13.1. Below are the compiler flags used:

Compiler Option

Description

“-c”

Stop compilation after emitting compiler generated object files; do not call linker

“-mlittle-endian”

Select little-endian; default

“-mcpu=cortex-r5”

ARM R5 Architecture

“-mfpu=vfpv3-d16”

Select appropriate floating-point hardware

“-mfloat-abi=hard”

Floating-point hardware is available;select appropriate hardware with -mfpu option

“–ffp_mode=std”

Tells the tiarmclang compiler to generate code where IEEE finite values with denormals are flushed to zero, rounding mode is round-to nearest, and no exceptions are thrown

“-ffunction-sections”

Instructs the tiarmclang compiler to generate code for a function definition into its own section

“-fshort-enums “

Instructs the compiler to only allocate as much space for an enum type data object as is needed to represent the declared range of possible values

“-gdwarf-3”

Emit DWARF version 3 debug information

“-fdiagnostics-show-option”

Discover the category name associated with a given diagnostic

“-Werror”

Treat detected warnings in the specified category as errors

“-Os”

Most optimizations enabled, especially optimizations that are designed to reduce code size while mitigating negative impacts on performance

“-x”

Decides the compile mode (c / c++ / ti-asm …)

“-save-temps “

Keeps all temporary files generated during compilation and linking without halting either the compiler or the linker

2.14. Cable Connections

Important cable connections, ports and switches.

2.14.1. AM273X EVM

  1. The figure below shows some important cable connections, ports and switches.

    • Take note of the location of the “BOOTMODE” switch, this is used to switch between different boot modes like OSPI, UART, SD, NOBOOT mode

      _images/evm_overview_273.png

2.15. Setup UART Terminal

  1. Many examples use a standard UART terminal to log the output from the examples. You can use any UART terminal program for the same. Below steps show how to setup the UART terminal from CCS.

  2. First identify the UART port as enumerated on the host machine.

    • Make sure that the EVM and UART cable connected as shown in Cable Connections.

    • In windows, you can use the “Device Manager” to see the detected UART ports.

      • Search “Device Manager” in Windows Search Box in the Windows taskbar.

    • If dont see any USB serial ports listed in “Device Manager” under “Ports (COM & LPT)”, then make sure you have installed the UART to USB driver from FTDI, https://www.ftdichip.com/FTDrivers.htm.

    _images/ccs_uart_identify_273.png

    Figure 3: Identify UART Port in Windows Device Manager

  3. In CCS, goto “View > Terminal”

    _images/Terminal.png

    Figure 4: UART Terminal Menu

  4. Open a new UART terminal

    _images/Uart_terminal.png

    Figure 5: Open New UART Terminal

  5. Select the UART port, keep other options to default, i.e 115200 baud rate - 8 data bits - No parity - 1 stop bit,

  6. UART for R5F console is only visible in Device Manager when USB XDS110 cable is connected to EVM.

  7. UART for C66x console is only visible in Device Manager when UART to USB cable is connected to EVM.

    • We use the 1st USB serial port, as seen in the device manager, when USB XDS110 cable is connected for below in the SDK

      • Flashing application via UART

      • Booting application via UART

      • Console output for examples which run from R5F

    • We use the 3rd USB serial port out of 4 ports emulated, when UART to USB cable is connected for below in the SDK

      • Console output for examples which run from C66x

    • In this screenshot this happens to be COM5/COM11 however on your machine this could be different.

    _images/Launch_Terminal.png

    Fig. 2.1 Figure 6: Connect to UART port

    • Tips for checking the right UART port number.

      • disconnect all other UART to USB devices other than this EVM before checking in device manager.

      • un-plug and re-plug the USB FTDI and XDS110 connection to the PC while the Device Manager is open and the COM ports are visible.

2.16. BOOT MODE

_images/Sop.png

2.16.1. UART BOOT MODE

This mode is used to flash files to the EVM flash via UART. It can also be used to boot applications via UART.

Note

SOP0 - Short

SOP2 - Short

SOP1 - Open.

_images/uart_bootmode_273.png

Fig. 2.2 Figure 11: UART BOOT MODE

2.16.2. QSPI BOOT MODE

This mode is used to boot flashed applications via EVM flash like QSPI flash.

Note

SOP0 - Short

SOP2 - Open

SOP1 - Open

_images/qspi_bootmode_273.png

Fig. 2.3 Figure 11: QSPI BOOT MODE

2.16.3. NOBOOT MODE

This mode is used with the Gel files without using the SBL.

Note

SOP0 - Short

SOP2 - Open

SOP1 - Short

_images/no_bootmode_273.png

Figure 13: NO BOOT MODE

2.17. CCS Setup

If user does not have a functional setup using CCS with then the instructions in this section are relevant.

Installing CCS - Use TI CCS v12.1.0 or later - After the package is downloaded, you will be prompted to restart CCS to complete the installation. - The installer will install the Emulation package and complete installation. AM273xChip Support Package - Device xml files, GEL files, etc. for CCS configuration - If you don’t have the CSP file please contact your TI representative

2.18. Hardware Setup

List of hardware required for EVM:

  1. AM273x EVM

2.19. Memory Usage

Please refer Memory Footprint for more details.

2.20. Running the examples

It is recommended that user refer to module specific user guide for detailed information on examples.

  • Connect the EVM to CCS through JTag(USB Port)

  • Connect to core Cortex_R5_0

  • Load the respective core binary

  • Connect UART USB cable to the UART terminal () and select UART1 serial port for viewing the UART logs and giving user input. Select UART baud rate as 115200, 8-bit data, no parity and 1 stop bit as the serial port settings

  • Run the application and follow the instruction on CCS console/UART console