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

is the function"eTaskGetStateFromISR"exist?

Posted by yukunduan on August 21, 2015

Now,we are writing a project upon FreeRTOS. I wrote a function suspend one task using vTaskSuspend(task1),then when DMA interrupt occur,I resume the task in interrupt using function TaskResumeFromISR(task1 ); but i met some problem: sometimes DMA interrupt won't occur(transmission broken) ,so the task won't be resume. I plan to write one timeout check in TIM interrupt,like: void TIM interrupt(void)// 0.1 second { if(eTaskGetState(task1hadle) == eSuspended)
{ if( //check 100 times ) { vTaskDelete(task1) xTaskCreate(task1) } } } but now it's halt in eTaskGetState : configASSERT( ( portNVICINTCTRLREG & portVECTACTIVE_MASK ) == 0 ); so like xTaskResumeFromISR and xTaskResume don't we have a function called eTaskGetStateFromISR?


is the function"eTaskGetStateFromISR"exist?

Posted by yukunduan on August 21, 2015

oh no,when i saw the function "vTaskDelete(task1),xTaskCreate(task1)",they all have the assert "configASSERT( ( portNVICINTCTRLREG & portVECTACTIVEMASK ) == 0 );" so ,is it impossible to execute according to my thought?


is the function"eTaskGetStateFromISR"exist?

Posted by yukunduan on August 21, 2015

well,now ,I think i have two solutions: 1.I set a global variable to receive the TIM interrupt times,and create a task that check the state of the task. like this: xTaskCreate(taskcheckfunctioin...) void TIM interrupt(void)// 0.1 second { givtimecount++; } void taskcheckfunctioin() { check according givtimecount;
if(eTaskGetState(task1hadle) == eSuspended) { if( //check 100 times ) { vTaskDelete(task1) xTaskCreate(task1) } } } 2.using Blocked state.I saw function like xQueueSendToBack or xSemaphoreTake. I can set number of timeout . when the interrupt occur ,release the semaphore.otherwise, timeout i will restart this task; like this: xSemaphore = xSemaphoreCreateBinary(); void DMA interrupt(void)// dma receive over { xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
} void task() { xSemaphoreTake( xSemaphore, portMAXDELAY ); }


is the function"eTaskGetStateFromISR"exist?

Posted by richard_damon on August 21, 2015

Normally suspending/resuming a task like this is really the wrong thing to be doing. If the task wants to wait for a DMA interrupt then wait for a semaphore that is set by that interrupt. That way you can add a timeout on the wait and the task can handle its own cleanup. (You can also use the task notification system as a lightweight version of this).

Also killing and restarting a task is a good way to mess up your program enviroment. Maybe you know that task doesn't hold any resources in this case, but in general it can be very bad. On "Big" OSes, you can kill a PROCESS and restart it, as the OS knows what resources a process owns and can clean those up. Tasks are much more light weight.


is the function"eTaskGetStateFromISR"exist?

Posted by rtel on August 21, 2015

Just to re-iterate and emphasise Richard Damon's point - using task suspend/resume as a synchronisation method in this way is dangerous and can lead to missed interrupts if there is a chance an interrupt arrived before the task has suspended. Suspending and resuming had no method of latching that an interrupt occured. I would also second the suggestion that the correct way to do this is with a semahore, because a semaphore does latch that an interrupt has occurred - better still use a direct to task notification as that is faster and has no RAM overhead.

Regards.


[ 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