1 / 12

ECT 358

ECT 358. Lecture 25 Interrupts. The best way to forget your own problems is to help someone solve his. Look not every man on his own things, but every man also on the things of others. Phillippians 2:4. Interrupts. MicroBlaze has one interrupt port.

Download Presentation

ECT 358

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ECT 358 Lecture 25 Interrupts

  2. The best way to forget your own problems is to help someone solve his. Look not every man on his own things, but every man also on the things of others. Phillippians 2:4

  3. Interrupts • MicroBlaze has one interrupt port. • An interrupt controller peripheral is required for handling more than one interrupt signal.

  4. Interrupt Sources • Interrupt Controller Peripheral • Peripheral with an Interrupt Port • External Interrupt Port • Interrupt Handlers • Interrupt Vector Table in MicroBlaze • Interrupt Routines in MicroBlaze

  5. Interrupt Action • Interrupt occurs • MicroBlaze jumps to address location 0x10 • Interrupt Vector Table contains address of Interrupt Handler for Interrupt Source • MicroBlaze jumps to address of Interrupt Handler (Subroutine) • Subroutine returns and MicroBlaze returns to original code execution

  6. Interrupt Controller Peripheral • An interrupt controller peripheral should be used for handling multiple interrupts. • The interrupt handler for the interrupt controller peripheral is automatically generated by Libgen. • Peripherals are handled by individual interrupt handlers in the order of their priority. • The interrupt controller handler services each interrupt signal that is active starting from the highest priority signal. • Each of the peripheral interrupt signals needs to be associated with an ISR.

  7. Interrupt Controller Peripheral

  8. Peripheral with Interrupt • Change the following lines of the MHS snippet in the OPBTIMER section to the following port Interrupt = interrupt port CaptureTrig0 = net_gnd Delete references to other interrupt controller

  9. Peripheral with Interrupt • Change the following lines of the MSS snippet in the OPBTIMER section to the following parameter INT_HANDLER = timer_int_handler, INT_PORT = Interrupt timer_int_handler is the name of your interrupt service routine. Delete references to other interrupt controller.

  10. Interrupt Handlers You can write your own interrupt handlers, or ISRs, for any peripherals that raise interrupts. You write these routines in C as with other functions. You can give the interrupt handler function any name with the signature void func (void *). Alternately, you can elect to register the handlers defined as a part of the drivers of the interrupt sources.

  11. Example C File #include <xtmrctr_l.h> void timer_int_handler(void * baseaddr_p) { int status; status = XTmrCtr_mGetControlStatusReg(baseaddr_p, 0); if (status & XTC_CSR_INT_OCCURED_MASK) { /* your code here */ /* Clear the timer interrupt */ XTmrCtr_mSetControlStatusReg(baseaddr_p, 0, status); } }

  12. Example C File void main() { /* initializations */ microblaze_enable_interrupts(); XTmrCtr_mSetLoadReg(XPAR_OPB_TIMER_1_BASEADDR, 0, 1000000); /* reset the timers, and clear interrupts */ XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_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); /* Wait for interrupts to occur */ while (1); }

More Related