PIC32 changing timer?

ulmus71 wrote on Tuesday, October 18, 2011:

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 :slight_smile:

rtel wrote on Tuesday, October 18, 2011:

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

Regards.

ulmus71 wrote on Tuesday, October 18, 2011:

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 :wink:

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

rtel wrote on Tuesday, October 18, 2011:

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

Don’t worry about the license.  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.

remidebord wrote on Wednesday, April 25, 2012:

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 :wink:

ulmus71 wrote on Wednesday, April 25, 2012:

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