MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
COP: Computer Operating Properly(Watchdog) Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 COP Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method.
 
 The Driver Change Log
 The current COP driver version is 2.2.0.
 

Data Structures

struct  cop_config_t
 structure for COP module initialization configuration. More...
 

Enumerations

enum  cop_clock_source_t {
  kCOP_RoscClockSource = 0U,
  kCOP_CoscClockSource = 1U,
  kCOP_BusClockSource = 2U,
  kCOP_LpoClockSource = 3U
}
 enumeration for COP clock source selection. More...
 
enum  cop_clock_prescaler_t {
  kCOP_ClockPrescalerDivide1 = 0U,
  kCOP_ClockPrescalerDivide16 = 1U,
  kCOP_ClockPrescalerDivide256 = 2U,
  kCOP_ClockPrescalerDivide1024 = 3U
}
 enumeration for COP clock prescaler to input source clock. More...
 

Driver version

#define FSL_COP_DRIVER_VERSION   (MAKE_VERSION(2, 2, 0))
 COP driver version.
 

COP refresh sequence.

#define COP_FIRST_WORD_OF_REFRESH   (0x5555U)
 First word of refresh sequence.
 
#define COP_SECOND_WORD_OF_REFRESH   (0xAAAAU)
 Second word of refresh sequence.
 

Initialization Interfaces

void COP_Init (COP_Type *base, const cop_config_t *psConfig)
 Initializes the COP module with input configuration. More...
 
void COP_GetDefaultConfig (cop_config_t *psConfig)
 Prepares an available pre-defined setting for module's configuration. More...
 

COP Operation Interfaces

static void COP_Enable (COP_Type *base, bool bEnable)
 Enable/Disable the COP module. More...
 
static void COP_EnableLossOfReferenceCounter (COP_Type *base, bool bEnable)
 Enables or disables the COP Loss of Reference counter. More...
 
static void COP_SetTimeoutCount (COP_Type *base, uint16_t u16TimeoutCount)
 Sets the COP timeout value. More...
 
static void COP_SetInterruptCount (COP_Type *base, uint16_t u16InterruptCount)
 Sets the COP interrupt value. More...
 
static void COP_SetWindowCount (COP_Type *base, uint16_t u16WindowCount)
 Sets the COP window value. More...
 
void COP_Refresh (COP_Type *base)
 Refreshes the COP timer. More...
 

Interrupt Control Interfaces

static void COP_EnableInterrupt (COP_Type *base)
 Enables the COP interrupt, if psConfig->bEnableWriteProtect is set to true for calling WDOG_Init, the operation does not take effect. More...
 
static void COP_DisableInterrupt (COP_Type *base)
 Disables the COP interrupt, if psConfig->bEnableWriteProtect is set to true for calling WDOG_Init, the operation does not take effect. More...
 

Data Structure Documentation

struct cop_config_t

Data Fields

bool bEnableWriteProtect: 1
 Set COP Write protected.
 
bool bEnableStop: 1
 Enable or disable COP in STOP mode.
 
bool bEnableWait: 1
 Enable or disable COP in WAIT mode.
 
bool bEnableLossOfReference: 1
 Enable or disable COP loss of reference counter.
 
bool bEnableInterrupt: 1
 Enables or disables COP interrupt.
 
bool bEnableCOP: 1
 Enables or disables COP module.
 
cop_clock_source_t eClockSource: 2
 Set COP clock source.
 
cop_clock_prescaler_t ePrescaler
 Set COP clock prescaler.
 
uint16_t u16TimeoutCount
 Timeout count in clock cycles, Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler. More...
 
uint16_t u16WindowCount
 Window count in clock cycles, Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler. More...
 
uint16_t u16InterruptCount
 Interrupt count in clock cycles, Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler. More...
 

Field Documentation

uint16_t cop_config_t::u16TimeoutCount
uint16_t cop_config_t::u16WindowCount
uint16_t cop_config_t::u16InterruptCount

Enumeration Type Documentation

Enumerator
kCOP_RoscClockSource 

COP clock sourced from Relaxation oscillator (ROSC)

kCOP_CoscClockSource 

COP clock sourced from Crystal oscillator (COSCs)

kCOP_BusClockSource 

COP clock sourced from IP Bus clock.

kCOP_LpoClockSource 

COP clock sourced from Low speed oscillator.

Enumerator
kCOP_ClockPrescalerDivide1 

Divided by 1.

kCOP_ClockPrescalerDivide16 

Divided by 16.

kCOP_ClockPrescalerDivide256 

Divided by 256.

kCOP_ClockPrescalerDivide1024 

