Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


PIC32 - Using a different Timer

Posted by Marcel van Lieshout on June 16, 2013

While working on (loosely) integrating Microchip's TCP/IP and USB stacks into my FreeRTOS application, I want FreeRTOS to use a different Timer (The default Timer1 is used by Microchip stacks).

The port.c conveniently has vApplicationSetupTickTimerInterrupt() declared as "weak", allowing me to define this function, setting up a different timer, elsewhere. There also is a configuration definition for the interrupt vector (configTICK_INTERRUPT_VECTOR). This is all quite nice :)

The last line in function vPortIncrementTick() in port.c, clears the interruptflag in the following way:

/* Clear timer 1 interrupt. */

So, I still need to modify port.c to change timers. Not a big deal at first glance, but it means I am changing a core FreeRTOS file and that implicates there are license consequences.

What can I do?

RE: PIC32 - Using a different Timer

Posted by Richard on June 16, 2013
Just changing the line that clears the interrupt flag is not a problem and so no licensing issue to worry about as far as I'm concerned because you are not modifying or enhancing the behaviour of the kernel.

What is more of an issue is that the implementation was intended to be such that you would not need to do that. It looks like a bit of an omission from the port layers implementation, and maybe the line that clears the interrupt source also needs to be user definable.

The other alternative would be to implement your own "increment tick" function the the application - basically just a copy of the one from the port layer. As you have your own handler you can have the handler call your own increment tick function too.

Note that the next version of FreeRTOS will change the increment tick function somewhat as follows:

void vPortIncrementTick( void )
unsigned portBASE_TYPE uxSavedStatus;

uxSavedStatus = uxPortSetInterruptMaskFromISR();
if( xTaskIncrementTick() != pdFALSE )
/* Pend a context switch. */
_CP0_BIS_CAUSE( portCORE_SW_0 );
vPortClearInterruptMaskFromISR( uxSavedStatus );

/* Clear timer 1 interrupt. */


RE: PIC32 - Using a different Timer

Posted by Marcel van Lieshout on June 17, 2013
Richard, thank you for your reply :)

Making the "clear interrupt flag" user definable appeals to me the most. It continues to build upon the already present definable timer parameters. And, even more important for me, updating the kernel to a newer release is not obscured by having to maintain an almost duplicate version of vPortIncrementTick().

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists