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.

RTOS/TMS570LC4357: Problem with HALCoGen FreeRTOS project

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Tool/software: TI-RTOS

Hi 

I have created two task:-

one xTaskCreate(vTask1) and xTaskCreateRestricted(vTask2) for checking functionality of FREERTOS , but while the pro-game goes to vTask1 then from there its moving to prefetchEntry, why is it happening like this, and if i remove the  xTaskCreateRestricted(vTask2) its working fine.is it due to one privileged and user mode, if so how can i resolve it.

I have generated the code/driver from HalcoGen, and using CCS studio(version7)

code snippet:-

#include "HL_sys_common.h"
#include "HL_system.h"

/* USER CODE BEGIN (1) */
/* Include FreeRTOS scheduler files */
#include "FreeRTOS.h"
#include "os_task.h"

/* Include HET header file - types, definitions and function declarations for system driver */
#include "HL_het.h"
#include "HL_esm.h"

extern void blink(void);
/* Stack Buffer for Task 1 */
//#pragma DATA_ALIGN(stackbuffer, configMINIMAL_STACK_SIZE*sizeof(portSTACK_TYPE))
static portSTACK_TYPE stackbuffer[configMINIMAL_STACK_SIZE] __attribute__ ((aligned (configMINIMAL_STACK_SIZE * sizeof(portSTACK_TYPE))));

/* Define Task Handles */
xTaskHandle xTask1Handle;
xTaskHandle xTask2Handle;
/* Task function */
void vTask1(void *pvParameters)
{
/* Set high end timer GIO port hetPort pin direction to all output */
//gioSetDirection(hetPORT1, 0xFFFFFFFF);

for(;;)
{
/* Toggle HET[1] with timer tick */
blink();
// gioSetBit(hetPORT1, 17, gioGetBit(hetPORT1, 17) ^ 1);
vTaskDelay(100);
}
}


void vTask2(void *pvParameters)
{
while(1)
{
blink();
//sciSend(sciREG1,14,(unsigned char *)"\r\nTask2:\r\n");
vTaskDelay(1000);
}
}

/*Task 1 Parameters*/
static const xTaskParameters xTaskParamters1={
vTask1, /* Function that implements the task */
(const signed char *)"Blinky",/* Just a text name for the task to assist debugging */
configMINIMAL_STACK_SIZE, /* Stack size */
NULL, /* Parametrs to be passed to the task function */
1, /* Task Priority. set the portPRIVILEGE_BIT (1|portPRIVILEGE_BIT) if the task should run in a privileged state*/
stackbuffer, /* Buffer to be used as the task stack */
/* xRegions - Allocate up to three separate memory regions for access by the task, with appropriate access permissions.*/
/* No region is set in this example. */
{ /* Base address Length Parameters */
{0,0,0}, /* { cReadWriteArray, 32, portMPU_REGION_READ_WRITE }, */
{0,0,0}, /* { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY }, */
{0,0,0} /* { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }*/
}
};
/* USER CODE END */


/** @fn void main(void)
* @brief Application main function
*
*/

/* USER CODE BEGIN (2) */
/* USER CODE END */


void main(void)
{
/* USER CODE BEGIN (3) */

/* Create Task 1 */
if (xTaskCreateRestricted(&xTaskParamters1, &xTask1Handle) != pdTRUE)
{
/* Task could not be created */
while(1);
}
/* Create Task 2 */
if (xTaskCreate(vTask2,"Task2", configMINIMAL_STACK_SIZE, NULL, 1, &xTask2Handle) != pdTRUE)
{
/* Task could not be created */
while(1);
}
/* Start Scheduler */
vTaskStartScheduler();

/* Run forever */
while(1);
/* USER CODE END */
}

Can you please provide your feedback on this.

  • Hello Ramesh,

    You can use the CP15 fault status registers to see information about the exception such as which domain it is happening in and what the offending address was that cause it. This often will help determine the root cause. The data and instruction fault status registers are viewable through the registers window in CCS. The bit definitions are defined in the ARM user guide for the Cortex-R5F (search for DFSR and/or IFSR).

    The ARM user guide is available on the ARM website as an online manual or as a downloadable PDF.

    For the downloadable PDF version: infocenter.arm.com/.../DDI0460D_cortex_r5_r1p2_trm.pdf

    For the online version: infocenter.arm.com/.../index.html
  • Hello Ramesh,

    Can you add the memory region and try again?

    static portSTACK_TYPE xTaskStack[configMINIMAL_STACK_SIZE] __attribute__ ((aligned (configMINIMAL_STACK_SIZE * sizeof(portSTACK_TYPE))));

    /* Declare an array that will be accessed by the protected task being created. The task should only be able to read from the array, not write to it. */
    static portSTACK_TYPE stackbuffer[configMINIMAL_STACK_SIZE] __attribute__ ((aligned (configMINIMAL_STACK_SIZE * sizeof(portSTACK_TYPE))));

    /* Fill in a TaskParameters_t structure to define the task. This is the structure passed to the xTaskCreateRestricted() function. */
    static const TaskParameters_t xTaskParamters1 =
    {
    vTask1, /* Function that implements the task */
    (const signed char *)"Blinky", /* Just a text name for the task to assist debugging */
    configMINIMAL_STACK_SIZE, /* Stack size */
    NULL, /* Parametrs to be passed to the task function */
    1, /* Task Priority. set the portPRIVILEGE_BIT (1|portPRIVILEGE_BIT) if the task should run in a privileged state*/
    xTaskStack, /* puxStackBuffer - the array to use as the task stack. */
    /* xRegions - In this case, only one of the three user-definable regions is actually used. The parameters are used to set the region to read-only. */
    {
    /* Base address Length Parameters */
    { stackbuffer, 512, portMPU_REGION_READ_ONLY },
    { 0, 0, 0 },
    { 0, 0, 0 },
    }
    };

    void main( void )
    {
    /* Create the task defined by xTaskParamters1. NULL is used as the second parameter because a task handle is not required. */
    if (xTaskCreateRestricted(&xTaskParamters1, &xTask1Handle) != pdTRUE)
    {
    /* Task could not be created */
    while(1);
    }
    /* Start the scheduler. */
    vTaskStartScheduler();
    /* Should not reach here! */
    }
  • Hi Wang

    Thank you.
    This worked for me.