4.21. WDG Module

4.21.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.21.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.21.3. Functional Overview

4.21.3.1. WDG Driver Architecture

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

Wdg in AUTOSAR architecture

Fig. 4.96 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:

  1. Initialization of WDG

  2. Reset WDG expiration time (trigger)

4.21.3.2. Initialization

The initialization covers the following steps

  1. Set selected watchdog timer expiration time

  2. Set selected trigger timeout

  3. Set selected window size (Digital Windowed Watchdog)

  4. Set selected mode (Fast or slow can be selected but cannot be switched runtime)

4.21.3.3. States

  1. WDG_IDLE: This is indicating the module is initialized and not busy.

  2. WDG_BUSY: This is indicating the module is busy.

4.21.3.4. Assumptions

None

4.21.3.5. Limitations

None

4.21.3.6. Design overview

Will be updated in future release

4.21.4. Hardware Features

4.21.4.1. Hardware Features supported

  • Setting default mode and timeout during initialization.

  • Setting window size (Digital Windowed Watchdog).

  • Enable watchdog timer.

  • Service watchdog timer.

4.21.4.2. Not supported Features

  • Off mode not supported

  • Due to hardware limitations, Mode and Timeout can’t be modified if watchdog is running.

4.21.4.3. Non compliance

4.21.4.3.1. Deviations to requirements (Requirement Traceability)

4.21.4.3.1.1. Deviation of requirements against AUTOSAR specification requirements

Will be updated in next release

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

WDG header file include structure

Fig. 4.97 WDG header file include structure

4.21.6. Module requirements

4.21.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.21.6.2. Scheduling

None

4.21.6.3. Error handling

4.21.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.21.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.21.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.21.7. Used resources

4.21.7.1. Interrupt Handling

Will be updated in the future release

4.21.8. Integration description

4.21.8.1. Dependent modules

4.21.8.1.1. MCU

The module MCU powers up the microcontroller’s peripherals at startup time and initializes the PLL.

4.21.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.21.8.1.3. SchM

There are no exclusive areas.

4.21.8.1.4. Critical Sections

There are no critical sections.

4.21.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.21.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.21.8.1.7. Callback Notification

The WDG driver does not provide any call back functions.

4.21.8.2. Multi-core and Resource allocator

Will be updated in the future release

4.21.9. Configuration

The Wdg is configured through GUI in Post-Build and Pre-Compile Variants.

Variants

Configured Files

PostBuild

Wdg_PBcfg.c , Wdg_Cfg.h

Pre-Compile

Wdg_Cfg.c , Wdg_Cfg.h

4.21.9.1. Parameter Description

4.21.9.1.1. Standard Configuration

Standard Parameters

Description

Default Value

Range

Unit

WDG_E_DISABLE_REJECTED

Reference to the DemEventParameter which shall be issued when the error “Initialization or mode switch failed because it would disable the watchdog” has occurred.

FALSE

0..1

Boolean

WDG_E_MODE_FAILED

Reference to the DemEventParameter which shall be issued when the error “Setting a watchdog mode failed (during initialization or mode switch)” has occurred.

FALSE

0..1

Boolean

WdgDevErrorDetect

Switches the development error detection and notification on or off.

FALSE

TRUE

FALSE

Boolean

WdgDisableAllowed

Compile switch to allow / forbid disabling the watchdog driver during runtime.

FALSE

TRUE

FALSE

Boolean

WdgIndex

Specifies the InstanceId of this module instance. If only one instance is present it shall have the Id 0.

0

0 .. 255

Integer

WdgInitialTimeout

The initial timeout (sec) for the trigger condition to be initialized during Init function.

0

0 .. 65.535

Integer

WdgMaxTimeout

The maximum timeout (sec) to which the watchdog trigger condition can be initialized.

0

0 .. 65.535

Integer

WdgVersionInfoApi

Compile switch to enable / disable the version information API

TRUE

TRUE

FALSE

Boolean

WdgDefaultMode

Default mode for watchdog driver initialization.

WDGIF_FAST_MODE

