Arduino Due Interrupt Problems using RTOS

Hello All, I’m able to run three different tasks using RTOS but have problems when i have to Blink an Led on an interrupt.The LED blinks  with interrupts  perfectly fine without the RTOS.When i introduce the task with interrupts none of the other tasks work ,the interrupt first triggers once the code is loaded and all the other tasks freeze .When i disable the task with interrupts the other tasks work fine .I guess there’s an issue on the software side ,i have posted the code please let me know where i’m going wrong .
 #include <FreeRTOS_ARM.h>
            #include <Servo.h> 
           Servo servo;
#undef F
#define F(str) str
float temp=0;
float val=0;
int in1Pin = 22;
int in2Pin = 23;
int state=LOW;
int interuptpin=24;
xSemaphoreHandle sem=NULL;
static void CriticalTask(void *pvParameters) {
  portTickType xLastWakeTime;
  
  xLastWakeTime = xTaskGetTickCount();
   
  for (;;) {
    
    vTaskDelayUntil( &xLastWakeTime,20);
    
     analogReadResolution(10);
     val=analogRead(A0);
     temp = ( 3.3 * val * 100.0) /1024; 
     
     if(temp>20.00)
     {
     
     digitalWrite(in1Pin,HIGsH);
     digitalWrite(in2Pin,LOW);
     
     }
     else
    {
      digitalWrite(in1Pin,LOW);
      digitalWrite(in2Pin,LOW);
     
     }
       
  }
}
static void ServoMotor(void *pvParameters) {
  servo.attach(9);
   
  for (;;) {
    servo.write(90);
    
    vTaskDelay((1000L * configTICK_RATE_HZ) / 1000L);
    
    servo.write(0);
    
    vTaskDelay((1000L * configTICK_RATE_HZ) / 1000L);
   
  }
}
static void vLEDFlashTask(void *pvParameters) {
  pinMode(13, OUTPUT);
  
  // Flash led every 200 ms.
  for (;;) {
    // Turn LED on.
    digitalWrite(13, HIGH);
    
    // Sleep for 50 milliseconds.
    vTaskDelay((50L * configTICK_RATE_HZ) / 1000L);
    
    // Turn LED off.
    digitalWrite(13, LOW);
    
    // Sleep for 150 milliseconds.
    vTaskDelay((150L * configTICK_RATE_HZ) / 1000L);
  }
}
static void LedTurnOn(void *pvParameters) {
  pinMode(25, OUTPUT);
  for (;;) {
    
    xSemaphoreTake(sem,5);
    
    state = !state;
    digitalWrite(25,state);
  }
}
void InteruptHandler()
{
  static signed portBASE_TYPE xHigherPriorityTaskWoken;
  xHigherPriorityTaskWoken = pdFALSE;
  Serial.println("n Inside Interrupt");
  xSemaphoreGiveFromISR(sem,&xHigherPriorityTaskWoken);
  
}
void setup() {
  
  Serial.begin(9600);
  
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(interuptpin,INPUT);
  
  attachInterrupt(interuptpin,InteruptHandler,CHANGE);
  
  sem = xSemaphoreCreateCounting(1, 0);
  
/* xTaskCreate(ServoMotor,
    (signed portCHAR *)"ServoTask",
    configMINIMAL_STACK_SIZE + 50,
    NULL,3,NULL);*/
    
 xTaskCreate(vLEDFlashTask,
    (signed portCHAR *)"Blinker",
    configMINIMAL_STACK_SIZE + 50,
    NULL,
    1,
    NULL);
    

 /*xTaskCreate(CriticalTask,
    (signed portCHAR *)"Critical task",
    configMINIMAL_STACK_SIZE + 50,
    NULL,
    4,
    NULL);   */
    
    
 xTaskCreate(LedTurnOn,
    (signed portCHAR *)"Working With Interrupt",
    configMINIMAL_STACK_SIZE + 50,
    NULL,
    2,
    NULL);
  noInterrupts();
  vTaskStartScheduler();
  interrupts();
}
void loop() {
  // put your main code here, to run repeatedly: 
  
}

Arduino Due Interrupt Problems using RTOS

A quick scan of your code does not show anything obviously wrong – if the application was running ‘bare metal’ (say using Atmel Studio rather than the Arduino IDE), but I’m not familiar with the internal workings of the Arduino system.  There could be a start up code issue perhaps, or a clash between a resource used by FreeRTOS and a resource used by Arduino, or even a problem because it is C++. However, in this case you are starting the scheduler from the setup() function.  If doing that is appropriate and the call passes then nothing past vTaskStartScheduler() will be called because the tasks will be running, meaning your call to interrupts() will never be executed, loop() will never be executed, and the internal Arduino polling scheduler will never execute.  If you wanted loop() to be executed you could put it in the idle task hook. You could alternatively switch to Atmel Studio, the ASF Wizard has a FreeRTOS project that targets the Duo hardware. Regards.

Arduino Due Interrupt Problems using RTOS

I had read through the couple of forum posts stating that the interrupts must not be triggered at the start of the scheduler , so i disabled interrupts .usually the call to interrupts will not be reached once the tasks are in place .