Thanks
Geoffrey
#define DTIM3_VECTOR 0x56
#define INTERRUPT_LEVEL_4 (0x04 3)
#define INTERRUPT_PRIORITY_1 0x1
#define DTIM3_PIF_INT_L 0x00400000
#define MASK_ALL_INT 0x00000001
#define BUS_CLOCK (60000000)
#define DMA_TIM_EVENT_CAP 0x0001
#define DMA_TIM_EVENT_REF 0x0002
#define BUS_CLOCK_16 0x0004
#define DMA_TIM_RESTART 0x0008
#define ORRI 0x0010
#define ENABLE_DMA_TIMER 0x0001
static __interrupt__ void _hwtimer_interrupt(void)
{
DTRR3 = 0; // clear reference to indicate not in use
DTER0 = DMA_TIM_EVENT_REF; // reset interrupt request flag
// Do stuff here
// ..
}
// Start a single short hardware timer for a delay in ms units
//
externt void fnStartDelay(unsigned long ulMilliSeconds)
{
__VECTOR_RAM[DTIM3_VECTOR] = (unsigned long)_hwtimer_interrupt; // enter the interrupt routine
IC_ICR_0_22 = (INTERRUPT_LEVEL_4 | INTERRUPT_PRIORITY_1); // define interrupts level and priority
IC_IMRL_0 &= ~(DTIM3_PIF_INT_L | MASK_ALL_INT); // unmask interrupt source
DTRR3 = (ulMilliSeconds * ((BUS_CLOCK / 16 / 1000)); // set ms unit compare rate (max about 19 minutes)
DTER3 = (DMA_TIM_EVENT_CAP | DMA_TIM_EVENT_REF); // Clear possible events
DTMR3 = (BUS_CLOCK_16 | DMA_TIM_RESTART | ORRI | ENABLE_DMA_TIMER); // Bus clock / 16, enable interrupt and enable timer (again)
}
Message Edited by mjbcswitzerland on 2007-01-2512:50 PM