WDGIF_FAST_MODE

WDGIF_OFF_MODE

WDGIF_SLOW_MODE

Enumeration

WdgInstanceId

Watchdog HW instance id. 0 - R5F0_0, 1 - R5F0_1, 2 - R5F1_0, 3 - R5F1_1

0

0..3

Integer

WdgTriggerMode

Watchdog trigger mode (toggle/window/both)

WDG_WINDOW

WDG_BOTH

WDG_TOGGLE

WDG_WINDOW

Enumeration

WdgRunArea

Represents the watchdog driver execution area is either from ROM(Flash) or RAM as required with the particular microcontroller

RAM

RAM

ROM

Enumeration

4.21.9.1.2. IP Specific Configuration

Standard Parameters

Description

Default Value

Range

Unit/Datatype

WdgWindowSize

The Digital Windowed Watchdog window size. Selecting 100% enables standard watchdog

WINDOW_SIZE_100_PERCENT

WINDOW_SIZE_3_125_PERCENT

WINDOW_SIZE_6_25_PERCENT

WINDOW_SIZE_12_5_PERCENT

WINDOW_SIZE_25_PERCENT

WINDOW_SIZE_50_PERCENT

WINDOW_SIZE_100_PERCENT

Enumeration

WdgRegisterReadbackApi

Compile switch to enable / disable the Register Readback API

FALSE

TRUE

FALSE

Boolean

WdgRtiFrequency

RTI Clock Frequency (MHz)

200

0..200

Integer

WdgPreloadValue

Watchdog preload value to be set in RTIDWDPRLD register. Expiration time is calculated using this function: texp = (WdgPreloadValue + 1) x 2^13 / RTICLK1

4095

0..4095

Integer

WdgDeviceVariant

Select SOC AM263Px variant

AM263Px

AM263Px

String

WdgReaction

Watchdog reaction for timer expiration or incorrect service.

WDG_GENERATE_NMI

WDG_GENERATE_RESET

WDG_GENERATE_NMI

Enumeration

WDG_E_HARDWARE_ERROR

This error is raised when Hardware failed detected

NULL

NA

NA

  1. WDG_INITIAL_TIMEOUT: This is the initial wdg timeout period.

  2. WDG_MAX_TIMEOUT: Maximum timeout for the wdg is 65 * 1000.

  3. WDG_MAX_PRELOAD_VALUE: To define wdg maximum preload value.

  4. WDG_RTI_FREQUENCY: This is defined to get the desired frequency.

  5. WdgDeviceVariant: To Select SOC AM263Px variant

4.21.9.2. Symbolic Names deviations

None

4.21.9.3. Configuration rules and constraints to enable plausibility checks

Will be updated in future release

4.21.10. Examples

4.21.10.1. Overview

Will be updated in the future release

4.21.10.2. Hardware Software Setup and Tools

None

4.21.10.3. Steps to build and run example

  1. WDG example application demonstrates the MCAL WDG driver features, which is referred from folder <MCAL_ROOT>/examples/WDG.

  2. This application can be built from the build folder by giving “gmake –s wdg_app PLATFORM=am263px” command in command prompt.

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

4.21.10.4. Flow of the example application

  1. Default Example program is configured in Non-Maskable Interrupt method (WDT will trigger interrupt when counter becomes zero).

  2. WDT window reaction can be changed to “reset” through configuration (EB Tresos).

  3. 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).

  4. WDG is integrated with WDG in order to service WDG.

  5. WDG_SetTriggerCondition API is servicing WDG by passing non zero timeout value

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

  7. It checks for reset reason, if reset happened due to WDT then “Test Passed”

  8. In Reset window reaction mode, after counter reaches to zero POR(Power ON Reset) happens.

4.21.10.5. 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.21.10.6. 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.21.11. FAQ’s

Will be updated in next release

4.21.12. Test Report

Please refer AM26x WDG Driver Test Case Report as part of CSP provided in the release package.

4.21.13. References

AUTOSAR_SWS_WatchdogDriver
Technical Reference Manual