Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

anyone can help m in edk

Status
Not open for further replies.

ck_nandy

Newbie level 6
Joined
Apr 28, 2008
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,362
hi
the task given m in edk is to glow an set of leds using a timer interrupt.

i know ,it is an easy task to do . i dnt know were am i going worng.

Pls help m.
 

Hi,
Attach your codes or explain your exact problem plz.
 

    ck_nandy

    Points: 2
    Helpful Answer Positive Rating
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() ;


}
 

Hi ck_nandy,

I attach the code needed to adjust interrupt routine in my own code(it's not timer but not important).
I add some comments for you, I hope it could help.

Tell me plz, if anything is not clear.

Regards.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top