How can I configure pulse counter by timer?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I configure pulse counter by timer?

3,642 Views
leeyoungjae
Contributor II

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.

pastedImage_1.png

for GIMA register ( 454 pate )

pastedImage_2.png

 

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 

Labels (3)
0 Kudos
Reply
5 Replies

2,833 Views
Vyankatesh_ATL1
Contributor I

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. 

0 Kudos
Reply

2,847 Views
jeremyzhou
NXP Employee
NXP Employee

Hi LEE Young Jae ,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

2,846 Views
leeyoungjae
Contributor II

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);
}

0 Kudos
Reply

2,847 Views
jeremyzhou
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

2,847 Views
stevenjin
Contributor I

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.

0 Kudos
Reply