void init_timer16(uint8_t timer_num, uint32_t TimerInterval) { if ( timer_num == 0 ) { LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7); LPC_IOCON->PIO0_2 &= ~0x07;/* Timer0_16 I/O config */ LPC_IOCON->PIO0_2 |= 0x02;/* Timer0_16 CAP0 */ LPC_IOCON->PIO0_8 &= ~0x07; LPC_IOCON->PIO0_8 |= 0x02;/* Timer0_16 MAT0 */ LPC_IOCON->PIO0_9 &= ~0x07; LPC_IOCON->PIO0_9 |= 0x02;/* Timer0_16 MAT1 */ #ifdef __JTAG_DISABLED LPC_IOCON->JTAG_TCK_PIO0_10 &= ~0x07; LPC_IOCON->JTAG_TCK_PIO0_10 |= 0x03;/* Timer0_16 MAT2 */ #endif timer16_0_counter = 0; LPC_TMR16B0->MR0 = TimerInterval; LPC_TMR16B0->MCR = 3;/* Interrupt and Reset on MR0 */ /* Enable the TIMER0 Interrupt */ NVIC_EnableIRQ(TIMER_16_0_IRQn); } else if ( timer_num == 1 ) { LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8); LPC_IOCON->PIO1_8 &= ~0x07;/* Timer1_16 I/O config */ LPC_IOCON->PIO1_8 |= 0x01;/* Timer1_16 CAP0 */ LPC_IOCON->PIO1_9 &= ~0x07; LPC_IOCON->PIO1_9 |= 0x01;/* Timer1_16 MAT0 */ LPC_IOCON->PIO1_10 &= ~0x07; LPC_IOCON->PIO1_10 |= 0x02;/* Timer1_16 MAT1 */ timer16_1_counter = 0; LPC_TMR16B1->MR0 = TimerInterval; LPC_TMR16B1->MCR = 3;/* Interrupt and Reset on MR1 */ /* Enable the TIMER1 Interrupt */ NVIC_EnableIRQ(TIMER_16_1_IRQn); } return; } |