timer1.c

来自「TI公司2407的TIMER1测试程序」· C语言 代码 · 共 108 行

C
108
字号
#include  "240x_c.h"

int flag ;
int flagmain ;  
unsigned int k=0,j=0; 

int m_scsr=0,m_wdcr=0,m_imr=0,m_ifr=0;
int t_imr=0,t_ifr=0,t_ticon=0,t_t1pr=0,t_t1cnt=0;

void inline disable()
{
	asm( " setc INTM " ) ;
}
 
 
void inline enable()
{
	asm( " clrc INTM " ) ;
} 

initial()                 /* system initial */
{
	asm( " setc SXM " ) ;
	asm( " clrc OVM " ) ;
	asm( " clrc CNF " ) ;                 /* B0 for data */
	
	
	
	*SCSR1 	= 0xFFFF;          /*CLKIN=6M,CLKOUT=24M,*SCSR1	= 0x81FE;,*/ 
	*WDCR 	= 0x00E8 ;            /* disable watch dog */
	*MCRB=0x0000;
	*IMR 	= 0x0002;          /*开CAN中断,int,int2*/
	*IFR 	= 0xFFFF;          /*清除所有中断标志*/
} 


int timer1int()
{
	*EVAIMRA = 0x0080;/**EVAIMRA | 0x0080 ;  */
	*EVAIFRA = *EVAIFRA | 0x0080 ; 
	t_ifr		= *EVAIFRA;
	*T1CON 	= 0x1604 ;
	*T1PR 	= 0x0077 ;
	*T1CNT	= 0x0000 ;
	 
	 *IFR 	= 0xFFFF;
}


void interrupt c_int2()
{
	k++;
	flag 	= *EVAIFRA & 0x0080 ;
	if (flag != 0x0080) 
	{
		enable() ;
		return ;
	} 
	
	*T1CNT	= 0x0000;
	*EVAIFRA 	= *EVAIFRA | 0x0780;
	enable() ;
	
}              

void interrupt nothing()
{
	enable() ;

}              


main()
{
	disable() ;
	initial() ;
	timer1int() ;
	enable() ;
	*T1CON = *T1CON | 0x0040 ;
	while(1)
	{ j++;
t_t1cnt	= *T1CNT;	
	m_scsr	= *SCSR1;
t_t1cnt	= *T1CNT;
	m_wdcr	= *WDCR;
	m_imr	= *IMR;
	m_ifr	= *IFR; 
t_t1cnt	= *T1CNT;
 t_imr		= *EVAIMRA;
 t_ifr		= *EVAIFRA;
 t_ticon	= *T1CON; 
t_t1cnt	= *T1CNT;
 t_t1pr		= *T1PR;
 t_t1cnt	= *T1CNT;
	
/*	timer1int() ;         
	*T1CON = 0x0040 ;     T1CON | 0x0040 ; */

    t_t1cnt	= *T1CNT;
    t_t1cnt	= *T1CNT;
    t_t1cnt	= *T1CNT;
    t_t1cnt	= *T1CNT;
    t_t1cnt	= *T1CNT;
    


	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?