Use hardware timers of MCU

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.

Use hardware timers of MCU

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.

Use hardware timers of MCU

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?

Use hardware timers of MCU

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.

Use hardware timers of MCU

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?

Use hardware timers of MCU

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.

Use hardware timers of MCU

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?

Use hardware timers of MCU

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.