Content originally posted in LPCWare by ethan_kao on Mon Feb 02 23:57:26 MST 2015
Dear all,
For my application in LPC1113, need a 1us unit timer to count, below is my timer definition
I also use one I/O output to measure the cycle time of TIMER16_1_IRQHandler function
I measure the I/O from LOW to HIGH is 1.76us; I/O from HIGH to LOW is 1.62us
Is it means my code need more than 1us execute time? :((
Is 1us timer is possible or I miss something??
void main
{
init ...
init_timer16(1, 48M/1M );
init ...
timerResetflag1=0;
}
void init_timer16(uint8_t timer_num, uint32_t TimerInterval)
{
if ( timer_num == 1 )
{
/* Some of the I/O pins need to be clearfully planned if
you use below module because JTAG and TIMER CAP/MAT pins are muxed. */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8);
LPC_IOCON->PIO1_10 &= ~0x07;
LPC_IOCON->PIO1_10 |= 0x02;/* Timer1_16 MAT1 */
LPC_TMR16B1->MR0 = TimerInterval;
LPC_TMR16B1->MCR = 3;/* Interrupt and Reset on MR0 */
/* Enable the TIMER1 Interrupt */
NVIC_EnableIRQ(TIMER_16_1_IRQn);
}
return;
}
void TIMER16_1_IRQHandler(void)
{
//GPIOSetValue(1,2,0);
LPC_TMR16B1->IR = 1;// clear interrupt flag
timer16_1_counter++;
if(timerResetflag1==1)//when re-enable timer, reset counter
{
timer16_1_counter=0;
timerResetflag=0;
timerResetflag1=0;
}
//GPIOSetValue(1,2,1);
return;
}