⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interrupt_timer.c

📁 AT91SAM7S64的定时
💻 C
字号:
//*----------------------------------------------------------------------------
//*      ATMEL Microcontroller Software Support  -  ROUSSET  -
//*----------------------------------------------------------------------------
//* The software is delivered "AS IS" without warranty or condition of any
//* kind, either express, implied or statutory. This includes without
//* limitation any warranty or condition with respect to merchantability or
//* fitness for any particular purpose, or against the infringements of
//* intellectual property rights of others.
//*----------------------------------------------------------------------------
//* File Name           : interrupt_timer.c
//* Object              : Timer interrupt management
//*                     : Use LED7 & LED8 for status interrupt
//*
//* 1.0 24/Jun/04 JPP   : Creation
//* 1.1 29/Aug/05 JPP   : Update AIC definion
//*----------------------------------------------------------------------------

// Include Standard LIB  files
#include "Board.h"

#define TIMERPIT_INTERRUPT_LEVEL		1

//*------------------------- Interrupt Function -------------------------------

//*----------------------------------------------------------------------------
//* Function Name       : timer0_c_irq_handler
//* Object              : C handler interrupt function called by the interrupts
//*                       assembling routine
//* Output Parameters   : increment count_timer0_interrupt
//*----------------------------------------------------------------------------
__ramfunc void timer_c_irq_handler(void)
{
    unsigned int status;
    //* Interrupt Acknowledge
    status = AT91C_BASE_PITC->PITC_PIVR;  //读PIT_PIVR清除中断
    status =status;
    // AT91C_BASE_DBGU->DBGU_THR = '*';
    //* Read the output state
    if ((AT91F_PIO_GetInput(AT91C_BASE_PIOA) & LED1 ) == LED1 ) 
       {  
          AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, LED1 );
       }
       else
       {  
          AT91F_PIO_SetOutput( AT91C_BASE_PIOA, LED1 );
       }
}

//*-------------------------- External Function -------------------------------

//*----------------------------------------------------------------------------
//* Function Name       : timer_init
//* Object              : Init timer counter
//* Input Parameters    : none
//* Output Parameters   : TRUE
//*----------------------------------------------------------------------------
void timer_init ( void )
//* Begin
{  
    //* Open Timer PIT interrupt      
	AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, 
                                AT91C_ID_SYS, 
                                TIMERPIT_INTERRUPT_LEVEL,
                                AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE, 
                                timer_c_irq_handler);
        
        AT91F_PITInit(AT91C_BASE_PITC,PIV,MCK);
        //AT91C_BASE_PITC->PITC_PIMR = AT91C_PITC_PITEN | AT91C_PITC_PITIEN | (((MCK/16)*PIV)/1000-1) ; 
        AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITIEN;
        
	AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_SYS);
        
//* End
}

⌨️ 快捷键说明

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