I am trying to use a timer for regular interrupt in microblaze. I am using edk 9.2i and spartan 3a dsp 1800a. Even following a simple lab example widely used by beginners didn't work: http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf I have connected all the interrupt ports correctly as evident from the following portion of the mhs file: BEGIN microblaze PARAMETER HW_VER = 7.00.a ........... ........... PORT INTERRUPT = interrupt END BEGIN xps_timer PARAMETER INSTANCE = delay PARAMETER HW_VER = 1.00.a PARAMETER C_ONE_TIMER_ONLY = 1 PARAMETER C_BASEADDR = 0x8141c200 PARAMETER C_HIGHADDR = 0x8141c3ff BUS_INTERFACE SPLB = mb_plb PORT Interrupt = timer1 PORT CaptureTrig0 = net_gnd END BEGIN xps_intc PARAMETER INSTANCE = xps_intc_0 PARAMETER HW_VER = 1.00.a PARAMETER C_BASEADDR = 0x81418000 PARAMETER C_HIGHADDR = 0x814181ff BUS_INTERFACE SPLB = mb_plb PORT Irq = interrupt PORT Intr = timer1 END Now for the software settings since I am using edk 9.2i, it does not have option for registering our interrupt handler in software platform settings window (which is what the lab suggests), I used the microblaze_register_handler(...) function ( I took me 3 days to figure out this), but I still don't get how it works differently from the function XIntc_RegisterHandler. The portion of C file is as follows: void timer_int_handler(void * baseaddr_p) { /* Add variable declarations here */ unsigned int csr; /* Read timer 0 CSR to see if it raised the interrupt */ csr = XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,0); /* If the interrupt occurred, then increment a counter */ /* and set one_second_flag to 1 */ if (csr & XTC_CSR_INT_OCCURED_MASK ) { count ++; one_second_flag = 1; } /* Display the count on the LEDs */ XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); /* Print the count using the UART*/ xil_printf("count value is: %x\n\r", count); /* Clear the timer interrupt */ XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); } int main() { int count_mod_3; //registering an interrupt handler microblaze_register_handler((XInterruptHandler) timer_int_handler, (void *)0); /* Register the Timer interrupt handler in the vector table */ XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, XPAR_XPS_INTC_0_DELAY_INTERRUPT_INTR, (XInterruptHandler) timer_int_handler, (void *)XPAR_DELAY_BASEADDR); /* Enable MicroBlaze Interrupts */ microblaze_enable_interrupts(); /* Initialize and set the direction of the GPIO connected to LEDs */ XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); XGpio_SetDataDirection(&gpio,LEDChan, 0); /* Start the interrupt controller */ XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); /* Set the gpio as output on high 8 bits (LEDs)*/ XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); xil_printf("The value of count = %d\n\r", count); /* Set the number of cycles the timer counts before interrupting */ XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, (timer_count*timer_count) * 50000000); /* Reset the timers, and clear interrupts */ XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); /* Enable timer interrupts in the interrupt controller */ XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MASK); /* Start the timers */ XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); /* Wait for interrupts to occur */ while(1) { if(one_second_flag){ count_mod_3 = count % 3; if(count_mod_3 == 0) xil_printf("Interrupt taken at %d seconds \n\r",count); one_second_flag=0; xil_printf("."); } } } When I run the system, the value of count does not change from 1. What could be the problem?
timer interrupt problem: microblaze
Started by ●November 24, 2008
Summary
A developer is troubleshooting an issue where a timer interrupt is not triggering on a MicroBlaze system using EDK 9.2i and a Spartan-3A DSP 1800A board.
A developer is troubleshooting an issue where a timer interrupt is not triggering on a MicroBlaze system using EDK 9.2i and a Spartan-3A DSP 1800A board. Despite following standard lab examples and verifying MHS file connections, the interrupt handler remains uncalled after the first execution.
The discussion highlights critical software requirements such as using the volatile keyword for flags and properly registering handlers using both the MicroBlaze and Interrupt Controller (INTC) APIs.
- Variables updated within an ISR must be declared as volatile to prevent the compiler from optimizing away conditional checks in the main loop.
- Interrupts must be enabled at three levels: the peripheral (timer), the interrupt controller (INTC), and the MicroBlaze processor core.
- Correct software registration requires both microblaze_register_handler and XIntc_RegisterHandler to link the hardware interrupt to the C function.
- Using established reference designs from vendors like Avnet can help verify if the hardware configuration (MHS file) or software code is at fault.
MicroBlazeXilinx EDKInterrupt HandlingFPGA Embedded Design
Reply by ●November 25, 20082008-11-25
Hi! I wonder, whether "one_second_flag" is declared as volatile? If not, the compiler optimizes your if-statement in the while(1) loop away. You can check this by using mb-objdump. Cheers, Matthias bish schrieb:> I am trying to use a timer for regular interrupt in microblaze. I am > using edk 9.2i and spartan 3a dsp 1800a. > Even following a simple lab example widely used by beginners didn't > work: http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > I have connected all the interrupt ports correctly as evident from the > following portion of the mhs file: > BEGIN microblaze > PARAMETER HW_VER = 7.00.a > ........... > ........... > PORT INTERRUPT = interrupt > END > > BEGIN xps_timer > PARAMETER INSTANCE = delay > PARAMETER HW_VER = 1.00.a > PARAMETER C_ONE_TIMER_ONLY = 1 > PARAMETER C_BASEADDR = 0x8141c200 > PARAMETER C_HIGHADDR = 0x8141c3ff > BUS_INTERFACE SPLB = mb_plb > PORT Interrupt = timer1 > PORT CaptureTrig0 = net_gnd > END > > BEGIN xps_intc > PARAMETER INSTANCE = xps_intc_0 > PARAMETER HW_VER = 1.00.a > PARAMETER C_BASEADDR = 0x81418000 > PARAMETER C_HIGHADDR = 0x814181ff > BUS_INTERFACE SPLB = mb_plb > PORT Irq = interrupt > PORT Intr = timer1 > END > > > Now for the software settings since I am using edk 9.2i, it does not > have option for registering our interrupt handler in software platform > settings window (which is what the lab suggests), I used the > microblaze_register_handler(...) function ( I took me 3 days to figure > out this), but I still don't get how it works differently from the > function XIntc_RegisterHandler. > The portion of C file is as follows: > void timer_int_handler(void * baseaddr_p) { > /* Add variable declarations here */ > unsigned int csr; > /* Read timer 0 CSR to see if it raised the interrupt */ > csr = XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,0); > /* If the interrupt occurred, then increment a counter */ > /* and set one_second_flag to 1 */ > if (csr & XTC_CSR_INT_OCCURED_MASK ) { > count ++; > one_second_flag = 1; > } > > /* Display the count on the LEDs */ > XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > /* Print the count using the UART*/ > xil_printf("count value is: %x\n\r", count); > /* Clear the timer interrupt */ > XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > } > > int main() { > > int count_mod_3; > > //registering an interrupt handler > microblaze_register_handler((XInterruptHandler) timer_int_handler, > (void *)0); > > /* Register the Timer interrupt handler in the vector table */ > XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > XPAR_XPS_INTC_0_DELAY_INTERRUPT_INTR, > (XInterruptHandler) timer_int_handler, > (void *)XPAR_DELAY_BASEADDR); > /* Enable MicroBlaze Interrupts */ > microblaze_enable_interrupts(); > > > /* Initialize and set the direction of the GPIO connected to LEDs */ > XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > XGpio_SetDataDirection(&gpio,LEDChan, 0); > > /* Start the interrupt controller */ > XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > /* Set the gpio as output on high 8 bits (LEDs)*/ > XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > xil_printf("The value of count = %d\n\r", count); > > /* Set the number of cycles the timer counts before interrupting */ > XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > (timer_count*timer_count) * 50000000); > > /* Reset the timers, and clear interrupts */ > XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > /* Enable timer interrupts in the interrupt controller */ > XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MASK); > > /* Start the timers */ > XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); > > /* Wait for interrupts to occur */ > while(1) { > if(one_second_flag){ > count_mod_3 = count % 3; > if(count_mod_3 == 0) > xil_printf("Interrupt taken at %d seconds \n\r",count); > one_second_flag=0; > xil_printf("."); > } > } > } > > When I run the system, the value of count does not change from 1. What > could be the problem? >
Reply by ●November 25, 20082008-11-25
On Nov 25, 12:25=A0pm, Matthias Alles <REMOVEallesCAPIT...@NOeit.SPAMuni- kl.de> wrote:> Hi! > > I wonder, whether "one_second_flag" is declared as volatile? If not, the > compiler optimizes your if-statement in the while(1) loop away. You can > check this by using mb-objdump.I tried using the volatile for one_second_flag, still it does not work. It just prints "the value of count =3D 1" once in terminal and nothing happens then.> > Cheers, > Matthias > > bish schrieb: > > > > > I am trying to use a timer for regular interrupt in microblaze. I am > > using edk 9.2i and spartan 3a dsp 1800a. > > Even following a simple lab example widely used by beginners didn't > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > I have connected all the interrupt ports correctly as evident from the > > following portion of the mhs file: > > BEGIN microblaze > > =A0PARAMETER HW_VER =3D 7.00.a > > ........... > > ........... > > PORT INTERRUPT =3D interrupt > > END > > > BEGIN xps_timer > > =A0PARAMETER INSTANCE =3D delay > > =A0PARAMETER HW_VER =3D 1.00.a > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > =A0BUS_INTERFACE SPLB =3D mb_plb > > =A0PORT Interrupt =3D timer1 > > =A0PORT CaptureTrig0 =3D net_gnd > > END > > > BEGIN xps_intc > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > =A0PARAMETER HW_VER =3D 1.00.a > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > =A0BUS_INTERFACE SPLB =3D mb_plb > > =A0PORT Irq =3D interrupt > > =A0PORT Intr =3D timer1 > > END > > > Now for the software settings since I am using edk 9.2i, it does not > > have option for registering our interrupt handler in software platform > > settings window (which is what the lab suggests), I used the > > microblaze_register_handler(...) function ( I took me 3 days to figure > > out this), =A0but I still don't get how it works differently from the > > function XIntc_RegisterHandler. > > The portion of C file is as follows: > > void timer_int_handler(void * baseaddr_p) { > > =A0 =A0 /* Add variable declarations here */ > > =A0 =A0unsigned int csr; > > =A0 =A0/* Read timer 0 CSR to see if it raised the interrupt */ > > =A0 =A0csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,0); > > =A0 =A0/* If the interrupt occurred, then increment a counter */ > > =A0 =A0/* and set one_second_flag to 1 */ > > =A0 =A0if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > =A0 =A0 =A0 =A0 =A0 =A0count ++; > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag =3D 1; > > =A0 =A0} > > > =A0 =A0/* Display the count on the LEDs */ > > =A0 =A0XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > > =A0 =A0/* Print the count using the UART*/ > > =A0 =A0xil_printf("count value is: %x\n\r", count); > > =A0 =A0/* Clear the timer interrupt */ > > =A0 =A0XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > > } > > > int main() { > > > =A0 int count_mod_3; > > > =A0 //registering an interrupt handler > > =A0 microblaze_register_handler((XInterruptHandler) timer_int_handler, > > (void *)0); > > > =A0 /* Register the Timer interrupt handler in the vector table */ > > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR_XPS_INT=C_0_DELAY_INTERRUPT_INTR,> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterruptH=andler) timer_int_handler,> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)XPAR=_DELAY_BASEADDR);> > =A0 /* Enable MicroBlaze Interrupts */ > > =A0 microblaze_enable_interrupts(); > > > =A0 /* Initialize and set the direction of the GPIO connected to LEDs *=/> > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > > =A0 /* Start the interrupt controller */ > > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > > =A0 xil_printf("The value of count =3D %d\n\r", count); > > > =A0 /* Set the number of cycles the timer counts before interrupting */ > > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > > (timer_count*timer_count) * 50000000); > > > =A0 /* Reset the timers, and clear interrupts */ > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > > =A0 /* Enable timer interrupts in the interrupt controller */ > > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MASK); > > > =A0 /* Start the timers */ > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0==A0 =A0 =A0 =A0XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);> > > =A0 /* Wait for interrupts to occur */ > > =A0 while(1) { > > =A0 =A0if(one_second_flag){ > > =A0 =A0 =A0 =A0 =A0 =A0count_mod_3 =3D count % 3; > > =A0 =A0 =A0 =A0 =A0 =A0if(count_mod_3 =3D=3D 0) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xil_printf("Interrupt taken at %=d seconds \n\r",count);> > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag=3D0; > > =A0 =A0 =A0 =A0 =A0 =A0xil_printf("."); > > =A0 =A0 =A0 =A0 =A0 =A0} > > =A0 =A0} > > } > > > When I run the system, the value of count does not change from 1. What > > could be the problem?- Hide quoted text - > > - Show quoted text -
Reply by ●November 25, 20082008-11-25
There is a 9.2 MicroBlaze Timer Interrupt example done by Avnet at www.em.avnet.com/virtex4lx-sx-mb-dev, then click Support Files & Downloads. Bryan On Nov 24, 7:19=A0pm, bish <bishes...@gmail.com> wrote:> I am trying to use a timer for regular interrupt in microblaze. I am > using edk 9.2i and spartan 3a dsp 1800a. > Even following a simple lab example widely used by beginners didn't > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > I have connected all the interrupt ports correctly as evident from the > following portion of the mhs file: > BEGIN microblaze > =A0PARAMETER HW_VER =3D 7.00.a > ........... > ........... > PORT INTERRUPT =3D interrupt > END > > BEGIN xps_timer > =A0PARAMETER INSTANCE =3D delay > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT Interrupt =3D timer1 > =A0PORT CaptureTrig0 =3D net_gnd > END > > BEGIN xps_intc > =A0PARAMETER INSTANCE =3D xps_intc_0 > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_BASEADDR =3D 0x81418000 > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT Irq =3D interrupt > =A0PORT Intr =3D timer1 > END > > Now for the software settings since I am using edk 9.2i, it does not > have option for registering our interrupt handler in software platform > settings window (which is what the lab suggests), I used the > microblaze_register_handler(...) function ( I took me 3 days to figure > out this), =A0but I still don't get how it works differently from the > function XIntc_RegisterHandler. > The portion of C file is as follows: > void timer_int_handler(void * baseaddr_p) { > =A0 =A0 /* Add variable declarations here */ > =A0 =A0 =A0 =A0 unsigned int csr; > =A0 =A0 =A0 =A0 /* Read timer 0 CSR to see if it raised the interrupt */ > =A0 =A0 =A0 =A0 csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,=0);> =A0 =A0 =A0 =A0 /* If the interrupt occurred, then increment a counter */ > =A0 =A0 =A0 =A0 /* and set one_second_flag to 1 */ > =A0 =A0 =A0 =A0 if (csr & XTC_CSR_INT_OCCURED_MASK ) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 count ++; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 one_second_flag =3D 1; > =A0 =A0 =A0 =A0 } > > =A0 =A0 =A0 =A0 /* Display the count on the LEDs */ > =A0 =A0 =A0 =A0 XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > =A0 =A0 =A0 =A0 /* Print the count using the UART*/ > =A0 =A0 =A0 =A0 xil_printf("count value is: %x\n\r", count); > =A0 =A0 =A0 =A0 /* Clear the timer interrupt */ > =A0 =A0 =A0 =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > > } > > int main() { > > =A0 int count_mod_3; > > =A0 //registering an interrupt handler > =A0 microblaze_register_handler((XInterruptHandler) timer_int_handler, > (void *)0); > > =A0 /* Register the Timer interrupt handler in the vector table */ > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR_XPS_INTC_=0_DELAY_INTERRUPT_INTR,> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterruptHan=dler) timer_int_handler,> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)XPAR_D=ELAY_BASEADDR);> =A0 /* Enable MicroBlaze Interrupts */ > =A0 microblaze_enable_interrupts(); > > =A0 /* Initialize and set the direction of the GPIO connected to LEDs */ > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > =A0 /* Start the interrupt controller */ > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > =A0 xil_printf("The value of count =3D %d\n\r", count); > > =A0 /* Set the number of cycles the timer counts before interrupting */ > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > (timer_count*timer_count) * 50000000); > > =A0 /* Reset the timers, and clear interrupts */ > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > =A0 /* Enable timer interrupts in the interrupt controller */ > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MASK); > > =A0 /* Start the timers */ > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ==A0 =A0 =A0 =A0 =A0 =A0 XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK)= ;> > =A0 /* Wait for interrupts to occur */ > =A0 while(1) { > =A0 =A0 =A0 =A0 if(one_second_flag){ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 count_mod_3 =3D count % 3; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(count_mod_3 =3D=3D 0) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xil_printf("Interrupt tak=en at %d seconds \n\r",count);> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 one_second_flag=3D0; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xil_printf("."); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 } > > } > > When I run the system, the value of count does not change from 1. What > could be the problem?
Reply by ●November 25, 20082008-11-25
On Nov 26, 2:37=A0am, bish <bishes...@gmail.com> wrote:> On Nov 25, 12:25=A0pm, Matthias Alles <REMOVEallesCAPIT...@NOeit.SPAMuni- > > kl.de> wrote: > > Hi! > > > I wonder, whether "one_second_flag" is declared as volatile? If not, th=e> > compiler optimizes your if-statement in the while(1) loop away. You can > > check this by using mb-objdump. > > I tried using the volatile for one_second_flag, still it does not > work. It just prints "the value of count =3D 1" once in terminal and > nothing happens then. > > > > > Cheers, > > Matthias > > > bish schrieb: > > > > I am trying to use a timer for regular interrupt in microblaze. I am > > > using edk 9.2i and spartan 3a dsp 1800a. > > > Even following a simple lab example widely used by beginners didn't > > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > > I have connected all the interrupt ports correctly as evident from th=e> > > following portion of the mhs file: > > > BEGIN microblaze > > > =A0PARAMETER HW_VER =3D 7.00.a > > > ........... > > > ........... > > > PORT INTERRUPT =3D interrupt > > > END > > > > BEGIN xps_timer > > > =A0PARAMETER INSTANCE =3D delay > > > =A0PARAMETER HW_VER =3D 1.00.a > > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > =A0PORT Interrupt =3D timer1 > > > =A0PORT CaptureTrig0 =3D net_gnd > > > END > > > > BEGIN xps_intc > > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > > =A0PARAMETER HW_VER =3D 1.00.a > > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > =A0PORT Irq =3D interrupt > > > =A0PORT Intr =3D timer1 > > > END > > > > Now for the software settings since I am using edk 9.2i, it does not > > > have option for registering our interrupt handler in software platfor=m> > > settings window (which is what the lab suggests), I used the > > > microblaze_register_handler(...) function ( I took me 3 days to figur=e> > > out this), =A0but I still don't get how it works differently from the > > > function XIntc_RegisterHandler. > > > The portion of C file is as follows: > > > void timer_int_handler(void * baseaddr_p) { > > > =A0 =A0 /* Add variable declarations here */ > > > =A0 =A0unsigned int csr; > > > =A0 =A0/* Read timer 0 CSR to see if it raised the interrupt */ > > > =A0 =A0csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,0); > > > =A0 =A0/* If the interrupt occurred, then increment a counter */ > > > =A0 =A0/* and set one_second_flag to 1 */ > > > =A0 =A0if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > > =A0 =A0 =A0 =A0 =A0 =A0count ++; > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag =3D 1; > > > =A0 =A0} > > > > =A0 =A0/* Display the count on the LEDs */ > > > =A0 =A0XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > > > =A0 =A0/* Print the count using the UART*/ > > > =A0 =A0xil_printf("count value is: %x\n\r", count); > > > =A0 =A0/* Clear the timer interrupt */ > > > =A0 =A0XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > > > } > > > > int main() { > > > > =A0 int count_mod_3; > > > > =A0 //registering an interrupt handler > > > =A0 microblaze_register_handler((XInterruptHandler) timer_int_handler=,> > > (void *)0); > > > > =A0 /* Register the Timer interrupt handler in the vector table */ > > > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR_XPS_I=NTC_0_DELAY_INTERRUPT_INTR,> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterrup=tHandler) timer_int_handler,> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)XP=AR_DELAY_BASEADDR);> > > =A0 /* Enable MicroBlaze Interrupts */ > > > =A0 microblaze_enable_interrupts(); > > > > =A0 /* Initialize and set the direction of the GPIO connected to LEDs=*/> > > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > > > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > > > =A0 /* Start the interrupt controller */ > > > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > > > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > > > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > > > =A0 xil_printf("The value of count =3D %d\n\r", count); > > > > =A0 /* Set the number of cycles the timer counts before interrupting =*/> > > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > > > (timer_count*timer_count) * 50000000); > > > > =A0 /* Reset the timers, and clear interrupts */ > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > > > =A0 /* Enable timer interrupts in the interrupt controller */ > > > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MASK)=;> > > > =A0 /* Start the timers */ > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ==A0 =A0 =A0 =A0 =A0XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);> > > > =A0 /* Wait for interrupts to occur */ > > > =A0 while(1) { > > > =A0 =A0if(one_second_flag){ > > > =A0 =A0 =A0 =A0 =A0 =A0count_mod_3 =3D count % 3; > > > =A0 =A0 =A0 =A0 =A0 =A0if(count_mod_3 =3D=3D 0) > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xil_printf("Interrupt taken at=%d seconds \n\r",count);> > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag=3D0; > > > =A0 =A0 =A0 =A0 =A0 =A0xil_printf("."); > > > =A0 =A0 =A0 =A0 =A0 =A0} > > > =A0 =A0} > > > } > > > > When I run the system, the value of count does not change from 1. Wha=t> > > could be the problem?- Hide quoted text - > > > - Show quoted text -Hello, Here is how I set up a timer interrupt in 9.2: void TimerCounterHandler(void *CallBackRef) { print("timer interrupt "); } Int main (void) { XIntc intr_ctrl; XTmrCtr timr; XIntc_Initialize(&intr_ctrl,XPAR_XPS_INTC_0_DEVICE_ID); XTmrCtr_Initialize(&timr,XPAR_XPS_TIMER_1_DEVICE_ID); XIntc_Connect(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_INTERRUPT_INTR, (XInterruptHandler) XTmrCtr_InterruptHandler, (void *)&timr); XIntc_Start(&intr_ctrl, XIN_REAL_MODE); XIntc_Enable(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_INTERRUPT_INTR); XTmrCtr_SetHandler(&timr, (void *)TimerCounterHandler, void); XTmrCtr_SetOptions(&timr, 0, XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION); XTmrCtr_SetResetValue(&timr, 0, 0xF0000000); XTmrCtr_Start(&timr,0); microblaze_enable_interrupts(); while(1){ //wait for interrupts } } If you are using the Intc component, you no longer need to use the microblaze_register_handler function - instead use the XIntc_Connect() function. The XTmrCtr driver provides its own interrupt handler XTmrCtr_InterruptHandler() which you should use to service the interrupt. It will issue a callback to a function of your choice (set with XTmrCtr_SetHandler) Hope this helps, David
Reply by ●November 26, 20082008-11-26
On Nov 26, 3:29=A0am, Bryan <bryan.fletc...@avnet.com> wrote:> There is a 9.2 MicroBlaze Timer Interrupt example done by Avnet atwww.em.=avnet.com/virtex4lx-sx-mb-dev, then click Support Files &> Downloads. >I downloaded V4MB_SX35_interrupt_Design_Rev2_Rev3 example design, it had used two timers, so I commented out the second timer relevant codes and used only a single timer from its system.c file, still the problem is the interrupt handler seems never to be called. I am trying to use a single timer for interrupt and this is the only device to generate an interrupt. Is it possible that the XPS Interrupt Controller when used must need more than one interrupt inputs?? Because I still cannot figure out what the problem is, I have tried quite a few other examples too. Another one I used from other example design has: And this is also not working!!! Can anybody check the following out in edk 9.2: using ONLY ONE TIMER (from XPS_TIMER) and XPS interrupt controller??? Using the code given below:: // Driver instances //static XGpio myGpio; static XTmrCtr myTimer; static XIntc myIntc; // Timer ISR: void timer_a_int_handler(void *CallBackRef/*, Xuint8 TmrCtrNumber*/) { //if (TmrCtrNumber=3D=3D0) { xil_printf("In timer interrupt handler... waiting for 3 seconds\r\n"); //usleep(3000000); xil_printf("Leaving timer interrupt handler ...\r\n"); //} //Clear the interrupt XIntc_Acknowledge (&myIntc,XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR); } // Main: this is the function that is executed at the start of the program. int main(){ //********************** 1. Device initialization and configuration ************************* xil_printf("Setting up peripherals...\r\n"); //Initialize and configuring the timer XTmrCtr_Initialize(&myTimer, XPAR_XPS_TIMER_0_DEVICE_ID); //XTmrCtr_SelfTest(&myTimer, 0); XTmrCtr_SetOptions(&myTimer,(Xuint8)0,XTC_INT_MODE_OPTION | XTC_DOWN_COUNT_OPTION | XTC_AUTO_RELOAD_OPTION); XTmrCtr_SetHandler(&myTimer,(XTmrCtr_Handler) timer_a_int_handler,NULL); //*************** 2. Interrupt controller initialization and configuration ****************** xil_printf("Setting up interrupt controller...\r\n"); XIntc_Initialize(&myIntc, XPAR_XPS_INTC_0_DEVICE_ID); //Attach the ISRs to the interrupt controller driver. XIntc_Connect(&myIntc, XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR, (XInterruptHandler) XTmrCtr_InterruptHandler, =20 &myTimer); XIntc_Start(&myIntc, XIN_REAL_MODE); XIntc_Enable(&myIntc, XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR); //Set the timer to expire every 6 seconds XTmrCtr_SetResetValue(&myTimer, (Xuint8)0, 6 * 50000000); XTmrCtr_Start(&myTimer, (Xuint8)0); xil_printf("Entering loop...\r\n"); while(1){ //xil_printf("in loop..\r\n"); } }> Bryan > > On Nov 24, 7:19=A0pm, bish <bishes...@gmail.com> wrote: > > > > > I am trying to use a timer for regular interrupt in microblaze. I am > > using edk 9.2i and spartan 3a dsp 1800a. > > Even following a simple lab example widely used by beginners didn't > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > I have connected all the interrupt ports correctly as evident from the > > following portion of the mhs file: > > BEGIN microblaze > > =A0PARAMETER HW_VER =3D 7.00.a > > ........... > > ........... > > PORT INTERRUPT =3D interrupt > > END > > > BEGIN xps_timer > > =A0PARAMETER INSTANCE =3D delay > > =A0PARAMETER HW_VER =3D 1.00.a > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > =A0BUS_INTERFACE SPLB =3D mb_plb > > =A0PORT Interrupt =3D timer1 > > =A0PORT CaptureTrig0 =3D net_gnd > > END > > > BEGIN xps_intc > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > =A0PARAMETER HW_VER =3D 1.00.a > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > =A0BUS_INTERFACE SPLB =3D mb_plb > > =A0PORT Irq =3D interrupt > > =A0PORT Intr =3D timer1 > > END > > > Now for the software settings since I am using edk 9.2i, it does not > > have option for registering our interrupt handler in software platform > > settings window (which is what the lab suggests), I used the > > microblaze_register_handler(...) function ( I took me 3 days to figure > > out this), =A0but I still don't get how it works differently from the > > function XIntc_RegisterHandler. > > The portion of C file is as follows: > > void timer_int_handler(void * baseaddr_p) { > > =A0 =A0 /* Add variable declarations here */ > > =A0 =A0 =A0 =A0 unsigned int csr; > > =A0 =A0 =A0 =A0 /* Read timer 0 CSR to see if it raised the interrupt *=/> > =A0 =A0 =A0 =A0 csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADD=R,0);> > =A0 =A0 =A0 =A0 /* If the interrupt occurred, then increment a counter =*/> > =A0 =A0 =A0 =A0 /* and set one_second_flag to 1 */ > > =A0 =A0 =A0 =A0 if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 count ++; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 one_second_flag =3D 1; > > =A0 =A0 =A0 =A0 } > > > =A0 =A0 =A0 =A0 /* Display the count on the LEDs */ > > =A0 =A0 =A0 =A0 XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > > =A0 =A0 =A0 =A0 /* Print the count using the UART*/ > > =A0 =A0 =A0 =A0 xil_printf("count value is: %x\n\r", count); > > =A0 =A0 =A0 =A0 /* Clear the timer interrupt */ > > =A0 =A0 =A0 =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr)=;> > > } > > > int main() { > > > =A0 int count_mod_3; > > > =A0 //registering an interrupt handler > > =A0 microblaze_register_handler((XInterruptHandler) timer_int_handler, > > (void *)0); > > > =A0 /* Register the Timer interrupt handler in the vector table */ > > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR_XPS_INT=C_0_DELAY_INTERRUPT_INTR,> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterruptH=andler) timer_int_handler,> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)XPAR=_DELAY_BASEADDR);> > =A0 /* Enable MicroBlaze Interrupts */ > > =A0 microblaze_enable_interrupts(); > > > =A0 /* Initialize and set the direction of the GPIO connected to LEDs *=/> > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > > =A0 /* Start the interrupt controller */ > > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > > =A0 xil_printf("The value of count =3D %d\n\r", count); > > > =A0 /* Set the number of cycles the timer counts before interrupting */ > > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > > (timer_count*timer_count) * 50000000); > > > =A0 /* Reset the timers, and clear interrupts */ > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > > =A0 /* Enable timer interrupts in the interrupt controller */ > > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MASK); > > > =A0 /* Start the timers */ > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0==A0 =A0 =A0 =A0 =A0 =A0 XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK= );> > > =A0 /* Wait for interrupts to occur */ > > =A0 while(1) { > > =A0 =A0 =A0 =A0 if(one_second_flag){ > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 count_mod_3 =3D count % 3; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if(count_mod_3 =3D=3D 0) > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xil_printf("Interrupt t=aken at %d seconds \n\r",count);> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 one_second_flag=3D0; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 xil_printf("."); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > > =A0 =A0 =A0 =A0 } > > > } > > > When I run the system, the value of count does not change from 1. What > > could be the problem?- Hide quoted text - > > - Show quoted text -
Reply by ●November 26, 20082008-11-26
On Nov 26, 4:58=A0am, David <simianfe...@gmail.com> wrote:> On Nov 26, 2:37=A0am, bish <bishes...@gmail.com> wrote: > > > > > > > On Nov 25, 12:25=A0pm, Matthias Alles <REMOVEallesCAPIT...@NOeit.SPAMun=i-> > > kl.de> wrote: > > > Hi! > > > > I wonder, whether "one_second_flag" is declared as volatile? If not, =the> > > compiler optimizes your if-statement in the while(1) loop away. You c=an> > > check this by using mb-objdump. > > > I tried using the volatile for one_second_flag, still it does not > > work. It just prints "the value of count =3D 1" once in terminal and > > nothing happens then. > > > > Cheers, > > > Matthias > > > > bish schrieb: > > > > > I am trying to use a timer for regular interrupt in microblaze. I a=m> > > > using edk 9.2i and spartan 3a dsp 1800a. > > > > Even following a simple lab example widely used by beginners didn't > > > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > > > I have connected all the interrupt ports correctly as evident from =the> > > > following portion of the mhs file: > > > > BEGIN microblaze > > > > =A0PARAMETER HW_VER =3D 7.00.a > > > > ........... > > > > ........... > > > > PORT INTERRUPT =3D interrupt > > > > END > > > > > BEGIN xps_timer > > > > =A0PARAMETER INSTANCE =3D delay > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > =A0PORT Interrupt =3D timer1 > > > > =A0PORT CaptureTrig0 =3D net_gnd > > > > END > > > > > BEGIN xps_intc > > > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > =A0PORT Irq =3D interrupt > > > > =A0PORT Intr =3D timer1 > > > > END > > > > > Now for the software settings since I am using edk 9.2i, it does no=t> > > > have option for registering our interrupt handler in software platf=orm> > > > settings window (which is what the lab suggests), I used the > > > > microblaze_register_handler(...) function ( I took me 3 days to fig=ure> > > > out this), =A0but I still don't get how it works differently from t=he> > > > function XIntc_RegisterHandler. > > > > The portion of C file is as follows: > > > > void timer_int_handler(void * baseaddr_p) { > > > > =A0 =A0 /* Add variable declarations here */ > > > > =A0 =A0unsigned int csr; > > > > =A0 =A0/* Read timer 0 CSR to see if it raised the interrupt */ > > > > =A0 =A0csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,0); > > > > =A0 =A0/* If the interrupt occurred, then increment a counter */ > > > > =A0 =A0/* and set one_second_flag to 1 */ > > > > =A0 =A0if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > > > =A0 =A0 =A0 =A0 =A0 =A0count ++; > > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag =3D 1; > > > > =A0 =A0} > > > > > =A0 =A0/* Display the count on the LEDs */ > > > > =A0 =A0XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > > > > =A0 =A0/* Print the count using the UART*/ > > > > =A0 =A0xil_printf("count value is: %x\n\r", count); > > > > =A0 =A0/* Clear the timer interrupt */ > > > > =A0 =A0XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > > > > } > > > > > int main() { > > > > > =A0 int count_mod_3; > > > > > =A0 //registering an interrupt handler > > > > =A0 microblaze_register_handler((XInterruptHandler) timer_int_handl=er,> > > > (void *)0); > > > > > =A0 /* Register the Timer interrupt handler in the vector table */ > > > > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR_XPS=_INTC_0_DELAY_INTERRUPT_INTR,> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterr=uptHandler) timer_int_handler,> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)=XPAR_DELAY_BASEADDR);> > > > =A0 /* Enable MicroBlaze Interrupts */ > > > > =A0 microblaze_enable_interrupts(); > > > > > =A0 /* Initialize and set the direction of the GPIO connected to LE=Ds */> > > > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > > > > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > > > > =A0 /* Start the interrupt controller */ > > > > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > > > > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > > > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > > > > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > > > > =A0 xil_printf("The value of count =3D %d\n\r", count); > > > > > =A0 /* Set the number of cycles the timer counts before interruptin=g */> > > > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > > > > (timer_count*timer_count) * 50000000); > > > > > =A0 /* Reset the timers, and clear interrupts */ > > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > > > > =A0 /* Enable timer interrupts in the interrupt controller */ > > > > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_MAS=K);> > > > > =A0 /* Start the timers */ > > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0==A0 =A0 =A0 =A0 =A0XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);> > > > > =A0 /* Wait for interrupts to occur */ > > > > =A0 while(1) { > > > > =A0 =A0if(one_second_flag){ > > > > =A0 =A0 =A0 =A0 =A0 =A0count_mod_3 =3D count % 3; > > > > =A0 =A0 =A0 =A0 =A0 =A0if(count_mod_3 =3D=3D 0) > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xil_printf("Interrupt taken =at %d seconds \n\r",count);> > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag=3D0; > > > > =A0 =A0 =A0 =A0 =A0 =A0xil_printf("."); > > > > =A0 =A0 =A0 =A0 =A0 =A0} > > > > =A0 =A0} > > > > } > > > > > When I run the system, the value of count does not change from 1. W=hat> > > > could be the problem?- Hide quoted text - > > > > - Show quoted text - > > Hello, > > Here is how I set up a timer interrupt in 9.2: > > void TimerCounterHandler(void *CallBackRef) > { > =A0 =A0 =A0 =A0 print("timer interrupt "); > > } > > Int main (void) { > > =A0 =A0 =A0 =A0 XIntc intr_ctrl; > =A0 =A0 =A0 =A0 XTmrCtr timr; > > =A0 =A0 =A0 =A0 XIntc_Initialize(&intr_ctrl,XPAR_XPS_INTC_0_DEVICE_ID); > =A0 =A0 =A0 =A0 XTmrCtr_Initialize(&timr,XPAR_XPS_TIMER_1_DEVICE_ID); > > =A0 =A0 =A0 =A0 XIntc_Connect(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_INT=ERRUPT_INTR,> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterruptHandler=)> XTmrCtr_InterruptHandler, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)&timr); > > =A0 =A0 =A0 =A0 XIntc_Start(&intr_ctrl, XIN_REAL_MODE); > > =A0 =A0 =A0 =A0 XIntc_Enable(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_INTE=RRUPT_INTR);> > =A0 =A0 =A0 =A0 XTmrCtr_SetHandler(&timr, (void *)TimerCounterHandler, vo=id); This issued an error so I replaced void with NULL in the third argument above. Apart from that I didn't change anything, but still the terminal never printed "timer interrupt" so still the problem remains!!> > =A0 =A0 =A0 =A0 XTmrCtr_SetOptions(&timr, 0, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XTC_INT_MODE_OPTION | XTC_=AUTO_RELOAD_OPTION);> > =A0 =A0 =A0 =A0 XTmrCtr_SetResetValue(&timr, 0, 0xF0000000); > > =A0 =A0 =A0 =A0 XTmrCtr_Start(&timr,0); > > =A0 =A0 =A0 =A0 microblaze_enable_interrupts(); > > =A0 =A0 =A0 =A0while(1){ > =A0 =A0 =A0 //wait for interrupts > =A0 =A0 =A0 } > > } > > If you are using the Intc component, you no longer need to use the > microblaze_register_handler function - instead use the XIntc_Connect() > function. > The XTmrCtr driver provides its own interrupt handler > XTmrCtr_InterruptHandler() which you should use to service the > interrupt. =A0It will issue a callback to a function of your choice (set > with XTmrCtr_SetHandler) > > Hope this helps, > > David- Hide quoted text - > > - Show quoted text -
Reply by ●November 26, 20082008-11-26
Not sure what the problem is with your code. Here's an example with one timer. It's 10.1, but there weren't any changes in the interrupt stuff between 9.2 and 10.1 (so I'm told). This is based on a lab from one of Avnet's Speedway trainings. I ran it on the Xilinx Spartan-3A DSP 1800A Starter and verified that the interrupts are indeed happening. There is a bit file in the project directory if you don't want to rebuild the project. Bryan The following file has been made available for you to download from Avnet's File Transfer web site: http://xfer.avnet.com/uploads/Xil3S1800ADSP_Interrupt_v10.1.03.zip Click on the hyperlink or enter this URL into your web browser to retrieve the file. This file will remain on the server for approximately 5 days from the date of the upload at which time it will be deleted. Please be sure to download it before the expiration time. This file will expire on Dec 1, 2008. File Size: 232357 Bytes On Nov 26, 12:22=A0am, bish <bishes...@gmail.com> wrote:> On Nov 26, 4:58=A0am, David <simianfe...@gmail.com> wrote: > > > > > > > On Nov 26, 2:37=A0am, bish <bishes...@gmail.com> wrote: > > > > On Nov 25, 12:25=A0pm, Matthias Alles <REMOVEallesCAPIT...@NOeit.SPAM=uni-> > > > kl.de> wrote: > > > > Hi! > > > > > I wonder, whether "one_second_flag" is declared as volatile? If not=, the> > > > compiler optimizes your if-statement in the while(1) loop away. You=can> > > > check this by using mb-objdump. > > > > I tried using the volatile for one_second_flag, still it does not > > > work. It just prints "the value of count =3D 1" once in terminal and > > > nothing happens then. > > > > > Cheers, > > > > Matthias > > > > > bish schrieb: > > > > > > I am trying to use a timer for regular interrupt in microblaze. I=am> > > > > using edk 9.2i and spartan 3a dsp 1800a. > > > > > Even following a simple lab example widely used by beginners didn='t> > > > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > > > > I have connected all the interrupt ports correctly as evident fro=m the> > > > > following portion of the mhs file: > > > > > BEGIN microblaze > > > > > =A0PARAMETER HW_VER =3D 7.00.a > > > > > ........... > > > > > ........... > > > > > PORT INTERRUPT =3D interrupt > > > > > END > > > > > > BEGIN xps_timer > > > > > =A0PARAMETER INSTANCE =3D delay > > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > > > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > > > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > > =A0PORT Interrupt =3D timer1 > > > > > =A0PORT CaptureTrig0 =3D net_gnd > > > > > END > > > > > > BEGIN xps_intc > > > > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > > > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > > =A0PORT Irq =3D interrupt > > > > > =A0PORT Intr =3D timer1 > > > > > END > > > > > > Now for the software settings since I am using edk 9.2i, it does =not> > > > > have option for registering our interrupt handler in software pla=tform> > > > > settings window (which is what the lab suggests), I used the > > > > > microblaze_register_handler(...) function ( I took me 3 days to f=igure> > > > > out this), =A0but I still don't get how it works differently from=the> > > > > function XIntc_RegisterHandler. > > > > > The portion of C file is as follows: > > > > > void timer_int_handler(void * baseaddr_p) { > > > > > =A0 =A0 /* Add variable declarations here */ > > > > > =A0 =A0unsigned int csr; > > > > > =A0 =A0/* Read timer 0 CSR to see if it raised the interrupt */ > > > > > =A0 =A0csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR,0=);> > > > > =A0 =A0/* If the interrupt occurred, then increment a counter */ > > > > > =A0 =A0/* and set one_second_flag to 1 */ > > > > > =A0 =A0if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > > > > =A0 =A0 =A0 =A0 =A0 =A0count ++; > > > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag =3D 1; > > > > > =A0 =A0} > > > > > > =A0 =A0/* Display the count on the LEDs */ > > > > > =A0 =A0XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > > > > > =A0 =A0/* Print the count using the UART*/ > > > > > =A0 =A0xil_printf("count value is: %x\n\r", count); > > > > > =A0 =A0/* Clear the timer interrupt */ > > > > > =A0 =A0XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > > > > > } > > > > > > int main() { > > > > > > =A0 int count_mod_3; > > > > > > =A0 //registering an interrupt handler > > > > > =A0 microblaze_register_handler((XInterruptHandler) timer_int_han=dler,> > > > > (void *)0); > > > > > > =A0 /* Register the Timer interrupt handler in the vector table *=/> > > > > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR_X=PS_INTC_0_DELAY_INTERRUPT_INTR,> > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInte=rruptHandler) timer_int_handler,> > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void =*)XPAR_DELAY_BASEADDR);> > > > > =A0 /* Enable MicroBlaze Interrupts */ > > > > > =A0 microblaze_enable_interrupts(); > > > > > > =A0 /* Initialize and set the direction of the GPIO connected to =LEDs */> > > > > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > > > > > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > > > > > =A0 /* Start the interrupt controller */ > > > > > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > > > > > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > > > > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > > > > > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > > > > > =A0 xil_printf("The value of count =3D %d\n\r", count); > > > > > > =A0 /* Set the number of cycles the timer counts before interrupt=ing */> > > > > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > > > > > (timer_count*timer_count) * 50000000); > > > > > > =A0 /* Reset the timers, and clear interrupts */ > > > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > > > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > > > > > =A0 /* Enable timer interrupts in the interrupt controller */ > > > > > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT_M=ASK);> > > > > > =A0 /* Start the timers */ > > > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > > > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ==A0 =A0 =A0 =A0 =A0 =A0XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);> > > > > > =A0 /* Wait for interrupts to occur */ > > > > > =A0 while(1) { > > > > > =A0 =A0if(one_second_flag){ > > > > > =A0 =A0 =A0 =A0 =A0 =A0count_mod_3 =3D count % 3; > > > > > =A0 =A0 =A0 =A0 =A0 =A0if(count_mod_3 =3D=3D 0) > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xil_printf("Interrupt take=n at %d seconds \n\r",count);> > > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag=3D0; > > > > > =A0 =A0 =A0 =A0 =A0 =A0xil_printf("."); > > > > > =A0 =A0 =A0 =A0 =A0 =A0} > > > > > =A0 =A0} > > > > > } > > > > > > When I run the system, the value of count does not change from 1.=What> > > > > could be the problem?- Hide quoted text - > > > > > - Show quoted text - > > > Hello, > > > Here is how I set up a timer interrupt in 9.2: > > > void TimerCounterHandler(void *CallBackRef) > > { > > =A0 =A0 =A0 =A0 print("timer interrupt "); > > > } > > > Int main (void) { > > > =A0 =A0 =A0 =A0 XIntc intr_ctrl; > > =A0 =A0 =A0 =A0 XTmrCtr timr; > > > =A0 =A0 =A0 =A0 XIntc_Initialize(&intr_ctrl,XPAR_XPS_INTC_0_DEVICE_ID); > > =A0 =A0 =A0 =A0 XTmrCtr_Initialize(&timr,XPAR_XPS_TIMER_1_DEVICE_ID); > > > =A0 =A0 =A0 =A0 XIntc_Connect(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_I=NTERRUPT_INTR,> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterruptHandl=er)> > XTmrCtr_InterruptHandler, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)&timr); > > > =A0 =A0 =A0 =A0 XIntc_Start(&intr_ctrl, XIN_REAL_MODE); > > > =A0 =A0 =A0 =A0 XIntc_Enable(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_IN=TERRUPT_INTR);> > > =A0 =A0 =A0 =A0 XTmrCtr_SetHandler(&timr, (void *)TimerCounterHandler, =void);> > This issued an error so I replaced void with NULL in the third > argument above. Apart from that I didn't change anything, but still > the terminal never printed "timer interrupt" so still the problem > remains!! > > > > > > > =A0 =A0 =A0 =A0 XTmrCtr_SetOptions(&timr, 0, > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XTC_INT_MODE_OPTION | XT=C_AUTO_RELOAD_OPTION);> > > =A0 =A0 =A0 =A0 XTmrCtr_SetResetValue(&timr, 0, 0xF0000000); > > > =A0 =A0 =A0 =A0 XTmrCtr_Start(&timr,0); > > > =A0 =A0 =A0 =A0 microblaze_enable_interrupts(); > > > =A0 =A0 =A0 =A0while(1){ > > =A0 =A0 =A0 //wait for interrupts > > =A0 =A0 =A0 } > > > } > > > If you are using the Intc component, you no longer need to use the > > microblaze_register_handler function - instead use the XIntc_Connect() > > function. > > The XTmrCtr driver provides its own interrupt handler > > XTmrCtr_InterruptHandler() which you should use to service the > > interrupt. =A0It will issue a callback to a function of your choice (se=t> > with XTmrCtr_SetHandler) > > > Hope this helps, > > > David- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text -
Reply by ●November 27, 20082008-11-27
On Nov 27, 6:14=A0am, Bryan <bryan.fletc...@avnet.com> wrote:> Not sure what the problem is with your code. =A0Here's an example with > one timer. =A0It's 10.1, but there weren't any changes in the interrupt > stuff between 9.2 and 10.1 (so I'm told). =A0This is based on a lab from > one of Avnet's Speedway trainings. =A0I ran it on the Xilinx Spartan-3A > DSP 1800A Starter and verified that the interrupts are indeed > happening. =A0There is a bit file in the project directory if you don't > want to rebuild the project. > > Bryan > > The following file has been made available for you to download from > Avnet's File Transfer web site:http://xfer.avnet.com/uploads/Xil3S1800ADS=P_Interrupt_v10.1.03.zip I downloaded the timer_interrupt.bit file into FPGA using impact, the timer example worked FINE. It generated the required output and interrrupt was working. BUT I could not use the system.xmp present in http://xfer.avnet.com/uploads/Xil3S1800ADSP_Interrupt_v10.1.03.zip because I have edk 9.2i, but it was developed with later version of edk. And here is the mysterious problem yet to be solved!! So I developed a base system and used xps interrupt controller and timer. The MHS file is: # ###########################################################################= ### # Created by Base System Builder Wizard for Xilinx EDK 9.2 Build EDK_Jm.16 # Sun Nov 16 21:24:15 2008 # Target Board: Xilinx Spartan-3A DSP 1800A Starter Board Rev 1 # Family: spartan3adsp # Device: xc3sd1800a # Package: fg676 # Speed Grade: -4 # Processor: microblaze_0 # System clock frequency: 62.000000 MHz # On Chip Memory : 8 KB # ###########################################################################= ### PARAMETER VERSION =3D 2.1.0 PORT fpga_0_RS232_Uart_1_RX_pin =3D fpga_0_RS232_Uart_1_RX, DIR =3D I PORT fpga_0_RS232_Uart_1_TX_pin =3D fpga_0_RS232_Uart_1_TX, DIR =3D O PORT sys_clk_pin =3D dcm_clk_s, DIR =3D I, SIGIS =3D CLK, CLK_FREQ =3D 125000000 PORT sys_rst_pin =3D sys_rst_s, DIR =3D I, RST_POLARITY =3D 0, SIGIS =3D R= ST PORT dip_GPIO_in_pin =3D dip_GPIO_in, DIR =3D I, VEC =3D [0:7] PORT push_GPIO_in_pin =3D push_GPIO_in, DIR =3D I, VEC =3D [0:3] PORT led_GPIO_IO_pin =3D led_GPIO_IO, DIR =3D IO, VEC =3D [0:7] BEGIN microblaze PARAMETER HW_VER =3D 7.00.a PARAMETER INSTANCE =3D microblaze_0 PARAMETER C_INTERCONNECT =3D 1 PARAMETER C_DEBUG_ENABLED =3D 1 PARAMETER C_AREA_OPTIMIZED =3D 1 BUS_INTERFACE DLMB =3D dlmb BUS_INTERFACE ILMB =3D ilmb BUS_INTERFACE DPLB =3D mb_plb BUS_INTERFACE IPLB =3D mb_plb BUS_INTERFACE DEBUG =3D microblaze_0_dbg PORT RESET =3D mb_reset PORT INTERRUPT =3D Interrupt END BEGIN plb_v46 PARAMETER INSTANCE =3D mb_plb PARAMETER HW_VER =3D 1.00.a PORT PLB_Clk =3D sys_clk_s PORT SYS_Rst =3D sys_bus_reset END BEGIN lmb_v10 PARAMETER INSTANCE =3D ilmb PARAMETER HW_VER =3D 1.00.a PORT LMB_Clk =3D sys_clk_s PORT SYS_Rst =3D sys_bus_reset END BEGIN lmb_v10 PARAMETER INSTANCE =3D dlmb PARAMETER HW_VER =3D 1.00.a PORT LMB_Clk =3D sys_clk_s PORT SYS_Rst =3D sys_bus_reset END BEGIN lmb_bram_if_cntlr PARAMETER INSTANCE =3D dlmb_cntlr PARAMETER HW_VER =3D 2.10.a PARAMETER C_BASEADDR =3D 0x00000000 PARAMETER C_HIGHADDR =3D 0x00003fff BUS_INTERFACE SLMB =3D dlmb BUS_INTERFACE BRAM_PORT =3D dlmb_port END BEGIN lmb_bram_if_cntlr PARAMETER INSTANCE =3D ilmb_cntlr PARAMETER HW_VER =3D 2.10.a PARAMETER C_BASEADDR =3D 0x00000000 PARAMETER C_HIGHADDR =3D 0x00003fff BUS_INTERFACE SLMB =3D ilmb BUS_INTERFACE BRAM_PORT =3D ilmb_port END BEGIN bram_block PARAMETER INSTANCE =3D lmb_bram PARAMETER HW_VER =3D 1.00.a BUS_INTERFACE PORTA =3D ilmb_port BUS_INTERFACE PORTB =3D dlmb_port END BEGIN xps_uartlite PARAMETER INSTANCE =3D RS232_Uart_1 PARAMETER HW_VER =3D 1.00.a PARAMETER C_BAUDRATE =3D 115200 PARAMETER C_ODD_PARITY =3D 0 PARAMETER C_USE_PARITY =3D 0 PARAMETER C_SPLB_CLK_FREQ_HZ =3D 62500000 PARAMETER C_BASEADDR =3D 0x84000000 PARAMETER C_HIGHADDR =3D 0x8400ffff BUS_INTERFACE SPLB =3D mb_plb PORT RX =3D fpga_0_RS232_Uart_1_RX PORT TX =3D fpga_0_RS232_Uart_1_TX END BEGIN clock_generator PARAMETER INSTANCE =3D clock_generator_0 PARAMETER HW_VER =3D 1.00.a PARAMETER C_EXT_RESET_HIGH =3D 1 PARAMETER C_CLKIN_FREQ =3D 125000000 PARAMETER C_CLKOUT0_FREQ =3D 62500000 PARAMETER C_CLKOUT0_PHASE =3D 0 PARAMETER C_CLKOUT0_GROUP =3D NONE PORT CLKOUT0 =3D sys_clk_s PORT CLKIN =3D dcm_clk_s PORT LOCKED =3D Dcm_all_locked PORT RST =3D net_gnd END BEGIN mdm PARAMETER INSTANCE =3D debug_module PARAMETER HW_VER =3D 1.00.a PARAMETER C_MB_DBG_PORTS =3D 1 PARAMETER C_USE_UART =3D 1 PARAMETER C_UART_WIDTH =3D 8 PARAMETER C_BASEADDR =3D 0x84400000 PARAMETER C_HIGHADDR =3D 0x8440ffff BUS_INTERFACE SPLB =3D mb_plb BUS_INTERFACE MBDEBUG_0 =3D microblaze_0_dbg PORT Debug_SYS_Rst =3D Debug_SYS_Rst END BEGIN proc_sys_reset PARAMETER INSTANCE =3D proc_sys_reset_0 PARAMETER HW_VER =3D 2.00.a PARAMETER C_EXT_RESET_HIGH =3D 0 PORT Slowest_sync_clk =3D sys_clk_s PORT Dcm_locked =3D Dcm_all_locked PORT Ext_Reset_In =3D sys_rst_s PORT MB_Reset =3D mb_reset PORT Bus_Struct_Reset =3D sys_bus_reset PORT MB_Debug_Sys_Rst =3D Debug_SYS_Rst END BEGIN xps_gpio PARAMETER INSTANCE =3D push PARAMETER HW_VER =3D 1.00.a PARAMETER C_GPIO_WIDTH =3D 4 PARAMETER C_ALL_INPUTS =3D 1 PARAMETER C_IS_BIDIR =3D 0 PARAMETER C_BASEADDR =3D 0x8141c200 PARAMETER C_HIGHADDR =3D 0x8141c3ff BUS_INTERFACE SPLB =3D mb_plb PORT GPIO_in =3D push_GPIO_in END BEGIN xps_gpio PARAMETER INSTANCE =3D dip PARAMETER HW_VER =3D 1.00.a PARAMETER C_GPIO_WIDTH =3D 8 PARAMETER C_ALL_INPUTS =3D 1 PARAMETER C_IS_BIDIR =3D 0 PARAMETER C_BASEADDR =3D 0x81420000 PARAMETER C_HIGHADDR =3D 0x8142ffff BUS_INTERFACE SPLB =3D mb_plb PORT GPIO_in =3D dip_GPIO_in END BEGIN xps_gpio PARAMETER INSTANCE =3D led PARAMETER HW_VER =3D 1.00.a PARAMETER C_GPIO_WIDTH =3D 8 PARAMETER C_IS_BIDIR =3D 0 PARAMETER C_BASEADDR =3D 0x81400000 PARAMETER C_HIGHADDR =3D 0x8140ffff BUS_INTERFACE SPLB =3D mb_plb PORT GPIO_IO =3D led_GPIO_IO END BEGIN xps_timer PARAMETER INSTANCE =3D xps_timer_0 PARAMETER HW_VER =3D 1.00.a PARAMETER C_BASEADDR =3D 0x81418000 PARAMETER C_HIGHADDR =3D 0x814181ff PARAMETER C_ONE_TIMER_ONLY =3D 1 BUS_INTERFACE SPLB =3D mb_plb PORT Interrupt =3D xps_timer_0_Interrupt END BEGIN xps_intc PARAMETER INSTANCE =3D xps_intc_0 PARAMETER HW_VER =3D 1.00.a PARAMETER C_BASEADDR =3D 0x81414000 PARAMETER C_HIGHADDR =3D 0x814141ff BUS_INTERFACE SPLB =3D mb_plb PORT Irq =3D Interrupt PORT Intr =3D xps_timer_0_Interrupt END In xps_intc I have connected only timer interrupt to its Intr pin and other interrupts like from push buttons and other are NOT CONNECTED. Then I used "timer.c" provided in the link (I have not used external DDR2 SDRAM), and the result: Starting Timer example Timer example FAILED So, I am really confused here!!> > Click on the hyperlink or enter this URL into your web browser to > retrieve the file. > This file will remain on the server for approximately 5 days from the > date of the upload at which time it will be deleted. =A0Please be sure > to download it before the expiration time. > This file will expire on Dec =A01, 2008. > > File Size: 232357 Bytes > > On Nov 26, 12:22=A0am, bish <bishes...@gmail.com> wrote: > > > > > On Nov 26, 4:58=A0am, David <simianfe...@gmail.com> wrote: > > > > On Nov 26, 2:37=A0am, bish <bishes...@gmail.com> wrote: > > > > > On Nov 25, 12:25=A0pm, Matthias Alles <REMOVEallesCAPIT...@NOeit.SP=AMuni-> > > > > kl.de> wrote: > > > > > Hi! > > > > > > I wonder, whether "one_second_flag" is declared as volatile? If n=ot, the> > > > > compiler optimizes your if-statement in the while(1) loop away. Y=ou can> > > > > check this by using mb-objdump. > > > > > I tried using the volatile for one_second_flag, still it does not > > > > work. It just prints "the value of count =3D 1" once in terminal an=d> > > > nothing happens then. > > > > > > Cheers, > > > > > Matthias > > > > > > bish schrieb: > > > > > > > I am trying to use a timer for regular interrupt in microblaze.=I am> > > > > > using edk 9.2i and spartan 3a dsp 1800a. > > > > > > Even following a simple lab example widely used by beginners di=dn't> > > > > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > > > > > I have connected all the interrupt ports correctly as evident f=rom the> > > > > > following portion of the mhs file: > > > > > > BEGIN microblaze > > > > > > =A0PARAMETER HW_VER =3D 7.00.a > > > > > > ........... > > > > > > ........... > > > > > > PORT INTERRUPT =3D interrupt > > > > > > END > > > > > > > BEGIN xps_timer > > > > > > =A0PARAMETER INSTANCE =3D delay > > > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > > > > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > > > > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > > > =A0PORT Interrupt =3D timer1 > > > > > > =A0PORT CaptureTrig0 =3D net_gnd > > > > > > END > > > > > > > BEGIN xps_intc > > > > > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > > > > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > > > =A0PORT Irq =3D interrupt > > > > > > =A0PORT Intr =3D timer1 > > > > > > END > > > > > > > Now for the software settings since I am using edk 9.2i, it doe=s not> > > > > > have option for registering our interrupt handler in software p=latform> > > > > > settings window (which is what the lab suggests), I used the > > > > > > microblaze_register_handler(...) function ( I took me 3 days to=figure> > > > > > out this), =A0but I still don't get how it works differently fr=om the> > > > > > function XIntc_RegisterHandler. > > > > > > The portion of C file is as follows: > > > > > > void timer_int_handler(void * baseaddr_p) { > > > > > > =A0 =A0 /* Add variable declarations here */ > > > > > > =A0 =A0unsigned int csr; > > > > > > =A0 =A0/* Read timer 0 CSR to see if it raised the interrupt */ > > > > > > =A0 =A0csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEADDR=,0);> > > > > > =A0 =A0/* If the interrupt occurred, then increment a counter *=/> > > > > > =A0 =A0/* and set one_second_flag to 1 */ > > > > > > =A0 =A0if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > > > > > =A0 =A0 =A0 =A0 =A0 =A0count ++; > > > > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag =3D 1; > > > > > > =A0 =A0} > > > > > > > =A0 =A0/* Display the count on the LEDs */ > > > > > > =A0 =A0XGpio_mSetDataReg(XPAR_LED_HIGHADDR, LEDChan, count); > > > > > > > =A0 =A0/* Print the count using the UART*/ > > > > > > =A0 =A0xil_printf("count value is: %x\n\r", count); > > > > > > =A0 =A0/* Clear the timer interrupt */ > > > > > > =A0 =A0XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR,0,csr); > > > > > > } > > > > > > > int main() { > > > > > > > =A0 int count_mod_3; > > > > > > > =A0 //registering an interrupt handler > > > > > > =A0 microblaze_register_handler((XInterruptHandler) timer_int_h=andler,> > > > > > (void *)0); > > > > > > > =A0 /* Register the Timer interrupt handler in the vector table=*/> > > > > > =A0 XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR, > > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XPAR=_XPS_INTC_0_DELAY_INTERRUPT_INTR,> > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XIn=terruptHandler) timer_int_handler,> > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(voi=d *)XPAR_DELAY_BASEADDR);> > > > > > =A0 /* Enable MicroBlaze Interrupts */ > > > > > > =A0 microblaze_enable_interrupts(); > > > > > > > =A0 /* Initialize and set the direction of the GPIO connected t=o LEDs */> > > > > > =A0 XGpio_Initialize(&gpio, XPAR_LED_DEVICE_ID); > > > > > > =A0 XGpio_SetDataDirection(&gpio,LEDChan, 0); > > > > > > > =A0 /* Start the interrupt controller */ > > > > > > =A0 XIntc_mMasterEnable(XPAR_XPS_INTC_0_BASEADDR); > > > > > > =A0 XIntc_mEnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1); > > > > > > > =A0 /* Set the gpio as output on high 8 bits (LEDs)*/ > > > > > > =A0 XGpio_mSetDataReg(XPAR_LED_DEVICE_ID,LEDChan, ~count); > > > > > > =A0 xil_printf("The value of count =3D %d\n\r", count); > > > > > > > =A0 /* Set the number of cycles the timer counts before interru=pting */> > > > > > =A0 XTmrCtr_mSetLoadReg(XPAR_DELAY_BASEADDR, 0, > > > > > > (timer_count*timer_count) * 50000000); > > > > > > > =A0 /* Reset the timers, and clear interrupts */ > > > > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > > > > XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); > > > > > > > =A0 /* Enable timer interrupts in the interrupt controller */ > > > > > > =A0 XIntc_mEnableIntr(XPAR_DELAY_BASEADDR, XPAR_DELAY_INTERRUPT=_MASK);> > > > > > > =A0 /* Start the timers */ > > > > > > =A0 XTmrCtr_mSetControlStatusReg(XPAR_DELAY_BASEADDR, 0, > > > > > > XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | > > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0==A0 =A0 =A0 =A0 =A0 =A0XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK)= ;> > > > > > > =A0 /* Wait for interrupts to occur */ > > > > > > =A0 while(1) { > > > > > > =A0 =A0if(one_second_flag){ > > > > > > =A0 =A0 =A0 =A0 =A0 =A0count_mod_3 =3D count % 3; > > > > > > =A0 =A0 =A0 =A0 =A0 =A0if(count_mod_3 =3D=3D 0) > > > > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0xil_printf("Interrupt ta=ken at %d seconds \n\r",count);> > > > > > =A0 =A0 =A0 =A0 =A0 =A0one_second_flag=3D0; > > > > > > =A0 =A0 =A0 =A0 =A0 =A0xil_printf("."); > > > > > > =A0 =A0 =A0 =A0 =A0 =A0} > > > > > > =A0 =A0} > > > > > > } > > > > > > > When I run the system, the value of count does not change from =1. What> > > > > > could be the problem?- Hide quoted text - > > > > > > - Show quoted text - > > > > Hello, > > > > Here is how I set up a timer interrupt in 9.2: > > > > void TimerCounterHandler(void *CallBackRef) > > > { > > > =A0 =A0 =A0 =A0 print("timer interrupt "); > > > > } > > > > Int main (void) { > > > > =A0 =A0 =A0 =A0 XIntc intr_ctrl; > > > =A0 =A0 =A0 =A0 XTmrCtr timr; > > > > =A0 =A0 =A0 =A0 XIntc_Initialize(&intr_ctrl,XPAR_XPS_INTC_0_DEVICE_ID=);> > > =A0 =A0 =A0 =A0 XTmrCtr_Initialize(&timr,XPAR_XPS_TIMER_1_DEVICE_ID); > > > > =A0 =A0 =A0 =A0 XIntc_Connect(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1=_INTERRUPT_INTR,> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(XInterruptHan=dler)> > > XTmrCtr_InterruptHandler, > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(void *)&timr)=;> > > > =A0 =A0 =A0 =A0 XIntc_Start(&intr_ctrl, XIN_REAL_MODE); > > > > =A0 =A0 =A0 =A0 XIntc_Enable(&intr_ctrl, XPAR_XPS_INTC_0_XPS_TIMER_1_=INTERRUPT_INTR);> > > > =A0 =A0 =A0 =A0 XTmrCtr_SetHandler(&timr, (void *)TimerCounterHandler=, void);> > > This issued an error so I replaced void with NULL in the third > > argument above. Apart from that I didn't change anything, but still > > the terminal never printed "timer interrupt" so still the problem > > remains!! > > > > =A0 =A0 =A0 =A0 XTmrCtr_SetOptions(&timr, 0, > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0XTC_INT_MODE_OPTION | =XTC_AUTO_RELOAD_OPTION);> > > > =A0 =A0 =A0 =A0 XTmrCtr_SetResetValue(&timr, 0, 0xF0000000); > > > > =A0 =A0 =A0 =A0 XTmrCtr_Start(&timr,0); > > > > =A0 =A0 =A0 =A0 microblaze_enable_interrupts(); > > > > =A0 =A0 =A0 =A0while(1){ > > > =A0 =A0 =A0 //wait for interrupts > > > =A0 =A0 =A0 } > > > > } > > > > If you are using the Intc component, you no longer need to use the > > > microblaze_register_handler function - instead use the XIntc_Connect(=)> > > function. > > > The XTmrCtr driver provides its own interrupt handler > > > XTmrCtr_InterruptHandler() which you should use to service the > > > interrupt. =A0It will issue a callback to a function of your choice (=set> > > with XTmrCtr_SetHandler) > > > > Hope this helps, > > > > David- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text -
Reply by ●November 27, 20082008-11-27
On Nov 27, 10:08=A0pm, bish <bishes...@gmail.com> wrote:> On Nov 27, 6:14=A0am, Bryan <bryan.fletc...@avnet.com> wrote: > > > Not sure what the problem is with your code. =A0Here's an example with > > one timer. =A0It's 10.1, but there weren't any changes in the interrupt > > stuff between 9.2 and 10.1 (so I'm told). =A0This is based on a lab fro=m> > one of Avnet's Speedway trainings. =A0I ran it on the Xilinx Spartan-3A > > DSP 1800A Starter and verified that the interrupts are indeed > > happening. =A0There is a bit file in the project directory if you don't > > want to rebuild the project. > > > Bryan > > > The following file has been made available for you to download from > > Avnet's File Transfer web site:http://xfer.avnet.com/uploads/Xil3S1800A=DSP_Interrupt_v10.1.03.zip> > I downloaded the timer_interrupt.bit file into FPGA using impact, the > timer example worked FINE. > It generated the required output and interrrupt was working. BUT > > I could not use the system.xmp present inhttp://xfer.avnet.com/uploads/Xi=l3S1800ADSP_Interrupt_v10.1.03.zip> because > I have edk 9.2i, but it was developed with later version of edk. > > And here is the mysterious problem yet to be solved!! > So I developed a base system and used xps interrupt controller and > timer. The MHS file is: > > # > #########################################################################=##=AD###> # Created by Base System Builder Wizard for Xilinx EDK 9.2 Build > EDK_Jm.16 > # Sun Nov 16 21:24:15 2008 > # Target Board: =A0Xilinx Spartan-3A DSP 1800A Starter Board Rev 1 > # Family: =A0 =A0 =A0 =A0spartan3adsp > # Device: =A0 =A0 =A0 =A0xc3sd1800a > # Package: =A0 =A0 =A0 fg676 > # Speed Grade: =A0 -4 > # Processor: microblaze_0 > # System clock frequency: 62.000000 MHz > # On Chip Memory : =A0 8 KB > # > #########################################################################=##=AD###> =A0PARAMETER VERSION =3D 2.1.0 > > =A0PORT fpga_0_RS232_Uart_1_RX_pin =3D fpga_0_RS232_Uart_1_RX, DIR =3D I > =A0PORT fpga_0_RS232_Uart_1_TX_pin =3D fpga_0_RS232_Uart_1_TX, DIR =3D O > =A0PORT sys_clk_pin =3D dcm_clk_s, DIR =3D I, SIGIS =3D CLK, CLK_FREQ =3D > 125000000 > =A0PORT sys_rst_pin =3D sys_rst_s, DIR =3D I, RST_POLARITY =3D 0, SIGIS ==3D RST> =A0PORT dip_GPIO_in_pin =3D dip_GPIO_in, DIR =3D I, VEC =3D [0:7] > =A0PORT push_GPIO_in_pin =3D push_GPIO_in, DIR =3D I, VEC =3D [0:3] > =A0PORT led_GPIO_IO_pin =3D led_GPIO_IO, DIR =3D IO, VEC =3D [0:7] > > BEGIN microblaze > =A0PARAMETER HW_VER =3D 7.00.a > =A0PARAMETER INSTANCE =3D microblaze_0 > =A0PARAMETER C_INTERCONNECT =3D 1 > =A0PARAMETER C_DEBUG_ENABLED =3D 1 > =A0PARAMETER C_AREA_OPTIMIZED =3D 1 > =A0BUS_INTERFACE DLMB =3D dlmb > =A0BUS_INTERFACE ILMB =3D ilmb > =A0BUS_INTERFACE DPLB =3D mb_plb > =A0BUS_INTERFACE IPLB =3D mb_plb > =A0BUS_INTERFACE DEBUG =3D microblaze_0_dbg > =A0PORT RESET =3D mb_reset > =A0PORT INTERRUPT =3D Interrupt > END > > BEGIN plb_v46 > =A0PARAMETER INSTANCE =3D mb_plb > =A0PARAMETER HW_VER =3D 1.00.a > =A0PORT PLB_Clk =3D sys_clk_s > =A0PORT SYS_Rst =3D sys_bus_reset > END > > BEGIN lmb_v10 > =A0PARAMETER INSTANCE =3D ilmb > =A0PARAMETER HW_VER =3D 1.00.a > =A0PORT LMB_Clk =3D sys_clk_s > =A0PORT SYS_Rst =3D sys_bus_reset > END > > BEGIN lmb_v10 > =A0PARAMETER INSTANCE =3D dlmb > =A0PARAMETER HW_VER =3D 1.00.a > =A0PORT LMB_Clk =3D sys_clk_s > =A0PORT SYS_Rst =3D sys_bus_reset > END > > BEGIN lmb_bram_if_cntlr > =A0PARAMETER INSTANCE =3D dlmb_cntlr > =A0PARAMETER HW_VER =3D 2.10.a > =A0PARAMETER C_BASEADDR =3D 0x00000000 > =A0PARAMETER C_HIGHADDR =3D 0x00003fff > =A0BUS_INTERFACE SLMB =3D dlmb > =A0BUS_INTERFACE BRAM_PORT =3D dlmb_port > END > > BEGIN lmb_bram_if_cntlr > =A0PARAMETER INSTANCE =3D ilmb_cntlr > =A0PARAMETER HW_VER =3D 2.10.a > =A0PARAMETER C_BASEADDR =3D 0x00000000 > =A0PARAMETER C_HIGHADDR =3D 0x00003fff > =A0BUS_INTERFACE SLMB =3D ilmb > =A0BUS_INTERFACE BRAM_PORT =3D ilmb_port > END > > BEGIN bram_block > =A0PARAMETER INSTANCE =3D lmb_bram > =A0PARAMETER HW_VER =3D 1.00.a > =A0BUS_INTERFACE PORTA =3D ilmb_port > =A0BUS_INTERFACE PORTB =3D dlmb_port > END > > BEGIN xps_uartlite > =A0PARAMETER INSTANCE =3D RS232_Uart_1 > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_BAUDRATE =3D 115200 > =A0PARAMETER C_ODD_PARITY =3D 0 > =A0PARAMETER C_USE_PARITY =3D 0 > =A0PARAMETER C_SPLB_CLK_FREQ_HZ =3D 62500000 > =A0PARAMETER C_BASEADDR =3D 0x84000000 > =A0PARAMETER C_HIGHADDR =3D 0x8400ffff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT RX =3D fpga_0_RS232_Uart_1_RX > =A0PORT TX =3D fpga_0_RS232_Uart_1_TX > END > > BEGIN clock_generator > =A0PARAMETER INSTANCE =3D clock_generator_0 > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_EXT_RESET_HIGH =3D 1 > =A0PARAMETER C_CLKIN_FREQ =3D 125000000 > =A0PARAMETER C_CLKOUT0_FREQ =3D 62500000 > =A0PARAMETER C_CLKOUT0_PHASE =3D 0 > =A0PARAMETER C_CLKOUT0_GROUP =3D NONE > =A0PORT CLKOUT0 =3D sys_clk_s > =A0PORT CLKIN =3D dcm_clk_s > =A0PORT LOCKED =3D Dcm_all_locked > =A0PORT RST =3D net_gnd > END > > BEGIN mdm > =A0PARAMETER INSTANCE =3D debug_module > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_MB_DBG_PORTS =3D 1 > =A0PARAMETER C_USE_UART =3D 1 > =A0PARAMETER C_UART_WIDTH =3D 8 > =A0PARAMETER C_BASEADDR =3D 0x84400000 > =A0PARAMETER C_HIGHADDR =3D 0x8440ffff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0BUS_INTERFACE MBDEBUG_0 =3D microblaze_0_dbg > =A0PORT Debug_SYS_Rst =3D Debug_SYS_Rst > END > > BEGIN proc_sys_reset > =A0PARAMETER INSTANCE =3D proc_sys_reset_0 > =A0PARAMETER HW_VER =3D 2.00.a > =A0PARAMETER C_EXT_RESET_HIGH =3D 0 > =A0PORT Slowest_sync_clk =3D sys_clk_s > =A0PORT Dcm_locked =3D Dcm_all_locked > =A0PORT Ext_Reset_In =3D sys_rst_s > =A0PORT MB_Reset =3D mb_reset > =A0PORT Bus_Struct_Reset =3D sys_bus_reset > =A0PORT MB_Debug_Sys_Rst =3D Debug_SYS_Rst > END > > BEGIN xps_gpio > =A0PARAMETER INSTANCE =3D push > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_GPIO_WIDTH =3D 4 > =A0PARAMETER C_ALL_INPUTS =3D 1 > =A0PARAMETER C_IS_BIDIR =3D 0 > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT GPIO_in =3D push_GPIO_in > END > > BEGIN xps_gpio > =A0PARAMETER INSTANCE =3D dip > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_GPIO_WIDTH =3D 8 > =A0PARAMETER C_ALL_INPUTS =3D 1 > =A0PARAMETER C_IS_BIDIR =3D 0 > =A0PARAMETER C_BASEADDR =3D 0x81420000 > =A0PARAMETER C_HIGHADDR =3D 0x8142ffff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT GPIO_in =3D dip_GPIO_in > END > > BEGIN xps_gpio > =A0PARAMETER INSTANCE =3D led > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_GPIO_WIDTH =3D 8 > =A0PARAMETER C_IS_BIDIR =3D 0 > =A0PARAMETER C_BASEADDR =3D 0x81400000 > =A0PARAMETER C_HIGHADDR =3D 0x8140ffff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT GPIO_IO =3D led_GPIO_IO > END > > BEGIN xps_timer > =A0PARAMETER INSTANCE =3D xps_timer_0 > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_BASEADDR =3D 0x81418000 > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT Interrupt =3D xps_timer_0_Interrupt > END > > BEGIN xps_intc > =A0PARAMETER INSTANCE =3D xps_intc_0 > =A0PARAMETER HW_VER =3D 1.00.a > =A0PARAMETER C_BASEADDR =3D 0x81414000 > =A0PARAMETER C_HIGHADDR =3D 0x814141ff > =A0BUS_INTERFACE SPLB =3D mb_plb > =A0PORT Irq =3D Interrupt > =A0PORT Intr =3D xps_timer_0_Interrupt > END > > In xps_intc I have connected only timer interrupt to its Intr pin and > other interrupts like > from push buttons and other are NOT CONNECTED.In the configure ip.. option for xps interrupt controller I could not change the no. of interrupt inputs (by default it is 2), as it is set to 2 and disabled. So I used two timers and connected interrupt pins of these timers to interrupt controller just make intr inputs 2. Then again I checked with the "timer.c" file from the link, and still the same result: Timer example failed !!! This has already taken so many days and problem is becoming more mysterious (but frustrating)!!!> Then I used "timer.c" provided in the link (I have not used external > DDR2 SDRAM), and the result: > > Starting Timer example > Timer example FAILED > > So, I am really confused here!! > > > > > > > Click on the hyperlink or enter this URL into your web browser to > > retrieve the file. > > This file will remain on the server for approximately 5 days from the > > date of the upload at which time it will be deleted. =A0Please be sure > > to download it before the expiration time. > > This file will expire on Dec =A01, 2008. > > > File Size: 232357 Bytes > > > On Nov 26, 12:22=A0am, bish <bishes...@gmail.com> wrote: > > > > On Nov 26, 4:58=A0am, David <simianfe...@gmail.com> wrote: > > > > > On Nov 26, 2:37=A0am, bish <bishes...@gmail.com> wrote: > > > > > > On Nov 25, 12:25=A0pm, Matthias Alles <REMOVEallesCAPIT...@NOeit.=SPAMuni-> > > > > > kl.de> wrote: > > > > > > Hi! > > > > > > > I wonder, whether "one_second_flag" is declared as volatile? If=not, the> > > > > > compiler optimizes your if-statement in the while(1) loop away.=You can> > > > > > check this by using mb-objdump. > > > > > > I tried using the volatile for one_second_flag, still it does not > > > > > work. It just prints "the value of count =3D 1" once in terminal =and> > > > > nothing happens then. > > > > > > > Cheers, > > > > > > Matthias > > > > > > > bish schrieb: > > > > > > > > I am trying to use a timer for regular interrupt in microblaz=e. I am> > > > > > > using edk 9.2i and spartan 3a dsp 1800a. > > > > > > > Even following a simple lab example widely used by beginners =didn't> > > > > > > work:http://users.utcluj.ro/~baruch/ssce/labor/EDK-L5-e.pdf > > > > > > > > I have connected all the interrupt ports correctly as evident=from the> > > > > > > following portion of the mhs file: > > > > > > > BEGIN microblaze > > > > > > > =A0PARAMETER HW_VER =3D 7.00.a > > > > > > > ........... > > > > > > > ........... > > > > > > > PORT INTERRUPT =3D interrupt > > > > > > > END > > > > > > > > BEGIN xps_timer > > > > > > > =A0PARAMETER INSTANCE =3D delay > > > > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > > > > =A0PARAMETER C_ONE_TIMER_ONLY =3D 1 > > > > > > > =A0PARAMETER C_BASEADDR =3D 0x8141c200 > > > > > > > =A0PARAMETER C_HIGHADDR =3D 0x8141c3ff > > > > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > > > > =A0PORT Interrupt =3D timer1 > > > > > > > =A0PORT CaptureTrig0 =3D net_gnd > > > > > > > END > > > > > > > > BEGIN xps_intc > > > > > > > =A0PARAMETER INSTANCE =3D xps_intc_0 > > > > > > > =A0PARAMETER HW_VER =3D 1.00.a > > > > > > > =A0PARAMETER C_BASEADDR =3D 0x81418000 > > > > > > > =A0PARAMETER C_HIGHADDR =3D 0x814181ff > > > > > > > =A0BUS_INTERFACE SPLB =3D mb_plb > > > > > > > =A0PORT Irq =3D interrupt > > > > > > > =A0PORT Intr =3D timer1 > > > > > > > END > > > > > > > > Now for the software settings since I am using edk 9.2i, it d=oes not> > > > > > > have option for registering our interrupt handler in software=platform> > > > > > > settings window (which is what the lab suggests), I used the > > > > > > > microblaze_register_handler(...) function ( I took me 3 days =to figure> > > > > > > out this), =A0but I still don't get how it works differently =from the> > > > > > > function XIntc_RegisterHandler. > > > > > > > The portion of C file is as follows: > > > > > > > void timer_int_handler(void * baseaddr_p) { > > > > > > > =A0 =A0 /* Add variable declarations here */ > > > > > > > =A0 =A0unsigned int csr; > > > > > > > =A0 =A0/* Read timer 0 CSR to see if it raised the interrupt =*/> > > > > > > =A0 =A0csr =3D XTmrCtr_mGetControlStatusReg(XPAR_DELAY_BASEAD=DR,0);> > > > > > > =A0 =A0/* If the interrupt occurred, then increment a counter=*/> > > > > > > =A0 =A0/* and set one_second_flag to 1 */ > > > > > > > =A0 =A0if (csr & XTC_CSR_INT_OCCURED_MASK ) { > > ... > > read more =BB- Hide quoted text - > > - Show quoted text -





