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


Software Timers Clarification

Posted by stolzie on June 23, 2015

I have been thrown into the deep end and have been given a project by an engineer that has since left the company. So I have no one to bounce questions off. I am a total beginner to the whole RTOS environment and have no idea .

I am currently looking at implementing some more software timers to handle various timeouts and connections to an FTP Server.

One, one shot Timer all ready exists that sets a flag when the timer expires and this then sends a file to the server, the timer is then reset. This is timing is happening every hour. See code below


} xApplicationFTPSendTimeout = xTimerCreate("FTP Send Timer", // Just a text name, not used by the kernel. ((60 * 60 * 1000) msec), // The timer period.
pdFALSE, // The timers will not auto-reload themselves when they expire. (void *) ApplicationFTPSendTimeout, // Assign each timer a unique id. (tmrTIMER_CALLBACK) vApplicationTimerCallback // Timer callback when it expires. ); if(xApplicationFTPSendTimeout == NULL) { // The timer was not created. LOG("Timer Not Initialized...nr"); }

} tmrTIMER_CALLBACK vApplicationTimerCallback(xTimerHandle pxTimer) { long lArrayIndex;

// Optionally do something if the pxTimer parameter is NULL.

// Which timer expired? */
lArrayIndex = (long) pvTimerGetTimerID(pxTimer);

// If the timer has expired stop it from running.
// Do not use a block time if calling a timer API function from a
// timer callback function, as doing so could cause a deadlock!

xTimerStop(pxTimer, 0);

if(lArrayIndex == ApplicationFTPSendTimeout)           stApplication.bits.APPLICATION_FTP_SEND_TIMEOUT = TRUE;



If I wanted to implement another timer to check the FTP server say every 10 minutes, I gather that I would need to create another Timer using the xTimerCreate and create another callback function for this new timer? Or can I create this new timer and use the same callback as the previous timer?

Thanks for your time.

Software Timers Clarification

Posted by stolzie on June 23, 2015

Ok so after trawling through code. I have figured out that I don't need to implement another call back as all that needs to be done is to create the new timer with xTimerCreate for the desired period and then check the lArrayIndex for the Timer ID assigned to that particular timer and then setting the timer from a Dormant state.

Feel free to delete the thread if no longer required.

Software Timers Clarification

Posted by davedoors on June 23, 2015

The handle of the timer is passed in as the callback function parameter. You dont need to check an index.

[ 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