2. MCAL User Guide

2.1. About This Document

Document Title

User Guide of MCAL Driver

Release Version

MCAL_AM263_09.00.00

Document Version

Version 1.0

Company

Texas Instruments

Document Name

MCAL User Guide AM263

2.2. Document Revision History

Version

Date

Revision History

Status

1.0

2022-11-18

Initial draft

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

FSI

Fast Serail Interface

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 AM263x. 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 AM263x platform.

AM263x 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.

2.6. Supported Devices/Platforms

AM263x: This release supports AM263x 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: McSPI

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

  5. GPT – Driver that controls the internal timer of the controller

  6. WDG – Driver for controlling the watchdog when controller goes into continuous loop

  7. DIO – Driver to read and write the data from the Channels / Port

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

  9. ETH – Driver provides services to transmit and Receive data with the external devices.

  10. ETHTRCV – Driver for Physical Layer Transceiver

  11. ADC – Driver converts the analog value applied to ADC pin to its equivalent digital value.

  12. PWM – Driver provides the pulse width modulated signal

  13. ICU – The ICU driver is a module using the input capture unit (ICU) counting pulses, measuring of frequency and duty cycle.

  14. IPC – Make the initialization of mailbox driver and provides read and write APIs to perform inter processor communication.

  15. UART – Driver provides serial communication using UART.

  16. I2C – Driver provides support for transferring data between an external I2C device and the chip running this driver.

  17. DMA – Provides direct memory access.

  18. FsiRx – Provides fast serial data reception service with the external devices.

  19. FsiTx – Provides fast serial data transmission service with the external devices.

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 driver.

  • Wdg – This directory contains the source files for the WDG driver.

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

  • 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 EthTrcv driver.

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

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

  • Icu - This directory contains the source files for the ICU driver.

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

  • Uart - This directory contains the source files for the Uart driver.

  • I2c - This directory contains the source files for the I2C driver.

  • Dma - This directory contains the source files for the Dma driver.

  • FsiRx - This directory contains the source files for the FsiRx driver.

  • FsiTx - This directory contains the source files for the FsiTx driver.

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

  • examples_config – Contains EB Tresos (configurator) generated configurations for all drivers which is used by the examples

  • include – Contains include files referred by MCAL drivers.

  • autosar_include – These included files part of the AUTOSAR BSW core. There include files should replace with the header files part of the AUTOSAR stack into which the MCAL integrated.

  • build – Make files for building the MCAL library. CAL supports make based build

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

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

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 modules.

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 mcal_PATH, autosar BSWInc_PATH, autosarConfig_PATH, UTILS_INSTALL_DIR are updated with the proper path.

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_PATH>/include/memmap

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

gmake -s all PLATFORM=am263

SOC value in make files shall be decided based on the PLATFORM selection. The SOC shall be am263, if platform is am263.

This would build all the libs and examples in release profile.

PLATFORM should be with the following value(s): am263

Command to build all the libraries: gmake -s all PLATFORM=am263

Command to build an application given in examples folder: gmake -s <app_name> PLATFORM=am263

app_name can be found in the make file of the respective examples folder.

Command to clean all targets: gmake -s clean PLATFORM=am263

Command to clean individual targets: gmake -s $(target)_clean PLATFORM=am263

The build system requires the RTS library present as part of the TI CG tools. If the library is not already built, make reports an error while linking. You can build the library by opening command prompt at the <CG tools directory>/libs and run the following command.

mk lib –pattern=<RTS library name>

gmake and <CG tools directory/CLANG Compiler>/bin should be added to system PATH environment variable to run above command.

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.

gmake all PLATFORM=am263 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=am263 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=am263 PROFILE=<release/debug> COMPILER_VARIANT=<CLANG>

COMPILER_VARIANT can take the following value(s): CLANG

If COMPILER_VARIANT 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”

Compile Only. Disable Linking

“-qq”

Super Quiet Mode

“-little_endian”

Little Endian mode

“-mv7R5”

ARM R5 Architecture

“–float_support=vfpv3d16”

Output Object file extension

“–abi=eabi”

Output assembly file extension

“-eo.oer5f”

Generate symbolic debug in DWARF format

“-ea.ser5f”

Embed inline assembly in code for optimization

“–symdebug:dwarf”

Generate symbolic debug in DWARF format

“–embed_inline_assembly”

Embed inline assembly in code for optimization

“–gcc”

