4.23. WDG Module
4.23.1. Acronyms and Definitions
Abbreviation/Term |
Explanation |
---|---|
AUTOSAR |
Automotive Open System Architecture |
BSW |
Basic Software |
DET |
Default Error Tracer |
HW |
Hardware |
SW |
Software |
WDG |
Watchdog Timer |
MCU |
Micro Controller Unit |
OS |
Operating System |
4.23.2. Introduction
This document describes the functionality and configuration of the AUTOSAR BSW module Wdg.
Supported AUTOSAR Release |
4.3.1 |
---|---|
Supported Configuration Variants |
Pre-Compile, Post-build |
Vendor ID |
WDG_VENDOR_ID (44) |
Module ID |
WDG_MODULE_ID (102) |
Supported Platform |
AM263Px |
The WDG driver depends on some other modules, like DET for error handling, OSEK/AUTOSAR OS for interrupt handling and the Mcu module for system clock settings.
4.23.3. Functional Overview
4.23.3.1. WDG Driver Architecture
The Wdg driver has architecture as shown in below figure from the AUTOSAR spec

Fig. 4.97 Wdg in AUTOSAR architecture
The WDG driver provides services for handling the watch dog timer on the microcontroller.
The WDG driver performs two main tasks, which are as follows:
Initialization of WDG
Reset WDG expiration time (trigger)
4.23.3.2. Initialization
The initialization covers the following steps
Set selected watchdog timer expiration time
Set selected trigger timeout
Set selected window size (Digital Windowed Watchdog)
Set selected mode (Fast or slow can be selected and can be switched runtime)
4.23.3.3. States
WDG_IDLE: This is indicating the module is initialized and not busy.
WDG_BUSY: This is indicating the module is busy.
4.23.3.4. Assumptions
None
4.23.3.5. Limitations
Wdg_SetTriggerCondition(0): If “0” is passed as the parameter for Wdg_SetTriggerCondition will result in an immediate stop of the watchdog triggering and an instantaneous watchdog reset of the ECU (irrespective of whether reaction is NMI or reset).
4.23.3.6. Design overview
Will be updated in future release
4.23.4. Hardware Features
4.23.4.1. Hardware Features supported
Setting default mode and timeout during initialization.
Setting window size (Digital Windowed Watchdog).
Enable watchdog timer.
Service watchdog timer.
Mode can be changed at runtime
4.23.4.2. Not supported Features
Off mode not supported
Due to hardware limitations, Timeout can’t be modified if watchdog is running.
4.23.4.3. Non compliance
4.23.4.3.1. Deviations to requirements (Requirement Traceability)
4.23.4.3.1.1. Deviation of requirements against AUTOSAR specification requirements
Will be updated in next release
4.23.5. Source files
Static source C Files are defined below
📦AM263Px
┣ 📂build
┣ 📂mcal
┃ ┣ 📂Wdg
┃ ┃ ┣ 📂include
┃ ┃ ┃ ┣ 📜Wdg.h : WDG module header file. Needs to be included by higher layers.
┃ ┃ ┣ 📂src
┃ ┃ ┃ ┣ 📜Wdg.c : Main part of the module functionality, implements the AUTOSAR APIs for WDG driver.
┃ ┃ ┣ 📂V0
┃ ┃ ┃ ┗ 📜Wdg_Priv.c : Platform specific internal file.
┃ ┃ ┃ ┣ 📜Wdg_Priv.h : Platform specific internal file.
┃ ┃ ┗ 📜Makefile
┃ 📂mcal_config
┃ 📂mcal_docs
┃ 📜README.txt
Plugin files are defined below in the table.
Plugin Files |
Description |
---|---|
Wdg_Cfg.h |
Contains the base addresses, Precompile switches, Macros for channels, counters etc. |
Wdg_PBcfg.c |
Contains all channels Post-Build Configuration parameters |
Wdg_Cfg.c |
Contains all channels Pre-Compile Configuration parameters |

