HI
I am using Timer1 to generate an interrupt at every 0.125 us ( 8MHz timer counter )
I modify timer setup code of Periph_blinky in LPCOpen.
Problem : I couldn’t generate an INT at Every 0.125us even through modify timer match value
MCU : LPC4370
Test Board: LPC-Link2 (included LPC4370)
Please check the following code that is set up timer INT for 0.125us (micro second)
static void timer_setup(void)
{
/* Enable timer 1 clock and reset it */
Chip_TIMER_Init(LPC_TIMER1);
Chip_RGU_TriggerReset(RGU_TIMER1_RST);
while (Chip_RGU_InReset(RGU_TIMER1_RST)) {}
/* Timer setup for match and interrupt at SAMPLERATE */
Chip_TIMER_Reset(LPC_TIMER1);
Chip_TIMER_MatchEnableInt(LPC_TIMER1, 1);
// Chip_TIMER_SetMatch(LPC_TIMER1, 1, (Chip_Clock_GetRate(CLK_MX_TIMER1) / SAMPLERATE));
// Chip_Clock_GetRate(CLK_MX_TIMER1): 204000000
// SAMPLERATE : 5
// Modified code for 0.125us (8MHZ) timer INT
Chip_TIMER_SetMatch(LPC_TIMER1, 1, (Chip_Clock_GetRate(CLK_MX_TIMER1) / 25000000 ));
Chip_TIMER_ResetOnMatchEnable(LPC_TIMER1, 1);
Chip_TIMER_Enable(LPC_TIMER1);
/* Enable timer interrupt */
NVIC_EnableIRQ(TIMER1_IRQn);
NVIC_ClearPendingIRQ(TIMER1_IRQn);
}
result frequency: 1.6MHz (maximum).
Question
1. Is there any limit for timer Interrupt frequency ?
- I want to generate 8Mhz timer Interrupt
2. How can I generate timer Interrupt at every 0.125us ( 8MHz ) ?
Thanks for you review.
Had you solved this Problem? I face the same question. Thanks!
Hi LEE Young Jae,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Having an interrupt at a 8MHz rate is a very bad idea. Each interrupt invokes the saving and restoring of the context, which is 12 cycles each without FPU registers.
This eats away core performance. And even with a moderate handler routine, you will quickly reach the saturation point.
Thanks! That is right, I got it.