4.16. MCU

4.16.1. About This Document

Document Title

User Guide of MCAL MCU Driver

Document Version

Version 1.0

Company

Texas Instruments

Document Name

MCU User Guide

4.16.2. Document Revision History

Version

Date

Revision History

Status

Version 1.0

13 Oct 2023

Initial Version.

Approved

Version 1.1

23 Nov 2023

Functional Testing, ADC functionality enabled in MCU.

Approved

4.16.3. Table of contents

  1. Acronyms and Definitions

  2. Functional Overview

  3. Deviations to requirements (Requirement Traceability)

  4. Integration Details

  5. API Description

  6. Configuration Description

  7. Memory Mapping

  8. Memory footprint

  9. Performance

  10. Example Usage

  11. FAQ’s

  12. Test Report (Link to test report)

  13. References

  14. TI Disclaimer

4.16.4. Acronyms and Definitions

Acronyms and Definitions used are presented in below table.

Acronyms

Descriptions

BSW

Basic Software

DET

Default Error Tracer

ADC

Analogue Digital Converter

PWM

Pulse Width Modulation

MCU

Micro Controller Unit

OS

Operating System

API

Application Programming Interface

HW

Hardware

SW

Software

PLL

Phase Locked Loop

4.16.5. Functional Overview

4.16.5.1. Brief Overview

This document describes MCAL MCU Driver functionality, its application interfaces and configuration details as per AUTOSAR version 4.3.1 .

Supported AUTOSAR Release

4.3.1

Supported Configuration Variants

Pre-Compile, Post-build

Vendor ID

MCU_VENDOR_ID (44)

Module ID

MCU_MODULE_ID (101)

Supported Platform

AM263px

The MCU driver provides services for basic microcontroller initialization, reset and microcontroller specific functions required by other MCAL software modules.

The MCU driver provides MCU services for Clock and RAM initialization. In the MCU configuration set, the MCU specific settings for the Clock (i.e. PLL setting) and RAM (i.e. section base address and size) shall be configured.

4.16.5.1.1. MCU Driver Architecture

The MCU driver has architecture as shown in below figure from the AUTOSAR spec.

../_images/mcu_image2.png

Figure 1: MCU in AUTOSAR architecture

../_images/mcu_image3.png

Figure 2: Interface of MCU

4.16.5.1.2. Initialization

Mcu_Init() initializes the MCU driver and does module enable for the configured module ids.

To enable PLL, MCU_NO_PLL should be kept STD_OFF and generate, so that it will generate PLL configuration required in Mcu_Cfg.h and Mcu_PBcfg.c/Mcu_Cfg.c. Refer to figure below :

../_images/mcu_image6.png

For AM263x, configuration settings are as shown below:

  1. Core_Pll shall be set for 2000MHz and is divided into three HSDIV values such as:

    DPLL_CORE_HSDIV0_CLKOUT0: 400MHz, DPLL_CORE_HSDIV0_CLKOUT1: 500MHz, DPLL_CORE_HSDIV0_CLKOUT2: 400MHz ,where DPLL_CORE_HSDIV0_CLKOUT0(400MHz) will be given to core.

Refer to figure below :

../_images/mcu_image25.png
  1. Per_Pll shall be set for 1920MHz and is divided into three HSDIV values such as:

    DPLL_PER_HSDIV0_CLKOUT0: 160MHz and DPLL_PER_HSDIV0_CLKOUT1: 192MHz

Refer to figure below :

../_images/mcu_image26.png

ADC:

MCU powers the ADC module. The ADC module depends on MCU module for data buffer control and crossbar interrupt mapping of ADC interrupts depending on the Hardware unit being configured. Suppose the Hardware Unit 1 and Hardware Unit 3 are configured for ADC module:

../_images/mcu_image7.png

Then, the MCU module container “McuAdcConfiguration” should be configured as shown in below figure:

../_images/mcu_image8.png
../_images/mcu_image9.png

Interrupt Crossbar(ADC):

MCU is also enabling Interrupt crossbar and Input crossbar in Mcu_Init(). Similarly, the crossbar interrupts also needs to be mapped in MCU module according to HW unit and interrupts being required. The ADC interrupts needs to be mapped to the corresponding cross bar interrupt required. Please refer limitation section of Interrupts to be configured for ADC as per “AdcPriorityImplementation” in ADC user guide.

../_images/mcu_image10.png
../_images/mcu_image11.png

PWM:

MCU also powers the PWM module. The PWM module depends on MCU module to enable PWM Channel and crossbar interrupt mapping of PWM interrupts depending on the Hardware unit being configured. Suppose the PWM channel 0 is configured for PWM module as shown in figure:

../_images/mcu_image12.png

Then, the MCU module container “McuPwmConfiguration” should be configured as shown in below figure:

../_images/mcu_image13.png
../_images/mcu_image14.png

Interrupt Crossbar(PWM):

The crossbar interrupts needs to be mapped in MCU module according to PWM channel configured. The PWM interrupts needs to be mapped to the corresponding cross bar interrupt.

../_images/mcu_image15.png
../_images/mcu_image16.png

