This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Urgent: Problem in Timer interrupt program using AT91SAM7SE512-EK]

Dear Friends,
I am using the Keil uvision3 ARM version,I have developed a new project Timer interrupt program.(downloaded from Atmel website).
In compilation of the code has no problem,after i downloaded into the Flash using ULink2 ARM debugger.

When i RUN the code,there is no output,means getting hang(only once go inside the interrupt loop,not return back ).

Hereby i have attached the source code for your reference.

Could you please advice on this problem.

The source code is
// ----------------------------------------------------------------------------
// File Name : interrupt_timer.c
// Object : Timer interrupt management
// : Use AT91B_LED1 & AT91B_LED2 for status interrupt
// Creation : JPP 11-May-2006
// ----------------------------------------------------------------------------

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

//* Global variable int count_timer0_interrupt; int count_timer1_interrupt;

#define TIMER0_INTERRUPT_LEVEL 1
#define TIMER1_INTERRUPT_LEVEL 7

/*-----------------*/
/* Clock Selection */
/*-----------------*/
#define TC_CLKS 0x7
#define TC_CLKS_MCK2 0x0
#define TC_CLKS_MCK8 0x1
#define TC_CLKS_MCK32 0x2
#define TC_CLKS_MCK128 0x3
#define TC_CLKS_MCK1024 0x4

//*------------------------- Internal Function --------------------------------
//*----------------------------------------------------------------------------
//* Function Name : AT91F_TC_Open
//* Object : Initialize Timer Counter Channel and enable is clock
//* Input Parameters : <tc_pt> = TC Channel Descriptor Pointer
//* <mode> = Timer Counter Mode
//* : <TimerId> = Timer peripheral ID definitions
//* Output Parameters : None
//*----------------------------------------------------------------------------
void AT91F_TC_Open ( AT91PS_TC TC_pt, unsigned int Mode, unsigned int TimerId)
//* Begin
{ unsigned int dummy;

//* First, enable the clock of the TIMER AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC, 1<< TimerId ) ;

//* Disable the clock and the interrupts TC_pt->TC_CCR = AT91C_TC_CLKDIS ; TC_pt->TC_IDR = 0xFFFFFFFF ;

//* Clear status bit dummy = TC_pt->TC_SR; //* Suppress warning variable "dummy" was set but never used dummy = dummy; //* Set the Mode of the Timer Counter TC_pt->TC_CMR = Mode| AT91C_TC_CPCTRG ;

TC_pt->TC_RC= 0xB71B;//0x12F4; =(Time * MCK)/1024 //0x5B8D;//500Ms //* Enable the clock TC_pt->TC_CCR = (AT91C_TC_CLKEN | AT91C_TC_SWTRG ) ;
//* End
} //*------------------------- Interrupt Function -------------------------------

//*----------------------------------------------------------------------------
//* Function Name : timer0_c_irq_handler
//* Object : C handler interrupt function call by the interrupts
//* assembling routine
//* Output Parameters : increment count_timer0_interrupt
//*---------------------------------------------------------------------------- void timer0_c_irq_handler(void)
{ AT91PS_TC TC_pt = AT91C_BASE_TC0; unsigned int dummy; //* AcknowAT91B_LEDge interrupt status dummy = TC_pt->TC_SR; //* Suppress warning variable "dummy" was set but never used dummy = dummy; //count_timer0_interrupt++; //* 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); } /*if ( (AT91F_PIO_GetInput(AT91C_BASE_PIOC) & HEARTBT_OUTPUT ) == HEARTBT_OUTPUT ) { AT91F_PIO_ClearOutput(AT91C_BASE_PIOC, HEARTBT_OUTPUT); } else { AT91F_PIO_SetOutput( AT91C_BASE_PIOC, HEARTBT_OUTPUT); } */
} //*----------------------------------------------------------------------------
//* Function Name : timer1_c_irq_handler
//* Object : C handler interrupt function call by the interrupts
//* assembling routine
//* Output Parameters : increment count_timer1_interrupt
//*----------------------------------------------------------------------------
// void timer1_c_irq_handler(void)
//{
// AT91PS_TC TC_pt = AT91C_BASE_TC1;
// unsigned int dummy; //* AcknowAT91B_LEDge interrupt status
// dummy = TC_pt->TC_SR; //* Suppress warning variable "dummy" was set but never used
// dummy = dummy;
// count_timer1_interrupt++;

//* Read the output state // if ( (AT91F_PIO_GetInput(AT91D_BASE_PIO_LED) & AT91B_LED2 ) == AT91B_LED2 ) // { // AT91F_PIO_ClearOutput( AT91D_BASE_PIO_LED, AT91B_LED2 ); // } else { // AT91F_PIO_SetOutput( AT91D_BASE_PIO_LED, AT91B_LED2 ); // }
//}
//*-------------------------- External Function -------------------------------

//*----------------------------------------------------------------------------
//* Function Name : timer_init
//* Object : Init timer counter
//* Input Parameters : none
//* Output Parameters : TRUE
//*----------------------------------------------------------------------------
void timer_init ( void )
//* Begin
{ //init the timer interrupt counter count_timer0_interrupt=0; count_timer1_interrupt=0;

//* Open timer0 AT91F_TC_Open(AT91C_BASE_TC0,TC_CLKS_MCK1024,AT91C_ID_TC0);

//* Open Timer 0 interrupt AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_TC0, TIMER0_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, timer0_c_irq_handler); AT91C_BASE_TC0->TC_IER = AT91C_TC_CPCS; // IRQ enable CPC AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_TC0);

//* Open timer1 //AT91F_TC_Open(AT91C_BASE_TC1,TC_CLKS_MCK128,AT91C_ID_TC1);

//* Open Timer 1 interrupt /*AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_TC1, TIMER1_INTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, timer1_c_irq_handler); AT91C_BASE_TC1->TC_IER = AT91C_TC_CPCS; // IRQ enable CPC AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_TC1);*/

//* Start timer0 AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG ;

//* Start timer1 // AT91C_BASE_TC1->TC_CCR = AT91C_TC_SWTRG ;

//* End
}

With Regards & Thanks, Murthy.R

0