Enable support for GCC extensions

“–emit_warnings_as_errors”

Treat warnings as errors

“-g”

Full symbolic debug – Can be used only when profile selected is debug

“-ms”

Place each function in a separate subsection

“–optimize_with_debug”

Optimize fully in the presence of debug – Can be used only when profile is release

2.14. Cable Connections

Important cable connections, ports and switches.

2.14.1. AM263X-CC

  1. System Power On/Off

    • 5V power through Type-C 5V/3A

    • HSEC 5V power is available only if Type-C is unavailable

    • No mechanical on/off switch on this EVM

    _images/Am263_cc.png

2.14.2. AM263X-LP

_images/Am263_Lp.png

2.15. Setup UART Terminal

2.15.1. AM263X-CC

  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/Uart-pin.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,

    • We use this serial port, as seen in the device manager, for below in the SDK

      • Flashing application via UART

      • Booting application via UART

      • Console output for examples

      _images/Launch_Terminal.png

      Figure 6: Connect to UART port

  6. In this screenshot this happens to be COM5/COM11 however on your machine this could be different. One tip to make sure there is no mistake in identifying the UART port is to disconnect all other UART to USB devices other than this EVM before checking in device manager.

2.15.2. AM263X-LP

  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/Uart-pin.png

    Figure 7: Identify UART Port in Windows Device Manager

  3. In CCS, goto “View > Terminal”

    _images/Terminal.png

    Figure 8: UART Terminal Menu

  4. Open a new UART terminal

    _images/Uart_terminal.png

    Figure 9: 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,

    • We use this serial port, as seen in the device manager, for below in the SDK

      • Flashing application via UART

      • Booting application via UART

      • Console output for examples

      _images/Launch_Terminal.png

      Figure 10: Connect to UART port

  6. In this screenshot this happens to be COM5/COM11 however on your machine this could be different. One tip to make sure there is no mistake in identifying the UART port is to disconnect all other UART to USB devices other than this EVM before checking in device manager.

2.16. BOOT MODE

Note

This section has more details on AM263X-CC and AM263X-LP. This is mainly for reference. Make sure boot mode switch is setup to NOBOOT mode to use with CCS.

2.16.1. QSPI BOOT MODE

2.16.1.1. AM263X-CC

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

BOOTMODE [ 1 : 4 ] (SW3) = 0010

_images/BootMode1.png

Figure 11: UART BOOT MODE

2.16.1.2. AM263X-LP

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

_images/UartBootMode2.png

Figure 12: UART BOOT MODE

2.16.2. NOBOOT MODE

2.16.2.1. AM263X-CC

This mode is used in CCS.

BOOTMODE [ 1 : 4 ] (SW3) = 1101

_images/NoBootMode1.png

Figure 13: NO BOOT MODE

2.16.2.2. AM263X-LP

This mode is used in CCS.

_images/NoBootMode2.png

Figure 14: 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.

2.18. Hardware Setup

List of hardware required for AM263x EVM:

  1. AM263x CC / EVM

  2. 5V 3Amp USB Type-C Power Adaptor.

  3. Micro USB Cable.

2.19. Memory Usage

Please refer Memory Footprint for more details.

2.20. Running the examples

  • Connect the CC or EVM board to your computer through JTag (USB Port)

  • Before running the binary file on target H/W follow the steps mentioned below:

  • Launch CCS, Go to View > Target Configuration

  • Create a new target configuration

  • Give a nice name to the new target configuration, typically {SOC name} _ {JTAG type}

  • Select connection as XDS110 USB Debug Probe

  • In “Board or Device” type “@VAR_SOC_NAME” and select “AM263x”

  • Click “Save” to save the newly created target configuration.

  • Under Advanced tab – Select Cortex_R5_0

  • Make sure the device gel file path is in the Initialization script field (C:ticcs1210ccsccs_baseemulationgelAM263xAM263x.gel)

  • Click “Save” to save the newly created target configuration

  • Launch the target configuration for AM263x

  • Connect to Cortex_R5_0 core

  • Connect UART USB cable to the serial UART terminal (with appropriate port) and select UART1 serial port for viewing the UART logs and providing user input. By default, configuration may be matched by selecting baud rate as 115200, 8-bit Data Size, Parity None and 1 Stop Bit as the serial port settings.

  • Load binary files using Load Program option

  • Run the application and follow the prompts and output on CCS console/UART serial console.