Divided by 1024.

Function Documentation

void COP_Init ( COP_Type *  base,
const cop_config_t psConfig 
)

Call this function to do initialization configuration for COP module. The configurations are:

  • COP configuration write protect enablement
  • Clock source selection for COP module
  • Prescaler configuration to the input clock source
  • Counter timeout value
  • Window value
  • WAIT/STOP work mode enablement
  • Interrupt enable/disable and interrupt timing value
  • Loss of reference counter enablement
  • COP enable/disable
Parameters
baseCOP peripheral base address.
psConfigThe pointer to COP configuration structure, cop_config_t.
void COP_GetDefaultConfig ( cop_config_t psConfig)

This function initializes the COP configuration structure to default values.

* psConfig->bEnableWriteProtect = false;
* psConfig->bEnableWait = false;
* psConfig->bEnableStop = false;
* psConfig->bEnableLossOfReference = false;
* psConfig->bEnableInterrupt = false;
* psConfig->bEnableCOP = false;
* psConfig->ePrescaler = kCOP_ClockPrescalerDivide1;
* psConfig->u16TimeoutCount = 0xFFFFU;
* psConfig->u16WindowCount = 0xFFFFU;
* psConfig->u16InterruptCount = 0xFFU;
* psConfig->eClockSource = kCOP_RoscClockSource;
*
Parameters
psConfigPointer to the COP configuration structure, cop_config_t.
static void COP_Enable ( COP_Type *  base,
bool  bEnable 
)
inlinestatic

This function disables the COP Watchdog. To disable the COP Watchdog, call COP_Enable(base, false).

Parameters
baseCOP peripheral base address.
bEnableEnable the feature or not.
static void COP_EnableLossOfReferenceCounter ( COP_Type *  base,
bool  bEnable 
)
inlinestatic

This function writes a value into the COP_CTRL register to enable or disable the COP Loss of Reference counter.

Parameters
baseCOP peripheral base address.
bEnableEnable the feature or not.
static void COP_SetTimeoutCount ( COP_Type *  base,
uint16_t  u16TimeoutCount 
)
inlinestatic

This function sets the COP timeout value, if psConfig->bEnableWriteProtect is set to true for calling WDOG_Init, the set does not take effect. It should be ensured that the time-out value for the COP is always greater than interrupt time + 40 bus clock cycles. This function writes a value into COP_TOUT register, when COP count down to zero from the timeout count value, COP_RST_B signal will be asserted. There are some considerations for setting the timeout count afer COP is enabled:

  • The recommended procedure for changing TIMEOUT is to disable the COP by invoking COP_Enable(), then call the function COP_SetTimeoutCount, and then re-enable the by invoking COP_Enable() again.
  • Alternatively, call the function COP_SetTimeoutCount, then feed the COP by invoking COP_Refresh() to reload the timeout.
Parameters
baseCOP peripheral base address
u16TimeoutCountCOP timeout value, count of COP clock tick. Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler.
static void COP_SetInterruptCount ( COP_Type *  base,
uint16_t  u16InterruptCount 
)
inlinestatic

This function sets the COP interrupt value, if psConfig->bEnableWriteProtect is set to true for calling WDOG_Init, the set does not take effect. This function writes a value into COP_INTVAL register, if COP interrupt is enabled and COP count down to the interrupt value configured, an interrupt will be triggered. Ensure the COP counter is disabled while the function is called.

Parameters
baseCOP peripheral base address
u16InterruptCountCOP interrupt value, count of COP clock tick. Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler.
static void COP_SetWindowCount ( COP_Type *  base,
uint16_t  u16WindowCount 
)
inlinestatic

This function sets the COP window value, if psConfig->bEnableWriteProtect is set to true for calling WDOG_Init, the set does not take effect. This function writes a value into COP_WINDOW register. Ensure the COP counter is disabled while the function is called.

Parameters
baseCOP peripheral base address
u16WindowCountCOP window value, count of COP clock tick. Use macro definition MSEC_TO_COUNT to convert value in ms to count of ticks, the COP clock rate is source clock divide prescaler.
void COP_Refresh ( COP_Type *  base)

This function feeds/services the COP.

Parameters
baseCOP peripheral base address.
static void COP_EnableInterrupt ( COP_Type *  base)
inlinestatic

This function writes a value into the COP_CTRL register to enable the COP interrupt.

Parameters
baseCOP peripheral base address
static void COP_DisableInterrupt ( COP_Type *  base)
inlinestatic

This function writes a value into the COP_CTRL register to disable the COP interrupt.

Parameters
baseCOP peripheral base address