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

FreeRTOS ISR Handler Task

Posted by sindhukrishnan on October 26, 2015

Hello Team !

I use TMS570LS0432 Hercules Launchpad with FreeRTOS generated from HALCogen.

I tried the following -->Create 6 Tasks (1ms, 5ms, 10ms, 20ms, 50ms, 100ms) -->Create a high priority Interrupt Handler Task. Initially this Task is suspended using vTaskSuspend(). This task is resumed only from ISR. -->Configure HET to give interrupt for every 1ms. ISR will be executed for every ENDOFPERIOD (1ms). -->Inside the ISR, I give vTaskResume() for handling Interrupt Handler Task

Now when I run the code in debug mode, I keep a breakpoint in points vTaskSuspend() inside task and vTaskResume() inside ISR. The execution stops at vTaskResume() inside ISR properly, but never enters to the Handler Task as expected. Repeatedly it enters only ISR routine.

*** But when the code is debugged Step-by-step then the code enters the Handler Task. * `#include "FreeRTOS.h" #include "FreeRTOSConfig.h" #include "gio.h" #include "het.h" #include "oseventgroups.h" #include "ostask.h" //#include "ostimer.h" #include "libdelayhookhdr.h"

#include "sys_common.h"

xTaskHandle xTask1Handle; xTaskHandle xTask2Handle; xTaskHandle xTask3Handle; xTaskHandle xTask4Handle; xTaskHandle xTask5Handle; xTaskHandle xTask6Handle;

xTaskHandle xISRHandle;

void vTask1(void *pvParameters) { for(;;) {

	vTask_PreEmp_1ms();
}

}

void vTask2(void *pvParameters) { for(;;) {

	vTask_PreEmp_5ms();
}

}

void vTask3(void *pvParameters) { for(;;) {

	vTask_PreEmp_10ms();
}

}

void vTask4(void *pvParameters) { for(;;) {

	vTask_PreEmp_20ms();
}

}

void vTask5(void *pvParameters) { for(;;) {

	vTask_PreEmp_50ms();
}

}

void vTask6(void *pvParameters) { for(;;) {

	vTask_PreEmp_100ms();
}

}

void vTaskISR(void *pvParameters) { uint32_t Count1=0;

vTaskSuspend(xISRHandle);
Count1++;

}

void main(void) { hetInit();

		_enable_interrupt_();

		    /* Create Task 1 */
		    if (xTaskCreate(vTask1,"Task1", configMINIMAL_STACK_SIZE, NULL, 6, &xTask1Handle) != pdTRUE)
		    {
		        /* Task could not be created */
		        while(1);
		    }

		    if (xTaskCreate(vTask2,"Task2", configMINIMAL_STACK_SIZE, NULL, 5, &xTask2Handle) != pdTRUE)
		        {
		            /* Task could not be created */
		            while(1);
		        }

		    if (xTaskCreate(vTask3,"Task3", configMINIMAL_STACK_SIZE, NULL, 4, &xTask3Handle) != pdTRUE)
		        {
		            /* Task could not be created */
		            while(1);
		        }

		    if (xTaskCreate(vTask4,"Task4", configMINIMAL_STACK_SIZE, NULL, 3, &xTask4Handle) != pdTRUE)
		    	    {
		    	        /* Task could not be created */
		    	        while(1);
		    	    }

		    if (xTaskCreate(vTask5,"Task5", configMINIMAL_STACK_SIZE, NULL, 2, &xTask5Handle) != pdTRUE)
		    		{
		    	            /* Task could not be created */
		    			while(1);
		    		}

		    if (xTaskCreate(vTask6,"Task6", configMINIMAL_STACK_SIZE, NULL, 1, &xTask6Handle) != pdTRUE)
		    	   {
		    	            /* Task could not be created */
		    	        while(1);
		    	   }

		    if (xTaskCreate(vTaskISR,"ISR", configMINIMAL_STACK_SIZE, NULL, 10, &xISRHandle) != pdTRUE)
		    	   {
		    	    	    	            /* Task could not be created */
		    			while(1);
		    	   }

		    pwmEnableNotification(hetREG1, pwm1, pwmEND_OF_PERIOD);
		    pwmStart( hetRAM1, pwm1);

		    /* Start Scheduler */
		    vTaskStartScheduler();

		    /* Run forever */
		    while(1);

}

void pwmNotification(hetBASE_t * hetREG,uint32 pwm, uint32 notification) {

static uint32_t ucLocalTickCount = 0;

		ucLocalTickCount++;
		vTaskResume(xISRHandle);

} void vApplicationMallocFailedHook( void ) {

	 	for( ;; );
	 }

`

Could the support team help to overcome this? Same thing happens with Event Groups and Counting Semaphores as well.


FreeRTOS ISR Handler Task

Posted by rtel on October 26, 2015

-->Create 6 Tasks (1ms, 5ms, 10ms, 20ms, 50ms, 100ms)

Is that the cycle rates of the tasks? What is the tick frequency? If it is 1KHz then remember you only have a timing granularity of 1ms - and also the 1ms task will start running after every tick (assuming it is the highest priority).

-->Create a high priority Interrupt Handler Task. Initially this Task is suspended using vTaskSuspend(). This task is resumed only from ISR.

Do NOT do this! Please read the API documentation http://www.freertos.org/taskresumefromisr.html - it is an almost guaranteed way of loosing interrupts. Consider what will happen if the interrupt tries to resume the task before it is suspended. The best method is to use a direct to task notification. http://www.freertos.org/RTOSTaskNotificationAsBinary_Semaphore.html

Repeatedly it enters only ISR routine.

Is the interrupt being cleared?


FreeRTOS ISR Handler Task

Posted by sindhukrishnan on October 26, 2015

I did all this. Yes the code works fine. But why does the control not entering the point vTaskSuspend(xISRHandle); inside the handler task after reaching xTaskResumeFromISR(xISRHandle); inside the ISR ? I raise this question after changing vTaskResume(xISRHandle); to xTaskResumeFromISR(xISRHandle).

-->Create 6 Tasks (1ms, 5ms, 10ms, 20ms, 50ms, 100ms)

Yes these are the cycle rates and the tick frequency is 1kHZ. The control never went to tasks but executed only the HET ISR at 1ms.

I didnot clear the interrupt.


FreeRTOS ISR Handler Task

Posted by shan-ahmed on October 27, 2015

Can you send me the code to for your program which works fine, as Im beginner and wanna explore more of the RTOS.. Would be grateful thankeu..


[ 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