Toggling between Timer and Capture Functionality

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

Toggling between Timer and Capture Functionality

830 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sns22 on Thu Jan 07 08:56:17 MST 2016
Hi all,

I am working with LPC 2468 in an embeddedartists board.

In my design I am interfacing to 8 PWM capture based sensors(PT100 using UTI and Max sensor).
To achieve it I used the 2 PWM captures and 6 timer (T1 T2 T3 CAP 0&1) captures.  (all are hard wired )

But now I face a design complexity where I have no free timers to be used for adding delay in the main code. T0 is being used for Ethernet uip code.

I had an idea to toggle between timer and capture functionality in software. All the capture signals are hardwired on the board. But this is not working. When I turn on the timer functionality and turn it off later it messes up with the counter in the sensor.

Is there a way to do it where one can switch in software between timer and capture functionality. My sensor capture code does not use the timer from the same line.

For eg:: My idea was to use Timer 1 while using cap functionality of Timer 2 and to use Timer 2 while using the capture functionality of Timer 1.

I set PCONP_bit.PCTIM1 ,2,3 = 0 at the end of the capture code. I  also reset the PINSEL = 0  after the capture code is finished.

Am I missing something here??

Cheers
Labels (1)
0 Kudos
Reply
2 Replies

790 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sns22 on Fri Jan 08 03:32:20 MST 2016
Hi wmues,

I will try your option as well.

But I wanted to know also if toggling between timer and counter is possible or is it set internally that only one of the hardware(timer or counter) can be used. Although I believe it should be possible in software to toggle between both options.

I think I am missing something here??


Cheers
0 Kudos
Reply

790 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Fri Jan 08 01:37:41 MST 2016
You may use another peripheral as timer.

For example:
- the SPI interface has a clock generator and an interrupt flag (if a data transfer ends).
- Programm the clock generator to 1/8 of your timeout value.
- Send a byte out over SPI.
- If the SPI interrupt fires, increment a timer variable and send a new byte over SPI.

So you can emulate a timer with an unused peripheral which has a clock divider.
0 Kudos
Reply