MCUSW
|
This document details AUTOSAR BSW ICU module implementation
The ICU module initializes, configures and controls the internal hardware to realize ICU driver as detailed in AUTOSAR BSW ICU Driver Specification. The ICU functionality is realized through the ECAP IP available on the device. Following section highlights key aspects of this implementation, which would be of interest to an integrator.
Please refer the ICU design, which is included as part of release (Icu Design Document)
The Icu driver uses ECAP module to capture events. Please refer to SOC user manual for soc specific details. The Icu driver provides the following features:
Programming of clock source for the ICU module, is beyond the scope of this document. The driver expects that the user of this module has programmed required clock source. The example application demonstrates configuring clock sources for ECAP module.
Please refer to the SOC user manual for details.
The Icu Driver implementation supports multiple configuration variants (refer section Introduction), the driver expects generated Icu_Cfg.h to be present as (File Structure). Please refer (Build) to specify path to generated configuration. The associated Icu configuration generated files Icu_Cfg.c and Icu_PBcfg.c to be present as shown (File Structure)
The following section details on the un-supported features and additional features added.
APIs (listed below) related to wakeup capability are not supported as the hardware does not support.
Please note that only preliminary functionality testing has been done on ICU driver module. Unit Test and API testing is planned for future releases.
This driver implementation introduces below listed configurable options
Name | IcuFunctionalClock |
Description | Value of the system clock freq. |
Container Name | IcuConfigSet |
Type | Integer |
Range | 125 (Default MHZ Clock) |
Value Configuration Class | VARIANT-PRE-COMPILE |
Name | IcuDeviceVariant |
Description | Used to specific family of devices, the variant of the device being used will belong one or more family of devices. Please refer (Supported Device Families) to determine the family of device. |
Container Name | IcuGeneral |
Type | Enumeration |
Range | TDA4x, etc… (new family of devices could be added in future) |
Value Configuration Class | VARIANT-PRE-COMPILE |
Name | IcuClkPrescaler |
Description | Used configure divider for the input clock This parameter could be used to divide this clock before it’s used to count. |
Container Name | IcuChannelConfigSet |
Type | uint8 |
Range | 0 to 7 |
Value Configuration Class | VARIANT-PRE-COMPILE & VARIANT-POST-BUILD |
The Driver doesn't register any interrupts handler (ISR), it’s expected that consumer of this driver registers the required interrupt handler.
For every Icu channel with notification enabled, an ISR requires to be registered. The Interrupt number associated with instance of the ECAP is detailed in TRM (also, please refer the demo application). Please refer IcuApp_InterruptConfig () in Icu demo application.
Some of the ICU interrupts are not routed/mapped to this core, these interrupts would require additional programming to route these to this core. Please refer IcuApp_IntrConfig () in Icu demo application.
Refer section (Icu Channel ID , Instance mapping and ISR mapping), for association between channel ID and ISR
As noted from the previous MCAL implementation, some of the critical configuration registers could potentially be corrupted by other entities (s/w or h/w). One of the recommended detection methods would be to periodically read-back the configuration and confirm configuration is consistent. The service API defined below shall be implemented to enable this detection
Description | Comments | |
Service Name | Icu_RegisterReadback | Can potentially be turned OFF (Refer to Design Document provided in CSP) |
Syntax | Icu_RegisterReadback(Icu_ChannelType Channel, P2VAR(Icu_RegisterReadbackType, AUTOMATIC, ICU_APPL_DATA) RegRbPtr) | E_OK: Register read back has been done, E_NOT_OK: Register read back failed. Icu_RegisterReadbackType defines the type, that holds critical |
Service ID | NA | |
Sync / Async | Sync | |
Reentrancy | Non Reentrant | |
Parameter in | Channel | Numeric identifier of the ICU channel |
Parameters out | RegRbPtr | A pointer of type Icu_RegisterReadbackType, which holds the read back values. |
Return Value | Std_ReturnType | E_OK or E_NOT_OK in case of Icu not initialized or NULL buffer pointer |
The driver doesn't configure the functional clock and power for the timer modules. Its expected that SBL power-up the required modules. Please refer SBL documentation.
Please follow steps detailed in section (Build) to build library or example.
ECAP based application name - icu_app
This application uses the PWM (Enhanced Pulse Width Module) to provide input to ECAP instance. The ECAP module (with ICU driver) will capture the signals provided as input.
Modification to EVM are required to ensure that EPWM signal is fed into the ECAP input.
Please refer to the SOC user manual for details .
The icu_app by default is configured to use "Signal Detect Measurement Mode". The configuration set can be modified to test out a different mode.
Please note that since EPWM module is used internally by the icu_app, it is required to perform a clean build.
Please refer (Running Examples)
Various objects of this implementation (e.g. variables, functions, constants) are defined under different sections. The linker command file at (Examples Linker File (Select memory location to hold example binary)) defines separate section for these objects. When the driver is integrated, its expected that these sections are created and placed in appropriate memory locations. (Locations of these objects depend on the system design and performance needs)
Section | ICU_CODE | ICU_VAR_INIT | ICU_VAR_NOINIT | ICU_CONST | ICU_CONFIG |
ICU_START_SEC_VAR_INIT_UNSPECIFIED (.data) | USED | ||||
ICU_DATA_INIT_32_SECTION | USED | ||||
ICU_TEXT_SECTION | USED | ||||
ICU_DATA_NO_INIT_UNSPECIFIED_SECTION | USED | ||||
ICU_CONST_32_SECTION | USED | ||||
ICU_ISR_TEXT_SECTION | USED | ||||
ICU_CONFIG_SECTION | USED |
This driver implementation has been validated with cache enabled. For optimal performance it’s recommended to place (Memory Mapping) sections in cache enabled memory area.
Prescaler value can be set using the IcuClkPrescaler vairable. Please note that various prescaler values (apart from 0) has not been tested for Icu driver. This activity is planned for later release.
This implementation depends on the DET in order to report development errors and can be turned OFF. Refer section (Development Error Reporting) for detailed error codes.
This implementation requires 1 level of exclusive access to guard critical sections. Invokes SchM_Enter_Icu_ICU_EXCLUSIVE_AREA_0 (), SchM_Exit_Icu_ICU_EXCLUSIVE_AREA_0 () to enter critical section and exit.
In the example implementation (File Structure SchM_Icu.c) , all the interrupts on CPU are disabled. However, disabling of the enabled ECAP interrupt should suffice.
Development errors are reported to the DET using the service Det_ReportError(), when enabled. The driver interface (Icu.h File Structure) lists the SID.
Type of Error | Related Error code | Value (Hex) |
API is called with invalid pointer | ICU_E_PARAM_POINTER | 0x0A |
API service used with an invalid channel identifier or channel was not configured for the functionality of the called API | ICU_E_PARAM_CHANNEL | 0x0B |
API service used with an invalid or not feasible activation | ICU_E_PARAM_ACTIVATION | 0x0C |
Init Function Failed | ICU_E_INIT_FAILED | 0x0D |
API service used with an invalid bugger size | ICU_E_PARAM_BUFFER_SIZE | 0x0E |
API serice Icu_SetMode used with an invalid mode | ICU_E_PARAM_MODE | 0x0F |
API service used without module initialization | ICU_E_UNINIT | 0x14 |
API serice Icu_SetMode is called while in running operation | ICU_E_BUSY_OPERATION | 0x16 |
API Icu_Init ervice is called and when the ICU driver and the Hardware are already Initialized | ICU_E_ALREADY_INITIALIZED | 0x17 |
API Icu_StartTimeStamp is called and the parameter NotifyInterval is Invalid | ICU_E_PARAM_NOTIFY_INTERVAL | 0x18 |
API Icu_GetVersionInfo is called and the parameter versioninfo is invalid | ICU_E_PARAM_VINFO | 0x19 |
Runtime Errors
Type of Error | Related Error code | Value (Hex) |
API service Icu_StopTimestamp called on a channel which was not started or already stopped | ICU_E_NOT_STARTED | 0x15 |
The AUTOSAR BSW ICU Driver specification details the APIs required for Icu Driver. Please refer to (Refer to Design Document provided in CSP) for detailed API description. APIs related to wakeup capability are not implemented, please refer to (Variance / Deviation from the specification).
Refer API Documentation for details
The example application demonstrate use of ECAP based Icu module, the list below identifies key steps performed the example. The configuration file is present at (File Structure)
To run the icu_app:
Please refer to the SOC user manual for soc specific details.
ICU_APP: Sample Application - STARTS !!! ICU_APP: ICU MCAL Version Info --------------------- ICU_APP: Vendor ID : 44 ICU_APP: Module ID : 122 ICU_APP: SW Major Version : 1 ICU_APP: SW Minor Version : 3 ICU_APP: SW Patch Version : 2 ICU_APP: Variant - Pre Compile being used !!! ICU_APP: EPWM Channel Initialized ICU_APP: EPWM Duty cycle: 60 Percent, 1000Hz ICU_APP: Use EPWM (Pin 2 in J22 on GESI Board) as input to ECAP test point (TP30 on SOM board) for J721E EVM ICU_APP: Edge Detect Mode! ICU_APP: input state is ICU_IDLE ICU_APP: SignalNotification for Double Edge Detection Reached in 1 sec: 2000 ICU_APP: SignalNotification for Single Edge Detection Reached in 1 sec: 1000 ICU_APP: input state is ICU_ACTIVE ICU_APP: Changing EPWM Frequency from 1000Hz to 25000Hz and Duty Cycle to 50% ICU_APP: Edge Detect Mode! ICU_APP: input state is ICU_IDLE ICU_APP: SignalNotification for Single Edge Detection Reached in 1 sec: 25002 ICU_APP: input state is ICU_ACTIVE ICU_APP: SignalNotification for after disabling notification Edge Detection Reached: 0 ICU_APP: Calling Deinit ICU_APP: Icu Stack Usage 1076 bytes ICU_APP: ICU Test Passed!!!
Revision | Date | Author | Description | Status |
---|---|---|---|---|
0.1 | 09 March 2021 | Nikki Shah | First version | Pending Review |
0.2 | 16 March 2021 | Nikki Shah | Update | Approved |