2. MCAL User Guide¶
2.1. About This Document¶
Document Title |
User Guide of MCAL Driver |
Document Version |
Version 1.2 |
Company |
Texas Instruments |
Document Name |
MCAL User Guide AM263 |
2.2. Document Revision History¶
Version |
Date |
Revision History |
Status |
---|---|---|---|
1.0 |
05 Aug 2023 |
Initial draft |
Approved |
1.1 |
25 Aug 2023 |
Build Steps Updated. Tool Chain Path updated |
Approved |
1.2 |
13 Feb 2024 |
EPWM Module Added |
Approved |
2.3. Table of contents¶
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 |
EPWM |
Enhanced Pulse Width Modulation |
IPC |
Inter Process Communication |
I2C |
Inter Integrated Circuit |
UART |
Universal Asynchronous Reciever Transmitter |
SPI |
Serial Pheripheral Interface |
FSI |
Fast Serial Interface |
LIN |
Local Interconnect Network |
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](_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
MCU – Driver to control enabling of modules, PLL setting and basic microcontroller initialization.
PORT – Driver for control of PinMux
SPI – SPI handler and driver for Serial Peripheral Interfaces: McSPI
CAN – Driver for the on-chip MCAN controller peripheral
GPT – Driver that controls the internal timer of the controller
WDG – Driver for controlling the watchdog when controller goes into continuous loop
DIO – Driver to read and write the data from the Channels / Port
FLS – Driver provides services for reading, writing, erasing flash memory for external flash device
ETH – Driver provides services to transmit and Receive data with the external devices.
ETHTRCV – Driver for Physical Layer Transceiver
ADC – Driver converts the analog value applied to ADC pin to its equivalent digital value.
PWM – Driver provides the pulse width modulated signal.
EPWM - Driver provides the enhanced pulse width modulated signal.
ICU – The ICU driver is a module using the input capture unit (ICU) counting pulses, measuring of frequency and duty cycle.
IPC – Make the initialization of mailbox driver and provides read and write APIs to perform inter processor communication.
UART – Driver provides serial communication using UART.
I2C – Driver provides support for transferring data between an external I2C device and the chip running this driver.
DMA – Provides direct memory access.
FsiRx – Provides fast serial data reception service with the external devices.
FsiTx – Provides fast serial data transmission service with the external devices.
LIN - Driver for the on-chip Lin controller peripheral.
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](_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.
Lin - This directory contains the source files for the Lin driver.
Epwm - This directory contains the source files for the Epwm 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 CCS_PATH, and the TOOLCHAIN_PATH_R5 are updated with the proper path.
Edit paths for the below variables according to your system environment
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
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
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_PATH>/include/memmap
Go to <MCAL_INSTALL_PATH>/build directory and type below commands:
Description
|
Commands
|
---|---|
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
|
2.11. Build Profiles¶
MCAL package can be built in two profiles:
Release Profile
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:
release for Release Profile
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: TI ARM CLANG 2.1.3.LTS.
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
|
Stop compilation after emitting compilergenerated 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-tonearest, and no exceptions are throw |
-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. AM263X-CC¶
System Power On/Off
2.14.2. AM263X-LP¶
2.15. Setup UART Terminal¶
2.15.1. AM263X-CC¶
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.
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.
Figure 3: Identify UART Port in Windows Device Manager
In CCS, goto “View > Terminal”
Figure 4: UART Terminal Menu
Open a new UART terminal
Select the UART port, keep other options to default, i.e 115200 baud rate - 8 data bits - No parity - 1 stop bit,
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¶
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.
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.
Figure 7: Identify UART Port in Windows Device Manager
In CCS, goto “View > Terminal”
Figure 8: UART Terminal Menu
Open a new UART terminal
Select the UART port, keep other options to default, i.e 115200 baud rate - 8 data bits - No parity - 1 stop bit,
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
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.
2.16.2. UARTBOOT MODE¶
2.16.2.1. AM263X-CC¶
This mode is used to flash files to the EVM flash via UART. It can also be used to boot applications via UART.
2.16.2.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.
2.16.3. NOBOOT MODE¶
2.16.3.1. AM263X-CC¶
This mode is used in CCS.
2.16.3.2. AM263X-LP¶
This mode is used in CCS.
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:
AM263x CC / EVM
5V 3Amp USB Type-C Power Adaptor.
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:ti/ccs1210/ccs/ccs_base/emulation/gel/AM263x/AM263x.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.