Quality RTOS & Embedded Software

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


Loading

FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 16, 2016

Hi All,

We have a Polaris FPGA board in which I am able to port FreeRTOS to some extent and able to see a task with high priority running. However this execution doesn't last long as after the first tick interrupt is occured (&serviced) my high priority task should resume. This is not happening.

I have tried two tasks with same priority but still neither of the tasks were able to run after tick interrupt is handled.

Following are my two tasks built and run on CORTEX-M4F port in IAR workbench.

/* Create task to monitor processor activity */
if (xTaskCreate(prvSampleTask, "Sample", configMINIMAL_STACK_SIZE, NULL, 1, NULL) != pdPASS) {
      printf("Failed to create Sample task\r\n");
}

/* Create task to monitor processor activity */
if (xTaskCreate(prvSecond, "Secondtask", configMINIMAL_STACK_SIZE, NULL, 1, NULL) != pdPASS) {
      printf("Failed to create Second task\r\n");
}
vTaskStartScheduler();

static void prvSampleTask( void *pvParameters ) { int i=0; for( ; ; ) { printf("In SampleTask..... n"); printf("This task never ends..... n"); } }

static void prvSecond( void *pvParameters ) { for( ; ; ) { printf("rTASKn"); vTaskDelay(100); } }


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by rtel on December 16, 2016

Have you installed the tick interrupt handler? Search for the text "Special note to ARM Cortex-M users" on this page http://www.freertos.org/FAQHelp.html

Also, have you tried without the calls to printf()? I'm not sure how your printf() works but (as noted in the book) often non-thread safe or extremely stack hungry implementations of printf are actually the root cause of issues, which users then try and debug by adding even more calls to printf().


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 19, 2016

Hi,

Attached file which contains vector table for CORTEX_M4F

Attachments

startup_polaris.s (5393 bytes)

FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 19, 2016

On printf, I just implemented function putchar() as shown in attached file. I don't think this has something to do with the task resuming after a tick interrupt. Am I right?

My problem here is suppose if I have only one high priority task, the scheduler should resume same task after tick interrupt is seved(no preemption of task is required).

When I debug line by line, controller reached end of tick handler (SysTick_Handler()) and doesn't start/resume high priority task. Instead it executes instructions that follows tick handler.

Attachments

printf-stdarg.c (6451 bytes)

FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 19, 2016

As fas as I understand in FreeRTOS xTaskIncrementTick() has some logic which decides whether the current running task should be preempted or not.

Two possible values returned by this function are: 1. False (means no pre emption is required), now who will bring the same task to running state? which is paused by tick handler.

  1. True, preemption is happened with setting PENDSV bit, even this is also not helping for me. Setting PENDSV bit doesn't trigger pendsv interrupt for my CORTEX_M4F

Regards Shyam


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by rtel on December 19, 2016

This start up file is importing the FreeRTOS interrupt handlers:

     EXTERN  vPortSVCHandler
     EXTERN  xPortPendSVHandler
     EXTERN  xPortSysTickHandler

but not installing them, as the relevant snippet of the vector table shows:

     DCD     SVC_Handler	          ; SVCall Handler
     DCD     DebugMon_Handler          ; Debug Monitor Handler
     DCD     0                         ; Reserved
     DCD     PendSV_Handler            ; PendSV Handler
     DCD     SysTick_Handler           ; SysTick Handler

With this setting you would need to call the FreeRTOS handlers the same names as the handlers you have actually installed (each of which ends with "_Handler" in the code snippet above). Have you done that? The code needing to be added to FreeRTOSConfig.h to map the FreeRTOS names to the names you have actually installed is provided on the link from the first reply above in this thread.


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by rtel on December 19, 2016

I don't think that printf() would cause the issue, but it is not thread safe. Did you actually try without the printf()?


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 19, 2016

Yeah I have tried without printf()

The result is same


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 19, 2016

They are being called from same file here

PUBWEAK SysTickHandler SECTION .text:CODE:REORDER(1) SysTickHandler LDR R0, =xPortSysTickHandler BLX R0

           PUBWEAK SVC_Handler
    SECTION .text:CODE:REORDER(1)

SVC_Handler LDR R0, =vPortSVCHandler BLX R0

    PUBWEAK PendSV_Handler
    SECTION .text:CODE:REORDER(1)

PendSV_Handler LDR R0, =xPortPendSVHandler BLX R0

    And I am able to go vPortSVCHandler, xPortPendSVHandler when appropriate interrutps are triggered. Validated this with debugger

FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by rtel on December 19, 2016

Please try installing the handlers using the #defines as per the link in the original reply.


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 19, 2016

Your soulution worked for me. But couldn't conclude how....

I was just calling the same handlers from the pubweak functions. Why is that the scheduler not able to resume in the previous setup?


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by edwards3 on December 19, 2016

Your code was changing the stack before calling the FreeRTOS handler.


FreeRTOS Scheduler doesn't resume/context switch tasks after the first tick interrupt

Posted by sunnshyamthella on December 20, 2016

Thanks for your support


[ 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