Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner