📄 timer_config.h
字号:
/*
*******************************************************************************
**
** This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
** 78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
**
** Filename : timer_config.h
** Abstract : This file implements a device driver for the timer module
** Device : uPD78F0547
** Compiler: NEC/CC78K0
**
*******************************************************************************
*/
/*
*******************************************************************************
** Case : Square wave output function
**
** Description : Output squarewave
**
** Setting : fprs = 8MHz
** TM00 TM00_Pulse_TI00nAndTI01nFreeRunnin
** TM01 TM00_Pulse_TI00nFreeRunning
** TM50
** TM51
** TMH0
** TMH1
**
*******************************************************************************
*/
#include "timer_macro.h"
#ifndef _TIMERCFG_
#define _TIMERCFG_
/*
*******************************************************************************
** User control macro define
*******************************************************************************
*/
/*
***************************************
** TM00 configure
**
** Please set operation mode here
***************************************
*/
/* if no use set nouse = 1, if use some function set function = 1 */
#define TM00_NotUse 0
#define TM00_Interval 0
#define TM00_ExternalEvent 0
#define TM00_SquareOut 0
#define TM00_PPGOut 0
#define TM00_OneshotOut 0
#define TM00_PulseMeasurement 1
/* if no use some method of pulse measurement set method = 1 */
#define TM00_Pulse_TI00nAndTI01nFreeRunning 1
#define TM00_Pulse_TI00nFreeRunning 0
#define TM00_Pulse_TI00nRestart 0
/* macro for setting of different functions */
#if TM00_Interval==1
/*
***************************************
** TM00 interval
**
** user set interval time = 0.5s
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_Internal0 : fprs or
TM0n_PRM0n_CountClock_Internal1 : fprs/2^2 or
TM0n_PRM0n_CountClock_Internal2 : fprs/2^8 or
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : Please select the higher frequency you can,
so the precision will be higher.
*/
#define TM00_Clock TM0n_PRM0n_CountClock_Internal2
/*
Value range : 0x0001 - 0xffff
Interval time = (CR00n_value + 1) * count_clock
*/
#define TM00_CR00nValue 0x3d08
#define TM00_CR01nValue 0xffff
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
#define TM00_PRM0nValue TM00_Clock
#define TM00_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
/* Interrupt settings */
#define TM00_INTTM000 1
#define TM00_INTTM010 0
#elif TM00_ExternalEvent==1
/*
***************************************
** TM00 external event
**
** user set valid edges = 10
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
*/
#define TM00_Clock TM0n_PRM0n_CountClock_TI00nEdge|\
TM0n_PRM0n_TI00nEdge_Falling
/*
Value range : 0x0001 - 0xffff
Valid edges = CR00n_value + 2 : first time after start
CR00n_value + 1 : second time or later
Note : Valid edge interspace must > 2 * count_clock.
*/
#define TM00_CR00nValue 0x9
#define TM00_CR01nValue 0xffff
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
/* external count clock only*/
#define TM00_PRM0nValue TM00_Clock
#define TM00_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
/* Interrupt settings */
#define TM00_INTTM000 1
#define TM00_INTTM010 0
#elif TM00_SquareOut==1
/*
***************************************
** TM00 squarewave output
**
** user set square width = 0.005s
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_Internal0 : fprs or
TM0n_PRM0n_CountClock_Internal1 : fprs/2^2 or
TM0n_PRM0n_CountClock_Internal2 : fprs/2^8 or
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : Please select the higher frequency you can,
so the precision will be higher.
*/
#define TM00_Clock TM0n_PRM0n_CountClock_Internal0
/*
Value range : 0x0001 - 0xffff
Square width = (CR00n_value + 1) * count_clock
*/
#define TM00_CR00nValue 0x9c3f
#define TM00_CR01nValue 0xffff
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
#define TM00_PRM0nValue TM00_Clock|\
/* Use register bit macro
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : External trigger set only
*/
TM0n_PRM0n_TI00nEdge_Falling
#define TM00_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
#define TM00_TOC0nValue /* Value selection
TM0n_TOC0n_TO0nOut_NoChange
TM0n_TOC0n_TO0nOut_Clear0
TM0n_TOC0n_TO0nOut_Set1
*/\
TM0n_TOC0n_TO0nOut_Clear0|\
TM0n_TOC0n_TO0nReverseByCR00n_Enable|\
TM0n_TOC0n_TO0nOut_Enable
/* Interrupt settings */
#define TM00_INTTM000 0
#define TM00_INTTM010 0
#elif TM00_PPGOut==1
/*
***************************************
** TM00 PPG output
**
** user set cycle = 0.003s, duty = 30%
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_Internal0 : fprs or
TM0n_PRM0n_CountClock_Internal1 : fprs/2^2 or
TM0n_PRM0n_CountClock_Internal2 : fprs/2^8 or
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : Please select the higher frequency you can,
so the precision will be higher.
*/
#define TM00_Clock TM0n_PRM0n_CountClock_Internal0
/*
Value range : 0x0001 - 0xffff
Pulse cycle = (CR00n_value + 1) * count_clock
Duty = (CR01n_value + 1) / (CR00n_value + 1)
CR01n_value < CR00n_value
*/
#define TM00_CR00nValue 0x5dbf
#define TM00_CR01nValue 0x1c1f
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
#define TM00_PRM0nValue TM00_Clock
#define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Compare|\
TM0n_CRC0n_CR00nMode_Compare
#define TM00_TOC0nValue TM0n_TOC0n_OneshotMode_Successive|\
TM0n_TOC0n_ReverseTO0nByCR01n_Enable|\
/* Value selection
TM0n_TOC0n_TO0nOut_NoChange
TM0n_TOC0n_TO0nOut_Clear0
TM0n_TOC0n_TO0nOut_Set1
*/\
TM0n_TOC0n_TO0nOut_Clear0|\
TM0n_TOC0n_TO0nReverseByCR00n_Enable|\
TM0n_TOC0n_TO0nOut_Enable
/* Interrupt settings */
#define TM00_INTTM000 0
#define TM00_INTTM010 0
#elif TM00_OneshotOut==1
/*
***************************************
** TM00 oneshot output
**
** user set delay = 0.01s, width= 0.02s
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_Internal0 : fprs or
TM0n_PRM0n_CountClock_Internal1 : fprs/2^2 or
TM0n_PRM0n_CountClock_Internal2 : fprs/2^8 or
TM0n_PRM0n_CountClock_TI00nEdge(Note : software trigger only)
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : Please select the higher frequency you can,
so the precision will be higher.
*/
#define TM00_Clock TM0n_PRM0n_CountClock_Internal1
/*
Value range : 0x0001 - 0xffff
Delay time = (CR01n_value + 1) * count_clock
Pulse width = (CR00n_value - CR01n_value) * count_clock
CR01n_value < CR00n_value
*/
#define TM00_CR00nValue 0xea5f
#define TM00_CR01nValue 0x4e1f
/* Register settings */
/* Value selection
TM0n_TMC0n_Operation_FreeRunning : software trigger
TM0n_TMC0n_Operation_ClearByTI00nEdge : External trigger
*/
#define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByTI00nEdge
/* Note : If use external trigger, use internal count clock only */
#define TM00_PRM0nValue TM00_Clock|\
/* Use register bit macro
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : External trigger set only
*/\
TM0n_PRM0n_TI00nEdge_Falling
#define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Compare|\
TM0n_CRC0n_CR00nMode_Compare
#define TM00_TOC0nValue TM0n_TOC0n_OneshotMode_Oneshot|\
TM0n_TOC0n_ReverseTO0nByCR01n_Enable|\
/* Value selection
TM0n_TOC0n_TO0nOut_NoChange
TM0n_TOC0n_TO0nOut_Clear0
TM0n_TOC0n_TO0nOut_Set1
*/\
TM0n_TOC0n_TO0nOut_Clear0|\
TM0n_TOC0n_TO0nReverseByCR00n_Enable|\
TM0n_TOC0n_TO0nOut_Enable
/* Interrupt settings */
#define TM00_INTTM000 0
#define TM00_INTTM010 0
#elif TM00_PulseMeasurement==1
/*
***************************************
** TM00 pulse measurement
**
** user set mode=
***************************************
*/
/* Count clock */
/* Use register bit macro
TM0n_PRM0n_CountClock_Internal0 : fprs or
TM0n_PRM0n_CountClock_Internal1 : fprs/2^2 or
TM0n_PRM0n_CountClock_Internal2 : fprs/2^8 or
Note : Please select the higher frequency you can,
so the precision will be higher.
*/
#define TM00_Clock TM0n_PRM0n_CountClock_Internal0
#if TM00_Pulse_TI00nAndTI01nFreeRunning==1
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_FreeRunning
#define TM00_PRM0nValue TM0n_PRM0n_TI01nEdge_Both|\
TM0n_PRM0n_TI00nEdge_Both|\
TM00_Clock /* internal count clock only */
#define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Capture|\
TM0n_CRC0n_CR00nMode_Capture
/* Interrupt settings */
#define TM00_INTTM000 1
#define TM00_INTTM010 1
#elif TM00_Pulse_TI00nFreeRunning==1
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_FreeRunning
#define TM00_PRM0nValue TM0n_PRM0n_TI01nEdge_Rising|\
TM0n_PRM0n_TI00nEdge_Rising|\
TM00_Clock /* internal count clock only */
#define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Capture|\
TM0n_CRC0n_CR00nTrigger_TI00nEdgeReverse|\
TM0n_CRC0n_CR00nMode_Capture
/* Interrupt settings */
#define TM00_INTTM000 0
#define TM00_INTTM010 1
#elif TM00_Pulse_TI00nRestart==1
/* Register settings */
#define TM00_TMC0nValue TM0n_TMC0n_Operation_ClearByTI00nEdge
#define TM00_PRM0nValue TM0n_PRM0n_TI01nEdge_Rising|\
TM0n_PRM0n_TI00nEdge_Rising|\
TM00_Clock /* internal count clock only */
#define TM00_CRC0nValue TM0n_CRC0n_CR01nMode_Capture|\
TM0n_CRC0n_CR00nTrigger_TI00nEdgeReverse|\
TM0n_CRC0n_CR00nMode_Capture
/* Interrupt settings */
#define TM00_INTTM000 0
#define TM00_INTTM010 1
#endif
#else /*not use*/
/* Interrupt settings */
#define TM00_INTTM000 0
#define TM00_INTTM010 0
#endif
/*
***************************************
** TM01 configure
**
** Please set operation mode here
***************************************
*/
/* if no use set nouse = 1, if use some function set function = 1 */
#define TM01_NotUse 0
#define TM01_Interval 0
#define TM01_ExternalEvent 0
#define TM01_SquareOut 0
#define TM01_PPGOut 0
#define TM01_OneshotOut 0
#define TM01_PulseMeasurement 1
/* if no use some method of pulse measurement set method = 1 */
#define TM01_Pulse_TI00nAndTI01nFreeRunning 0
#define TM01_Pulse_TI00nFreeRunning 1
#define TM01_Pulse_TI00nRestart 0
/* macro for setting of different functions */
#if TM01_Interval==1
/*
***************************************
** TM01 interval
**
** user set interval time = 0.5s
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_Internal0 : fprs or
TM0n_PRM0n_CountClock_Internal1 : fprs/2^4 or
TM0n_PRM0n_CountClock_Internal2 : fprs/2^6 or
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
Note : Please select the higher frequency you can,
so the precision will be higher.
*/
#define TM01_Clock TM0n_PRM0n_CountClock_Internal2
/*
Value range : 0x0001 - 0xffff
Interval time = (CR00n_value + 1) * count_clock
*/
#define TM01_CR00nValue 0xf423
#define TM01_CR01nValue 0xffff
/* Register settings */
#define TM01_TMC0nValue TM0n_TMC0n_Operation_ClearByMatchCR00n
#define TM01_PRM0nValue TM01_Clock
#define TM01_CRC0nValue TM0n_CRC0n_CR00nMode_Compare
/* Interrupt settings */
#define TM01_INTTM001 1
#define TM01_INTTM011 0
#elif TM01_ExternalEvent==1
/*
***************************************
** TM01 external event
**
** user set valid edges = 10
***************************************
*/
/* Count clock and compare value */
/* Use register bit macro
TM0n_PRM0n_CountClock_TI00nEdge
TM0n_PRM0n_TI00nEdge_Falling or
TM0n_PRM0n_TI01nEdge_Rising or
TM0n_PRM0n_TI01nEdge_Both
*/
#define TM01_Clock TM0n_PRM0n_CountClock_TI00nEdge|\
TM0n_PRM0n_TI00nEdge_Falling
/*
Value range : 0x0001 - 0xffff
Valid edges = CR00n_value + 2 : first time after start
CR00n_value + 1 : second time or later
Note : Valid edge interspace must > 2 * count_clock.
*/
#define TM01_CR00nValue 0x9
#define TM01_CR01nValue 0xffff
/* Register settings */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -