Hi
Here is one example which may help.
1. Configure a peripheral to use an interrupt.
Here is a routine to set up the PIT timer 0 and enable its interrupt.
extern void fnStartTick(void)
{
PIT_PCSR_0 = (PIT_PRESCALE | PIT_DBG | PIT_OVW | PIT_PIF | PIT_RLD); // prepare for load
PIT_PMR_0 = TICK_DIVIDE; // load interval value
IC_ICR_0_55 = (INTERRUPT_LEVEL_4 | INTERRUPT_PRIORITY_0); // define interrupts level and priority
IC_IMRH_0 &= ~(PIT_0_PIF_INT_H | MASK_ALL_INT); // unmask interrupt source
PIT_PCSR_0 = (PIT_PRESCALE | PIT_DBG | PIT_OVW | PIT_PIF | PIT_RLD | PIT_PIE | PIT_EN); // start PIT with interrupt enabled
}
Notes: Each interrupt has an ICR where its level and priority is defined. Here they are 4 and 0 respectively. Then the interrupt source is unmasked (in IMRH). Finally the interrupt in the peripheral is enabled (how it is performed depends on the peripheral). You will need to read the users' manual (interrupt section and corresponding peripheral section). [Note that the user is responsible for avoiding more that one source using particular level/priority setting.]
2. The interrupt vector table must include the interrupt service routine.
Here is a small extract from the interrupt vector table (MCF52235_vectors.s) where the handling routine has been set. The PIT 0 uses vector77 (see the users' manual to see which vectors are used by which interrupt)
vector74: .long _irq_handler
vector75: .long _irq_handler
vector76: .long _irq_handler
vector77: .long _RealTimeInterrupt /* TICK timer interrupt */
vector78: .long _irq_handler
vector79: .long _irq_handler
vector7A: .long _irq_handler
3. Finally the interrupt routine must be programmed. It is called when the interrupt occurs and must usually also reset the interrupt so that it only enters once per interrupt. In the following example the first line resets the interrupt flag.
/**************************** Real Time Clock interrupt ******************************************/
__interrupt__ void RealTimeInterrupt(void)
{
PIT_PCSR_0 = (PIT_PRESCALE | PIT_DBG | PIT_OVW | PIT_PIF | PIT_RLD | PIT_PIE | PIT_EN); // Reset interrupt request flag
fnRtmkSystemTick(); // operating system tick
}
As a student you qualify for free use of the uTasker operating system and integrated TCP/IP stack. Go to
www.uTasker.com and request an educational license and you can receive complete project code. The project runs on your M52233DEMO (you can also load the binary to test it immediately from
http://www.utasker.com/software/software.html ). There is a tutorial at
http://www.utasker.com/docs/M5223X/uTaskerV1.2-Tutorial-M5223X.PDF with step-by-step instruction sfor the CodeWarrior and your board.
To see what it does, visit an on-line demo here
http://212.254.22.36 and see it via web cam at
http://212.254.22.36:8080. You can Telnet it, control things via Browser, receive Emails from it etc...
Regards
Mark
www.mjbc.ch /
www.uTasker.com