| PDL for FM0+ Version1.0 Peripheral Driverl Library for FM0+

- Main Page
- Modules
- Data Structures
- Files

Watch Counter (WC)

Provided functions of WC module:

- Wc_Pres_SelClk()
- Wc_Pres_EnableDiv()
- Wc_Pres_DisableDiv()
- Wc_Init()
- Wc_EnableCount()
- Wc_DisableCount()
- Wc_EnableInt()
- Wc_DisableInt()
- Wc_WriteReloadVal()
- Wc_ReadCurCnt()
- Wc_ClearIntFlag()
- Wc_GetIntFlag()
- Wc_GetOperationFlag()
- Wc_IrqHandler()

How to use WC module?

Before using WC, WC prescaler must be configured first. Use Wc_Pres_SelClk() to select input clock of prescaler. Following clocks can be selected:

- Sub clock
- Main clock
- High-speed CR
- CLKLC (divided by low speed CR)

Wc_Pres_EnableDiv() is used to enable watch counter prescaler. Wc_Pres_DisableDiv() is used to disable watch counter prescaler.

Wc_Init() must be used for configuration of watch counter with a structure of the type stc_wc_config_t.

A WC interrupt can be enabled by the function Wc_EnableInt(). This function can set callback function for each channel too.

With Wc_WriteReloadVal() the WC reloader value is set to the value given in the parameter Wc_WriteReloadVal::u8Val.

After above setting, calling Wc_EnableCount() will start WC.

With Wc_ReadCurCnt() the current WC count can be read when WC is counting. with Wc_GetOperationFlag() the current WC operation status can be read.

With interrupt mode, when the interrupt occurs, the interrupt flag will be cleared and run into user interrupt callback function.

With polling mode, user can use Wc_GetIntFlag() to check if the interrupt occurs, and clear the interrupt flag by Wc_ClearIntFlag().

When stopping the WC, use Wc_DisableCount() to disable WC and Wc_DisableInt() to disable WC interrupt.