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




Loading

Use hardware timers of MCU

Posted by PaulVali on January 2, 2013
Hello,
I'm using FreeRTOS 7.3.0 on EKK-LM3S6965 board (I'm a beginner with FreeRTOS) and I want to use hardware timers instead sw timers because I need periods smaller than 10 us. How can I use these timers (LM3S6965 has 4 hw timers)? FreeRTOS is using all hw timers and for the operations that are very fast I think that maybe it's posible to suspend FreeRTOS, save the context, do the job and resume the running of FreeRTOS.

RE: Use hardware timers of MCU

Posted by Richard on January 2, 2013
FreeRTOS does not make use of any of the peripheral timers. The only timer it uses is SysTick, which is part of the Cortex-M core.

The demo applications make use of some software timers, but the demo tasks can (should) be removed.

If you want to use the peripheral timers then I would suggest downloading the StellarisWare drivers from the TI website. There are API functions to manage the peripherals.

Regards.

RE: Use hardware timers of MCU

Posted by PaulVali on January 3, 2013
Thank you very much for your answer it was helpful and now is working everything. I have one more question:
In code I have this instruction:
SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ );

and in debug I can see that the MCU is working at 37.5 MHz and it should work on 50 MHz. Also in FreeRTOSConfig.h I have this define:
#define configCPU_CLOCK_HZ( ( unsigned long ) 50000000 )


What the actual frequency of the MCU in this case?

RE: Use hardware timers of MCU

Posted by Richard on January 3, 2013
“and in debug I can see that the MCU is working at 37.5 MHz and it should work on 50 MHz”


How can you tell that? Have you measured it?

“What the actual frequency of the MCU in this case?”


Sorry - that is not a FreeRTOS question. To answer I would have to look at the datasheet for the microcontroller and the API documentation for the function - I'm happy to leave that to you...

Regards.

RE: Use hardware timers of MCU

Posted by Jay Khandhar on February 25, 2013
I need help on the same issue.

I am also working on the Stellaris LM3S8962 development board.

Even I am using the hardware timers to generate periodic timer interrupts, and analyse the data computed by the tasks that I have written. In short the timer interrupt handlers work as debug tools which help me to analyse my tasks.

The hardware timers have their own Interrupt Service Routines, which run automatically when the count overflows.

1. So they are not related to FreeRTOS? On who's context do they run?

2. So do they have an impact on performance of FreeRTOS?

RE: Use hardware timers of MCU

Posted by Dave on February 25, 2013
“1. So they are not related to FreeRTOS? On who's context do they run?”


If you configure a hardware timer to generate an interrupt then the interrupt service routine runs as an interrupt, it is not in the context of any task.

2. So do they have an impact on performance of FreeRTOS?


Your application can use 100% of CPU time. The 100% is split between executing interrupts and executing non-interrupt code (which may be a FreeRTOS application). If 5% of you time is spent executing interrupts then your non interrupt code only has 95% of the time left over, so yes interrupts always impact the performance of any code, not just FreeRTOS code.

RE: Use hardware timers of MCU

Posted by Jay Khandhar on February 25, 2013
Thank you for the quick reply.

So when I do a xSemaphoreGive in a Hardware Timer's ISR, will that be semaphore be given immediately, and will release a task blocked on that semaphore?
Or will it be given in the next tick, when the scheduler will run?

RE: Use hardware timers of MCU

Posted by Richard Damon on February 25, 2013
First, read the instructions for writing ISRs that interact with FreeRTOS. An ISR routine should NOT call xSemaphoreGive as that can cause data corruption. It needs to call xSemaphoreGiveFromISR (ISR routines need to call the FromISR version of the API functions).

As to resuming a now unblocked task, you need to look at the instructions for your port on how to activate the scheduler from your ISR to start the task up immediately. The xSemaphoreGiveFromISR has a parameter that you need to use to determine if you need to do this.


[ 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