Fig. 4.98 WDG header file include structure
4.23.6. Module requirements
Will be updated in future release
4.23.6.1. Memory Mapping
Memory Mapping Sections |
WDG_CODE |
WDG_CODE_ISR |
WDG_VAR_NO_INIT |
WDG_VAR_ZERO_INIT |
WDG_PBCFG |
WDG_PBCFG_ROOT |
---|---|---|---|---|---|---|
WDG_START_SEC_VAR_INIT_UNSPECIFIED(.bss) |
x |
|||||
WDG _STOP_SEC_VAR_INIT_UNSPECIFIED |
x |
|||||
WDG _START_SEC_CODE_APPL(.text) |
x |
|||||
WDG _STOP_SEC_CODE_APPL |
x |
|||||
WDG _START_SEC_VAR_UNSPECIFIED(.data) |
x |
|||||
WDG _STOP_SEC_VAR_UNSPECIFIED |
x |
|||||
WDG _START_SEC_CODE(.text) |
x |
|||||
WDG _STOP_SEC_CODE |
x |
|||||
WDG_START_SEC_PBCFG(.data) |
x |
|||||
WDG_STOP_SEC_PBCFG |
x |
|||||
WDG_START_SEC_PBCFG_ROOT(.const) |
x |
|||||
WDG_STOP_SEC_PBCFG_ROOT |
x |
4.23.6.2. Scheduling
The Wdg module has no scheduled functions.
4.23.6.3. Error handling
4.23.6.3.1. Development Error Reporting (DET)
The errors reported to DET and DEM are described in the following table
Type of Error |
Related Error code |
Value (Hex) |
---|---|---|
API service used in wrong context (e.g. module not initialized). |
WDG_E_DRIVER_STATE |
0x10 |
API service called with wrong / inconsistent parameter(s) |
WDG_E_PARAM_MODE |
0x11 |
API service called with wrong / inconsistent parameter(s) |
WDG_E_PARAM_CONFIG |
0x12 |
The passed timeout value is higher than the max timeout value. |
WDG_E_PARAM_TIMEOUT |
0x13 |
API is called with wrong pointer value (e.g. NULL pointer) |
WDG_E_PARAM_POINTER |
0x14 |
4.23.6.3.2. Parameter Checking
AUTOSAR requires that API functions check the validity of their parameters. The checks are described in spec and are done as internal parameter checks of the API functions. These checks are for development error reporting and can be en/dis-abled separately. Refer to the configuration chapter where the en/dis-abling of the checks is described. En/dis-abling of single checks is an addition to the AUTOSAR standard which requires to en/dis-able the complete parameter checking via the parameter WDG_DEV_ERROR_DETECT. The following table shows which parameter checks are performed on which services:
Services |
Wdg_Init |
Wdg_SetMode |
Wdg_SetTriggerCondition |
Wdg_GetVersionInfo |
Wdg_Trigger |
---|---|---|---|---|---|
WDG_E_DRIVER_STATE |
X |
X |
|||
WDG_E_PARAM_MODE |
X |
||||
WDG_E_PARAM_CONFIG |
|||||
WDG_E_PARAM_TIMEOUT |
X |
||||
WDG_E_PARAM_POINTER |
X |
X |
|||
WDG_E_MODE_FAILED |
X |
||||
WDG_E_DISABLE_REJECTED |
X |
4.23.6.3.3. Production Code Error Reporting
By default, production code related errors are reported to the DEM using the service DEM_ReportErrorStatus(). The errors reported to DEM are described in the following table:
Type of Error |
Related Error code |
Description |
---|---|---|
Assigned by DEM |
WDG_E_MODE_FAILED |
This error is raised when setting the watchdog mode fails. |
Assigned by DEM |
WDG_E_DISABLE_REJECTED |
Initialization or watchdog mode switch failed because it would disable the watchdog though this is not allowed in this configuration |
4.23.7. Used resources
4.23.7.1. Interrupt Handling
Watchdog uses Non maskable interrupt (Interrupt Number 128) and the ISR shall be called when interrupt occurs
Interrupt Number |
ISR API Mapped |
---|---|
RTI_WDT0_NMI |
WDT_Isr |
4.23.8. Integration description
4.23.8.1. Dependent modules
4.23.8.1.1. MCU
The module MCU powers up the microcontroller’s peripherals at startup time and initializes the PLL.
4.23.8.1.2. OS
An operating system can be used for task scheduling, interrupt handling, global suspend and restore of interrupts and creating of the Interrupt Vector Table. The WDG module may use AUTOSAR OS to suspend and restore global interrupts.
4.23.8.1.3. SchM
There are no exclusive areas.
4.23.8.1.4. Critical Sections
There are no critical sections.
4.23.8.1.5. DEM
By default, production code related errors are reported to the DEM using the service DEM_ReportErrorStatus().
Note: Dem Event is enable only if $(Module_Name)DemEventParameterRefs
is enabled.
4.23.8.1.6. DET
By default, production code related errors are reported to the DET using the service Det_ReportError(). If development error reporting is enabled (i.e. pre-compile parameter WDG_DEV_ERROR_DETECT== STD_ON). The reported service IDs identify the services which are described in 3.4.
4.23.8.1.7. Callback Notification
The WDG driver does not provide any call back functions.
4.23.8.2. Multi-core support
Not supported
4.23.9. Configuration
4.23.9.1. WdgDemEventParameterRefs
Item |
|
---|---|
Name |
WdgDemEventParameterRefs |
Description |
Reference to the DemEventParameter which shall be issued when the error “Timeout on blocking API call occurs “ has occurred. |
Post-build-variant-multiplicity |
false |
Multiplicity-Configuration-Class |
– |
Post-Build Time |
VARIANT-POST-BUILD |
Origin |
Texas Instruments |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Link Time |
VARIANT-LINK-TIME |
Pre-Compile Time |
VARIANT-PRE-COMPILE |
Link-Time |
VARIANT-LINK-TIME |
Pre-Compile-Time |
VARIANT-PRE-COMPILE |
4.23.9.2. WdgGeneral
All general parameters of the watchdog driver are collected here.
4.23.9.2.1. WdgDevErrorDetect
Item |
|
---|---|
Name |
WdgDevErrorDetect |
Description |
Compile switch to enable / disable development error detection for this module. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
true |
4.23.9.2.2. WdgDisableAllowed
Item |
|
---|---|
Name |
WdgDisableAllowed |
Description |
Compile switch to allow / forbid disabling the watchdog driver during runtime. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
false |
4.23.9.2.3. WdgIndex
Item |
|
---|---|
Name |
WdgIndex |
Description |
Represents the watchdog driver’s ID so that it can be referenced by the watchdog interface. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
0 |
Max-value |
255 |
Min-value |
0 |
4.23.9.2.4. WdgInitialTimeout
Item |
|
---|---|
Name |
WdgInitialTimeout |
Description |
The initial timeout (seconds) for the trigger condition to be initialized during Init function. It shall be not larger than WdgMaxTimeout. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
1.0 |
Max-value |
65.535 |
Min-value |
0.0 |
4.23.9.2.5. WdgMaxTimeout
Item |
|
---|---|
Name |
WdgMaxTimeout |
Description |
The maximum timeout (seconds) to which the watchdog trigger condition can be initialized. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
65.535 |
Max-value |
65.535 |
Min-value |
0.0 |
4.23.9.2.6. WdgWindowSize
Item |
|
---|---|
Name |
WdgWindowSize |
Description |
The Digital Windowed Watchdog window size. Selecting 100% enables standard watchdod (not windowed) |
Origin |
Texas Instruments |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
WINDOW_SIZE_100_PERCENT |
Range |
WINDOW_SIZE_3_125_PERCENT |
4.23.9.2.7. WdgRunArea
Item |
|
---|---|
Name |
WdgRunArea |
Description |
Represents the watchdog driver execution area is either from ROM(Flash) or RAM as required with the particular microcontroller. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
RAM |
Range |
RAM |
4.23.9.2.8. WdgTriggerLocation
Item |
|
---|---|
Name |
WdgTriggerLocation |
Description |
Location (memory address) of the watchdog trigger routine. |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
NULL_PTR |
4.23.9.2.9. WdgVersionInfoApi
Item |
|
---|---|
Name |
WdgVersionInfoApi |
Description |
Compile switch to enable / disable the version information API |
Origin |
AUTOSAR_ECUC |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
true |
4.23.9.2.10. WdgRegisterReadbackApi
Item |
|
---|---|
Name |
WdgRegisterReadbackApi |
Description |
Compile switch to enable / disable the Register Readback API |
Origin |
Texas Instruments |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
false |
4.23.9.2.11. WdgRtiFrequency
Item |
|
---|---|
Name |
WdgRtiFrequency |
Description |
RTI Clock Frequency (MHz) |
Origin |
Texas Instruments |
Post-build-variant-multiplicity |
false |
Post-Build-Variant-Value |
false |
Value-Configuration-Class |
– |
Post-Build-Time |
VARIANT-POST-BUILD |
Default-value |
200 |
Max-value |
200 |
Min-value |
0 |
4.23.10. Examples
4.23.10.1. Overview
Initializes clock using Mcu_Init()
Configure the interrupts for WDG using WDTApp_interruptConfig()
Default Example program is configured in Non-Maskable Interrupt method (WDT will trigger interrupt when counter becomes zero).
WDT window reaction can be changed to “reset” through configuration (EB Tresos).
Get Watchdog version using Wdg_GetVersionInfo()
Calculate and define the triggerValue and maxServiceInterval
In example, service interval is 25ms and service count is 100. So, every 25ms core will service the WDT for 100 times (25*100 = 2500 ms).
Initialize the timer using Gpt_Init()
Initialize the Watchdog using Wdg_Init()
Start the timer using API Gpt_StartTimer()
Set the trigger condition using Wdg_SetTriggerCondition() along with timeout value (Timeout is defined by subtracting triggerValue with maxServiceInterval)
Then after it will raise an interrupt and interrupt will run (WDT_Isr() function). In ISR function core reset will occurs and start running program again automatically.
On reset, Check the reason for the reset using GetResetReason(). If reset happened due to WDT then “Test Passed”
In Reset window reaction mode, after counter reaches to zero POR(Power ON Reset) happens.
4.23.10.2. Hardware Software Setup and Tools
None
4.23.10.3. Steps to build and run example
WDG example application demonstrates the MCAL WDG driver features, which is referred from folder <MCAL_ROOT>/examples/WDG.
This application can be built from the build folder by giving “gmake –s wdg_app PLATFORM=am263px” command in command prompt.
Once the build is completed we get a binary file, which is loaded in our controller and executed.
4.23.10.4. Example Logs
WDG_APP: Sample Application - STARTS !!!
WDG MCAL Version Info
---------------------
Vendor ID : 44
Module ID : 102
SW Major Version : 9
SW Minor Version : 1
SW Patch Version : 0
----------------------------------------------------------------------------------
Starting WDG test !!!
----------------------------------------------------------------------------------
Service Count 100
Service Interval 25 milliseconds
------------------------------------------
Trigger Value = 2500 milliseconds
------------------------------------------
Maximum Service Interval 74 milliseconds
Initializing channels
Post-Build variant is being used .
Reset Reason 2
Test Passed!!
WDG Stack Usage: 800 bytes
------------------------------------------
4.23.10.5. File Structure
📦AM263Px
┣ 📂build
┃ ┣ 📂examples
┃ ┃ ┣ 📂Wdg
┃ ┃ ┃ ┣ 📂soc
┃ ┃ ┃ ┣ 📜WdgApp.c : Contains WDG test example.
┃ ┃ ┃ ┣ 📜WdgApp.h : Contains WDG test example headers.
┃ ┃ ┃ ┣ 📜Makefile
┃ ┣ 📂examples_config
┃ ┃ ┣ 📂Wdg_Demo_Cfg
┃ ┃ ┃ ┣ 📂soc
┃ ┃ ┃ ┃ ┣ 📂am263px
┃ ┃ ┃ ┃ ┃ ┣ 📂r5f0_0
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂include
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Wdg_Cfg.h : Contains the Precompile switches, Macros etc.
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂src
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Wdg_Cfg.c : Contains Pre-Compile Configuration parameters
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Wdg_Lcfg.c : Contains linker Configuration parameters
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Wdg_PBcfg.c : Contains Post-Build Configuration parameters
┃ 📂mcal_config
┃ 📂mcal_docs
┣ 📜README.txt
4.23.11. FAQ’s
Will be updated in next release