# PIC32 changing timer?

**URL:** <https://forums.freertos.org/t/pic32-changing-timer/5668>\
**Category:** Kernel\
**Created:** [October 18, 2011, 7:17pm UTC](https://forums.freertos.org/t/pic32-changing-timer/5668 "2011-10-18T19:17:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 18, 2011, 7:17pm UTC](https://forums.freertos.org/t/pic32-changing-timer/5668/1 "2011-10-18T19:17:06Z")

</div>

**[ulmus71](https://sourceforge.net/u/ulmus71/)** wrote on [Tuesday, October 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/fc452a4f/#fbe2):

I was searching forum but dont know exactly:  
I want to change Timer2 into Timer5. Timer2 which is choosen in PIC32 port is imho not good. Timer 2 is used e.g. in PWM implementation in PIC32. Id like to change timer2 into 5 and want to know if it has something to do with license or not?  
And the last thing: anyone has change already timer2? there is some tricks or only changing 2’s into 5’s in source?  
Thanx in advance 🙂

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 18, 2011, 7:32pm UTC](https://forums.freertos.org/t/pic32-changing-timer/5668/2 "2011-10-18T19:32:45Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, October 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/fc452a4f/#af10):

Just change the implementation of prvSetupTimerInterrupt() in port.c, no problem.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 18, 2011, 8:19pm UTC](https://forums.freertos.org/t/pic32-changing-timer/5668/3 "2011-10-18T20:19:04Z")

</div>

**[ulmus71](https://sourceforge.net/u/ulmus71/)** wrote on [Tuesday, October 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/fc452a4f/#6ff1):

Not exactly, i can see something else in port.c:

extern void \_\_attribute\_\_( (interrupt(ipl1), vector(\_TIMER\_1\_VECTOR))) vT1InterruptHandler( void );

enough to change \_TIMER\_1\_VECTOR into \_TIMER\_5\_VECTOR, name of function can stay 😉

I hope it’s all 🙂  
but about licence: have to do something if i change those points of source?

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [October 18, 2011, 8:45pm UTC](https://forums.freertos.org/t/pic32-changing-timer/5668/4 "2011-10-18T20:45:51Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, October 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/fc452a4f/#0c4e):

You are right of course - you also have to change the vector used.

Don’t worry about the license.&nbsp; What you are doing is not adding to or modifying FreeRTOS, just changing the peripheral used to generate the tick, nothing need be done.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 25, 2012, 11:02am UTC](https://forums.freertos.org/t/pic32-changing-timer/5668/5 "2012-04-25T11:02:21Z")

</div>

**[remidebord](https://sourceforge.net/u/remidebord/)** wrote on [Wednesday, April 25, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/fc452a4f/#fe41):

We have 4 lines to change:

First, change the Vector,

extern void \_\_attribute\_\_( (interrupt(ipl1), vector(\_TIMER\_5\_VECTOR))) vT1InterruptHandler( void );

Next, change the lines in void prvSetupTimerInterrupt( void ) by these lines (for timer5),

OpenTimer5( ( T5\_ON | T5\_PS\_1\_64 | T5\_SOURCE\_INT ), ulCompareMatch );  
ConfigIntTimer5( T5\_INT\_ON | configKERNEL\_INTERRUPT\_PRIORITY );

and next modify this line in void vPortIncrementTick( void )

mT5ClearIntFlag();

Enjoy 😉

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 25, 2012, 11:23am UTC](https://forums.freertos.org/t/pic32-changing-timer/5668/6 "2012-04-25T11:23:31Z")

</div>

**[ulmus71](https://sourceforge.net/u/ulmus71/)** wrote on [Wednesday, April 25, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/fc452a4f/#b059):

Thanx&nbsp; remidebord, but as you can see, this post is 6 months old 🙂 I have already everything done and all is still working:)