The interrupt cross bar generates the functions in “Mcu_IntXbar” in Mcu_PBcfg.c as per the user configuration from configurator as shown in below figure:

../_images/mcu_image17.png

Input Crossbar:

Input Crossbar can be configured from MCU as per following figure:

../_images/mcu_image18.png
../_images/mcu_image19.png

As per user configuration, input crossbars APIs will be generated in Mcu_PBcfg.c as in figure.

../_images/mcu_image20.png

4.16.6. States

No state is maintained in the MCU driver

4.16.6.1. Features Supported and Not Supported

AUTOSAR features:

IP Supported Features

AUTOSAR Supported Features

Not Supported

Initialization of Core clock, PLL Clock and peripheral clocks.

Initialization of MCU clock, PLL, clock prescalers and MCU clock distribution.

Support to activate the MCU power modes

Initialization of RAM sections.

MCU Reset/Read Reset Reason.

Cross Bar not supported: PWMXBAR, DMAXBAR, OUTPUTXBAR, PWMSYNCOUTXBAR.

Activation of a µC reset.

Core PLL and Peripheral PLL Supported.

Provides a service to get the reset reason from hardware.

Support to get the lock status of the PLL.

ADC & PWM Enable from MCU.

Cross Bar supported: INPUTXBAR, INTXBAR.

4.16.6.2. Assumptions

None

4.16.6.3. Limitations

None

4.16.6.5. File Structure

Description of static files is provided below:

Static source and header files

Description

Mcu.h

Contains the API’s of the MCU driver to be used by upper layers.

Mcu.c

Implementation of the API’s for MCU driver.

Mcu_Priv.h

Internal function declarations.

Mcu_Priv.c

Contains Internal Functions Definitions.

Description of generated files is provided below:

Plugin Files

Descriptions

Mcu_Cfg.h

Contains the Precompile switches, Symbolic names of McuClockSettingConfig

Mcu_PBcfg.c

Contains all Post-Build Configured parameters

Mcu_Cfg.c

Contains all Pre-Compile Configured parameters

../_images/mcu_image21.png

Figure 4: MCU header file include structure

4.16.7. Deviations to requirements (Requirement Traceability)

4.16.7.1. Module Requirements

Please refer Software Product Specification document provided as part of CSP.

4.16.7.2. Deviation of requirements against AUTOSAR specification requirements

Will be updated in future release

4.16.8. Integration Details

4.16.8.1. Dependency on Other Software Modules

4.16.8.1.1. The MCU Driver dependent modules

4.16.8.1.2. Error Handling module

4.16.8.1.2.1. DET

The module MCU depends on the DET (by default) in order to report development errors. Detection and reporting of development errors can be enabled or disabled by the switch MCU_DEV_ERROR_DETECT = STD_ON in the Mcu_Cfg.h

AUTOSAR requires that API functions shall check the validity of their respective parameters. These checks are for development error reporting and can be enabled or disabled.

The errors reported to DET module are described in the following table:

Error Code

Error Macro

Description

[0x0A]

MCU_E_PARAM_CONFIG

API service called with incorrect configuration parameter.

[0x0B]

MCU_E_PARAM_CLOCK

API service called with invalid clock id.

[0x0C]

MCU_E_PARAM_MODE

API service called with invalid mode id.

[0x0D]

MCU_E_PARAM_RAMSECTION

API service called with invalid ramsection parameter.

[0x0E]

MCU_E_PLL_NOT_LOCKED

DET error reported when PLL is not locked.

[0x0F]

MCU_E_UNINIT

API service used without module initialization.

[0x10]

MCU_E_PARAM_POINTER

API service called with NULL_PTR passed to MCU driver APIs.

4.16.8.1.2.2. DEM

The extended production errors reported to DEM module are described in the following table:

Error Code

Error Macro

Description

Assigned by DEM

MCU_E_CLOCK_FAILURE

This error is raised when there is an MCU Clock Source Failure

4.16.8.1.2.3. Callback Notification

There are no Callback Notifications.

4.16.8.2. Hardware - Software - ISR API name mapping

The MCU module doesn’t implement any Interrupt Service Routines.

4.16.8.3. Scheduling Strategy

4.16.8.3.1. SchM

Beside the OS the BSW Scheduler provides functions that module MCU calls at begin and end of critical sections.

4.16.8.3.2. Critical Sections

There is only one kind of critical sections in MCU driver. Within these sections all read /modify / write accesses to internal MCU status variables must be protected. This is handled internally in the MCU driver by invoking SchM_Enter_Mcu_MCU_EXCLUSIVE_AREA_0()/SchM_Exit_Mcu_MCU_EXCLUSIVE_AREA_0().

4.16.9. API Description

4.16.9.1. Description of the API’s (Can be referred to Api Guide spec)

Refer the AUTOSAR SWS for API documentation and Type definition.

4.16.9.2. API’s with Service ID

The following table presents the service IDs and the related services:

Autosar API’s Supported:

Service ID

Autosar API’s Supported Service

Autosar API’s not Supported Service

0x00

