How write interrupt tables and routines for microcontroller

Discussion in 'Programmer's Corner' started by Albinoswordfish, Apr 17, 2009.

  1. Albinoswordfish

    Thread Starter New Member

    Sep 4, 2007
    Hi everyone,
    I was wondering if anybody could help me with building a vector table and also writing an interrupt service routine. I want to avoid using processor expert as much as possible. From what I've seen you can just build the table and then write the subroutines corresponding to the vectors.

    However there are some things I'm not sure on. Such as how to reset the system, how to write the subroutine itself, and how to build the vector table.

    If anybody could assist me on this it would be appreciated.
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    1. Enable the interrupt/s.

    2. Jump to the interrupt routine on occurrence of the interrupt.

    3. Disable further interrupts.

    4. Save the state of the processor.

    5. Evaluate the interrupt (this is where you set the vector if you want), and perform the necessary actions.

    6. Pull the state off the stack.

    7. Enable further interrupts.

    8. Return to the main loop.
  3. algae

    New Member

    Jan 14, 2008
    albino -

    this is the kind of thing you want to rely on what is already out there for...I know you want to do it yourself, however, in the end that will be more of a headache, and won't give as much education as you think. On the other hand, if you look carefully at the already crafted code (which can be quite different from architecture to architecture) you will learn a lot about the subject (and good coding practice too, depending). Chances are sooner or later you will have to reference code that is already out there anyway, since learnin to do this the right way can cause a lot of problems.