top10_fixcyc.c
来自「瑞萨CAN通讯单片机程序」· C语言 代码 · 共 92 行
C
92 行
/*""FILE COMMENT""*****************************************************
* M32R C Programming Rev. 1.00
* < Sample Program for TOP10 continuous output(fixed cycle) mode >
*
* Copyright (c) 2003 Renesas Technology Corporation
* And Renesas Solutions Corporation
* All Rights Reserved
*********************************************************************/
/************************************************************************/
/* Include file */
/************************************************************************/
#include "..\inc\sfr32170_pragma.h"
/************************************************************************/
/* Function prototype declaration */
/************************************************************************/
void TOP10_FixCyc_init(void); /* Set TOP10 continuous output mode (fixed cycle interrupt) */
void TOP10_FixCycInt(void); /* Process fixed cycle interrupt (user processing) */
/************************************************************************/
/* Define macro */
/************************************************************************/
/*** Continuous output : Fixed cycle(TOP10) ***/
/* 0123 4567 89AB CDEF */
#define TOP10_MASK (unsigned short)0x3013 /* 0011 0000 0001 0011B */
#define TOP10_CntOutput (unsigned short)0x2010 /* 0010 0000 0001 0000B */
/* || | ++- Select clock bus 0 */
/* || +------ Select enable source */
/* ++---------------- TOP10 continuous output mode */
#define TOP10_ILevel (unsigned char)0 /* MJT output interrupt 5 (TOP10) interrupt priority level */
#define TOP10_Cycle (unsigned short)5000 - 1 /* TOP10 interrupt cycle */
/*""FUNC COMMENT""*******************************************************
* Function name: TOP10_FixCyc_init()
*-----------------------------------------------------------------------
* Description : TOP10 interrupt cycleInitial settings necessary to generate an interrupt at fixed intervals while
* : driving TOP10 in continuous output mode
* : - While driving TOP10 in continuous output mode, this function generates an interrupt at fixed
* : intervals
* : - No signals are output from TO10
* : - The count source used for this operation is clock bus 0
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes : The prescaler, clock bus, etc. are set separately from the above
* : Must be executed while interrupts are disabled
*""FUNC COMMENT END""***************************************************/
void TOP10_FixCyc_init()
{
/*** Disabling TOP10 (TO10) output ***/
P10MOD &= ~0x20; /* Disable TOP10 (TO10 output) against output .. Select port P102 output */
/*** Setting continuous output mode (TOP10) ***/
IMJTOCR5 = TOP10_ILevel; /* Set MJT output interrupt 5 (TOP10) interrupt priority level */
TOP810CR = ( TOP810CR & ~TOP10_MASK) | TOP10_CntOutput; /* Set TOP10 continuous output mode */
TOP10CT = TOP10_Cycle; /* Set initial value in TOP10 counter */
TOP10RL = TOP10_Cycle; /* Set initial value in TOP10 reload register */
TOPPRO &= ~TOP10PRO; /* Enable TOP10 enable protect */
TOPCEN = 0xffff; /* Enable TOP10 count */
}
#if 0
/*""FUNC COMMENT""*******************************************************
* Function name: TOP10_FixCycInt()
*-----------------------------------------------------------------------
* Description : Fixed cycle interrupt processing
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes : -
*""FUNC COMMENT END""***************************************************/
void TOP10_FixCycInt()
{
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?