Mcu_Init

0x01

Mcu_InitRamSection

0x02

Mcu_InitClock

0x03

Mcu_DistributePllClock

0x04

Mcu_GetPllStatus

0x05

Mcu_GetResetReason

0x06

Mcu_GetResetRawValue

0x07

Mcu_PerformReset

0x09

Mcu_GetVersionInfo

0x0A

Mcu_GetRamState

0x08

Mcu_SetMode

Refer Autosar SWS for API description mentioned in above table.

4.16.9.3. Description on Non Standard API’s

Mcu_DeInit API

This function is Non- Autosar based and is used to de-initialize MCU module.

Mcu_RegisterReadback API

This function is non-autosar based and is used to read the data in the registers of MCU.

This functionality is enabled, if parameter McuEnableRegisterReadbackApi is TRUE (The Parameter sets MCU_REGISTER_READBACK_API Macro as STD_ON ).

4.16.10. Configuration Description

4.16.10.1. Configuration Variants

The MCU can be configured as Post-Build or Pre-Compile variant, using EB tresos tool.

Variants

Generated Files

PostBuild

Mcu_PBcfg.c , Mcu_Cfg.h

Pre-Compile

Mcu_Cfg.c , Mcu_Cfg.h

4.16.10.2. Parameter Description

Will be updated in future release

4.16.10.3. Symbolic Names deviations

None

4.16.10.4. Configuration rules and constraints to enable plausibility checks

Will be updated in future release

4.16.11. Memory Mapping

Memory Mapping Sections

MCU_CODE

MCU_DATA

MCU_PBCFG

MCU_START_SEC_VAR_INIT_UNSPECIFIED(.bss)

x

MCU_STOP_SEC_VAR_INIT_UNSPECIFIED

x

MCU_START_SEC_CODE(.text)

x

MCU_STOP_SEC_CODE

x

MCU_START_SEC_CONFIG_DATA(.data)

x

MCU_STOP_SEC_CONFIG_DATA

x

4.16.12. Memory footprint

Please refer Memory Footprint for more details.

4.16.13. Performance

Not Applicable

4.16.14. Example Usage

4.16.14.1. Steps to build and run example

MCU example application demonstrating the MCAL MCU driver features is in folder <MCAL_ROOT>/examples/Mcu.

This application can be built from the root folder by giving gmake –s mcu_app PLATFORM=am263.

Once the build is completed we get a binary file, which is loaded in our controller and executed.

4.16.14.2. External set up Information

None

4.16.14.3. Configuration used to test this example

  1. MCU module will initialize the clock for configured modules.

  2. McuRamSectionBaseAddress is configured with ‘zero’ and reference array is also configured with default value of RAM section.

  3. After configuration, Mcu_InitRamSection API is invoked inorder to set ‘McuRamSectionBaseAddress’ with default value.

  4. Reference array and McuRamSectionBaseAddress is compared with each other to check whether RAM section is initialized properly or not.

  5. It will also check for reset reason.

  6. Mcu_GetResetReason API’s return value is compared with MCU_POWER_ON_RESET to check the wakeup cause.

4.16.14.4. Example Logs

Mcu_App: Variant - Post Build being used !!!

McuApp: Sample Application - STARTS !!!
        Mcu Driver version info:9.1.0
        Mcu Driver Module/Driver:101.44
        RAM section is initialized properly
        Wake up from Power ON
        MCU Test Passed!!!
        MCU Stack Usage: 808 bytes

4.16.15. FAQ’s

None

4.16.17. References

Technical Reference Manual

4.16.18. TI Disclaimer

Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue any product or service without notice, and advise customers to obtain the latest version of relevant information to verify, before placing orders, that information being relied on is current and complete. All products are sold subject to the terms and conditions of sale supplied at the time of order acknowledgment, including those pertaining to warranty, patent infringement, and limitation of liability.

TI warrants performance of its products to the specifications applicable at the time of sale in accordance with TI’s standard warranty. Testing and other quality control techniques are utilized to the extent TI deems necessary to support this warranty. Specific testing of all parameters of each device is not necessarily performed, except those mandated by government requirements.

Customers are responsible for their applications using TI components. In order to minimize risks associated with the customer’s applications, adequate design and operating safeguards must be provided by the customer to minimize inherent or procedural hazards.

TI assumes no liability for applications assistance or customer product design. TI does not warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other intellectual property right of TI covering or relating to any combination, machine, or process in which such products or services might be or are used. TI’s publication of information regarding any third party’s products or services does not constitute TI’s approval, license, warranty or endorsement thereof.

Reproduction of information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations and notices. Representation or reproduction o f this information with alteration voids all warranties provided for an associated TI product or service, is an unfair and deceptive business practice, and TI is not responsible nor liable for any such use.

Resale of TI’s products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service, is an unfair and deceptive business practice, and TI is not responsible nor liable for any such use.

Also see: Standard Terms and Conditions of Sale for Semiconductor Products https://www.ti.com/sc/docs/stdterms.htm

Mailing Address: Texas Instruments Post Office Box 655303 Dallas, Texas 75265