📄 tid1_fixcyc_main.c
字号:
/*""FILE COMMENT""*****************************************************
* M32R C Programming Rev. 1.00
* < Sample Program for TID1 fixed cycle count mode (main routine) >
*
* Copyright (c) 2003 Renesas Technology Corporation
* And Renesas Solutions Corporation
* All Rights Reserved
*********************************************************************/
/************************************************************************/
/* Include file */
/************************************************************************/
#include "..\inc\sfr32170_pragma.h"
/************************************************************************/
/* Function prototype declaration */
/************************************************************************/
void main(void); /* Main function */
void init_func(void); /* Initial setup function */
void port_init(void); /* Initialize port */
void timer_init(void); /* Timer initialization */
void TID1_FixCycInt(void); /* Fixed cycle interrupt processing */
/************************************************************************/
/* Definition of external reference */
/************************************************************************/
extern void DisInt( void); /* Interrupt disable function */
extern void EnInt( void); /* Interrupt enable function */
extern void TID1_FixCyc_init( void); /* Initialize TID1 fixed cycle count mode */
/*""FUNC COMMENT""*******************************************************
* Function name: timer_init()
*-----------------------------------------------------------------------
* Description : Timer initialization
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes :
*""FUNC COMMENT END""***************************************************/
void timer_init(void)
{
PRS4 = ( 100 - 1); /* Set prescaler(10us@10MHz) */
}
/*""FUNC COMMENT""*******************************************************
* Function name: port_init()
*-----------------------------------------------------------------------
* Description : Initialize port
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes :
*""FUNC COMMENT END""***************************************************/
void port_init(void)
{
P11DATA = 0x00; /* Output data (must be set prior to mode) */
P11DIR = 0xff; /* P110-P117 : Output mode */
P11MOD = 0x00; /* P110-P117 : Input/output port */
}
/*""FUNC COMMENT""*******************************************************
* Function name: init_func()
*-----------------------------------------------------------------------
* Description : Call various initialization functions
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes :
*""FUNC COMMENT END""***************************************************/
void init_func(void)
{
timer_init(); /* Initialize those related to timer */
port_init(); /* Initialize those related to port */
}
/*""FUNC COMMENT""*******************************************************
* Function name: main()
*-----------------------------------------------------------------------
* Description : While using TID1 in fixed cycle count mode, this function generates an interrupt at intervals of.
* : 50 ms (when the source clock frequency = 10 MHz) to increment the LED (port 11) data.
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes :
*""FUNC COMMENT END""***************************************************/
void main(void)
{
/*** Initializing microcomputer ***/
init_func();
DisInt(); /* Disable interrupt */
TID1_FixCyc_init(); /* Start TID1 count */
EnInt(); /* Enable interrupt */
while( 1 ); /* Wait for interrupt (infinite loop) */
}
/*""FUNC COMMENT""*******************************************************
* Function name: TID1_FixCycInt()
*-----------------------------------------------------------------------
* Description : Process fixed cycle interrupt
*-----------------------------------------------------------------------
* Argument : -
*-----------------------------------------------------------------------
* Returns : -
*-----------------------------------------------------------------------
* Notes : -
*""FUNC COMMENT END""***************************************************/
void TID1_FixCycInt()
{
P11DATA++; /* Increment port in interrupt generated */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -