hi
i hve attached m program
#include "xparameters.h"
#include "stdio.h"
#include "xutil.h"
#include "xgpio_l.h" /* general-purpose I/O peripheral controlfunctions */
#include "xtmrctr_l.h" /* timer/counter peripheral control functions */
#include "xintc_l.h" /* interrupt controller peripheral controlfunctions */
unsigned int timer_count = 10000000; /* initial timer period in OPBcycles ~= 0.3 sec */
unsigned int led_data = 0;
void timer_int_handler(void *baseaddr_p)
{
unsigned int csr;
/* Read timer 0 CSR to see if it requested the interrupt */
csr = XTmrCtr_mGetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0);
if (csr & XTC_CSR_INT_OCCURED_MASK)
{
/* Increment led_count in a johnson-counter pattern */
led_data = led_data +1;
if(led_data > 16)
led_data = 0;
XGpio_mSetDataReg(XPAR_LEDS_BASEADDR, 1, led_data);
}
/* Clear the timer interrupt */
XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0, csr);
}
/* Interrupt test routine */
void InterruptTest(void)
{
/* Enable MicroBlaze interrupts */
microblaze_enable_interrupts();
/* Start the interrupt controller */
XIntc_mMasterEnable(XPAR_OPB_INTC_0_BASEADDR);
/* Set the gpio for LEDs as output */
XGpio_mSetDataDirection(XPAR_LEDS_BASEADDR, 1, 0x00000000);
/* Set the number of cycles the timer counts before interrupting */
XTmrCtr_mSetLoadReg(XPAR_OPB_TIMER_1_BASEADDR, 0, timer_count);
/* Reset the timers, and clear interrupts */
XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0,XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK );
/* Enable timer and UART interrupt requests in the interrupt
controller */
XIntc_mEnableIntr(XPAR_OPB_INTC_0_BASEADDR,XPAR_OPB_TIMER_1_INTERRUPT_MASK);
/* Start the timers */
XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0,XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK |
XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);
/* Disable MicroBlaze interrupts */
//microblaze_disable_interrupts();
}
int main (void)
{
InterruptTest() ;
}