This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-F280039C: Offset in FreeRTOS Task period

Part Number: LAUNCHXL-F280039C
Other Parts Discussed in Thread: SYSCONFIG

Hi,

I am currently in the process of implementing a FreeRTOS on the LAUNCHXL-F280039C. For validation, I have only created one task, which should toggle a GPIO after every tick, i.e. every millisecond. However, I observe with the oscilloscope that this always takes 65% longer, regardless of whether I set 1msec or 1sec (see screenshots). What is the reason for this?

Code:

// Included Files
#include "driverlib.h"
#include "device.h"
#include "FreeRTOS.h"
#include "board.h"
#include "c2000_freertos.h"
#include "FreeRTOSConfig.h"

// Function Prototypes
void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName);
void vApplicationMallocFailedHook( void );

// Task Functions
void Serial_polling(void * pvParameters);

//
// Main
//
void main(void)
{
Device_init(); // Initializes device clock and peripherals

Interrupt_initModule(); // Initializes PIE and clears PIE registers. Disables CPU interrupts.

Device_initGPIO();

// Disable all CPU interrupts and clear all CPU interrupt flags.
DINT;
IER = 0x0000;
IFR = 0x0000;

Interrupt_initVectorTable(); // Initializes the PIE vector table with pointers to the shell Interrupt Service Routines (ISR).

Board_init(); // Set up CPUTimer1, LEDs.

FreeRTOS_init(); // Configure FreeRTOS

//-------
while(1) // Loop forever. This statement should never be reached.
{
}
//-------
}

// Task function
void vSerial_polling(void * pvParameters)
{
TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount();

for(;;) {
GPIO_togglePin(20U); // Toggle the onboard LED
GPIO_togglePin(34U); // Toggle the GPIO for the oscilloscope
vTaskDelayUntil(&xLastWakeTime, 1 / portTICK_PERIOD_MS); // Set task period to 1msec
}
}

// vApplicationStackOverflowHook - Checks run time stack overflow
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
( void ) pcTaskName;
( void ) pxTask;

/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS();
for( ;; );
}

// vApplicationMallocFailedHook - Hook function for catching pvPortMalloc() failures
void vApplicationMallocFailedHook( void )
{
/* vApplicationMallocFailedHook() will only be called if
configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
function that will get called if a call to pvPortMalloc() fails.
pvPortMalloc() is called internally by the kernel whenever a task, queue,
timer or semaphore is created. It is also called by various parts of the
demo application. If heap_1.c or heap_2.c are used, then the size of the
heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
to query the size of free heap space that remains (although it does not
provide information on how the remaining heap might be fragmented). */
taskDISABLE_INTERRUPTS();
for( ;; );
}

SysConfig Settings for the FreeRTOS:

CPU Clock Hz: 200000000

Tick Rate Hz: 1000

Included optional API functions: vTaskDelayUntil, vTaskDelay

Screenshot Oscilloscope:

Thank you in advance

Joshua