How can I configure pulse counter by timer?
Test Board : LPC-Link2. (MCU : LPC4370)
Develop Env : LPCXpresso
Example Code : LPC Open
Target : 8MHz Pulse counter by timer )
I am trying make pulse counter by timer.
I have executed periph_blinky for testing timer1 that is working timer interrupt.
This example code working for 10Hz tick rate.
But It is not enough for My project.
I modified code for tick rate 8MHz(8000000) from 10 Hz(10) but I couldn't get 8MHz tick rate.
My project is working ADCHS that is 8MHz pulse counter by Hardware trigger of GPIO or SCT.
I am checking ADC external triggers in UM10503-User-Manual (1357 Page )
If i configure 8MHz pulse counter of timer and selecting GIMA It will be worked.
for GIMA register ( 454 pate )
Question
1. How can i configure 8MHz pulse counter by timer?
- Please let me know step by step if you can , I am beginner for LPC4370 ^^
2. How can i check pulse counter after setup 8MHz pulse counter ?
- Using toggled GPIO ?
3. if you have better idea for my project Please Let me know.
- I have to get analog result from scanner device which is external device and make analog signal by 8MHz clock
- the following timing chart is for scanner device.
- Meaning is " I have to generate 8MHz clock and send to device.
- and that clock will be used hardware trigger for SYNC.
Thanks
Dear all I am beginner to this controller please tell me how to configure Timer in LPC4337 using library and if any calculation regarding time period please let me know.
i already gone through Datasheets and user manual but i am first time working on driver based code please help me.
Hi LEE Young Jae ,
1. How can i configure 8MHz pulse counter by timer?
The periph_timers demo is the better choice to achieve your goal, and you'd better to have a through over the Chapter 32: LPC43xx/LPC43Sxx in the reference manual.
2. How can i check pulse counter after setup 8MHz pulse counter ?
Using oscilloscope is Ok.
Hope it helps.
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Dear jeremyzhou,
I have tested by your way. but I couldn't make 8MHz timer interrupt.
MAX speed : 1.6MHz --> Using Oscilloscope
You can see the following code, I changed the Match counter value 250000000 from 5.
if I have to use another way, Please let me you idea or your way.
Thanks.
static void timer_setup(void)
{
// uint32_t timerFreq;
/* 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);
/* Get timer 1 peripheral clock rate */
// Orignal code
// Chip_TIMER_SetMatch(LPC_TIMER1, 1, (Chip_Clock_GetRate(CLK_MX_TIMER1) / 5)); // 5 Hz
Chip_TIMER_SetMatch(LPC_TIMER1, 1, (Chip_Clock_GetRate(CLK_MX_TIMER1) / 25000000)); //8 MHz
Chip_TIMER_ResetOnMatchEnable(LPC_TIMER1, 1);
Chip_TIMER_Enable(LPC_TIMER1);
/* Enable timer interrupt */
NVIC_EnableIRQ(TIMER1_IRQn);
NVIC_ClearPendingIRQ(TIMER1_IRQn);
}
Hi LEE Young Jae,
I think the interrupt handler cost too much to response the match event occur on time, so I'd like to suggest that you can use the following function to toggle T1_MAT1 pin instead of the interrupt way.
Chip_TIMER_ExtMatchControlSet(LPC_TIMER1, False,TIMER_EXTMATCH_TOGGLE1);
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I have a similar issue with LPC_TIMER2. Our application needs a timer interrupt with a rate of at least 20MHz. Similar settings (refer to timer.c in sample project periph_timers) are used. The highest interrupt rate achieved is 1.6MHz rather the expected 20MHz. In my application, the timer2 ISR does nothing but increments a counter. When the counter reaches a threshold, say 5000000, the program stops and we record the time elapsed. It was noticed the elapsed time is changed as expected when the frequency is lower than 2MHz and then ceases changing after 2MHz.