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.

TMS570LC4357: Halcogen FreeRTOS

Part Number: TMS570LC4357


I have created a project with below tasks and tested the periodicity of each task which was as expected, but when I changed the stack size of the tasks as shown in second part I observed task is not executing with fixed period.

Can you please let me know the exact root cause of the behavior and its solution.

#if 0
 /* all task executes with configured period*/
         xTaskCreate(vEv_20ms1,"Test_20ms1", 1000, NULL, 23, NULL);
         xTaskCreate(vEv_50ms1,"Test_50ms1", 100, NULL, 28, NULL);
         xTaskCreate(vEv_50ms2,"Test_50ms2", 100, NULL, 25, NULL);
         xTaskCreate(vEv_100ms1,"Test_100ms1", 100, NULL, 1, NULL);
         xTaskCreate(vEv_100ms2,"Test_100ms2", 100, NULL, 1, NULL);
         xTaskCreate(vEv_100ms3,"Test_100ms3", 100, NULL, 1, NULL);
         xTaskCreate(vEv_100ms4,"Test_100ms4", 100, NULL, 1, NULL);
         xTaskCreate(vEv_100ms5,"Test_100ms5", 100, NULL, 1, NULL);
         xTaskCreate(vEv_100ms6,"Test_100ms6", 100, NULL, 1, NULL);
         xTaskCreate(vEv_500ms1,"Test_500ms1", 100, NULL, 1, NULL);
         xTaskCreate(vEv_500ms2,"Test_500ms2", 100, NULL, 1, NULL);
         xTaskCreate(vEv_500ms3,"Test_500ms3", 100, NULL, 1, NULL);
         xTaskCreate(vEv_500ms4,"Test_500ms4", 100, NULL, 1, NULL);
         xTaskCreate(vEv_1000ms1,"Test_1000ms1", 100, NULL, 1, NULL);
         xTaskCreate(vEv_1000ms2,"Test_1000ms2", 100, NULL, 1, NULL);
 #else
 /* Task lost its periodicity*/
         xTaskCreate(vEv_20ms1,"Test_20ms1", 4000, NULL, 23, NULL);
         xTaskCreate(vEv_50ms1,"Test_50ms1", 200, NULL, 27, NULL);
         xTaskCreate(vEv_50ms2,"Test_50ms2", 500, NULL, 25, NULL);
         xTaskCreate(vEv_100ms1,"Test_100ms1", 1000, NULL, 21, NULL);
         xTaskCreate(vEv_100ms2,"Test_100ms2", 1000, NULL, 18, NULL);
         xTaskCreate(vEv_100ms3,"Test_100ms3", 200, NULL, 17, NULL);
         xTaskCreate(vEv_100ms4,"Test_100ms4", 4000, NULL, 16, NULL);
         xTaskCreate(vEv_100ms5,"Test_100ms5", 500, NULL, 15, NULL);
         xTaskCreate(vEv_100ms6,"Test_100ms6", 1000, NULL, 14, NULL);
         xTaskCreate(vEv_500ms1,"Test_500ms1", 500, NULL, 12, NULL);
         xTaskCreate(vEv_500ms2,"Test_500ms2", 400, NULL, 10, NULL);
         xTaskCreate(vEv_500ms3,"Test_500ms3", 400, NULL, 8, NULL);
         xTaskCreate(vEv_500ms4,"Test_500ms4", 1000, NULL, 6, NULL);
         xTaskCreate(vEv_1000ms1,"Test_1000ms1", 1000, NULL, 4, NULL);
         xTaskCreate(vEv_1000ms2,"Test_1000ms2", 500,  NULL, 2, NULL);
#endif

FYI
FreeRTOSConfig.h is as below

#define configUSE_PREEMPTION		  1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION	1
#define configUSE_FPU							1
#define configUSE_IDLE_HOOK			  0
#define configUSE_TICK_HOOK			  0
#define configUSE_TRACE_FACILITY	  1
#define configUSE_16_BIT_TICKS		  0
#define configCPU_CLOCK_HZ			  ( ( unsigned portLONG ) 80000000 ) /* Timer clock. */
#define configTICK_RATE_HZ			  ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES		  ( 30 )
#define configMINIMAL_STACK_SIZE	  ( ( unsigned portSHORT ) 128 )
#define configTOTAL_HEAP_SIZE		  ( ( size_t ) 250000 )
#define configMAX_TASK_NAME_LEN		  ( 16 )
#define configIDLE_SHOULD_YIELD		  1
#define configGENERATE_RUN_TIME_STATS 1
#define configUSE_MALLOC_FAILED_HOOK  0

Case 1: Working version maximum task almost with same stack and priority
Result: Works normally
Case 2: Changed stack and priority
Result: Works with abnormal period

Case3: Changed only stack size with respect to working version
Result: Get stuck at b dataEntry

Case4: Changed only priority with respect to working version
Result: executes with expected period, normal behaviour

If its due to data exception, can you please guide me how to fix it? Its debug procedure.

heap configured is more than the total stack configured by all task and there is no function in any task so stack usage is might be around 20 30 bytes.

Thanks and Regards,

Kishor

  • Hi Kishor,

    Case 2: Changed stack and priority
    Result: Works with abnormal period
    Case3: Changed only stack size with respect to working version
    Result: Get stuck at b dataEntry

    Does case 3 use the same stack size as case 2? 

    Please take a look in your map file which will tell you available RAM for heap and data. When you get data abort, check the data abort status and address (CP15 registers) and abt_R14.

    https://software-dl.ti.com/hercules/hercules_docs/latest/hercules/FAQ/FAQ.html#troubleshooting-abort-exceptions

  • Thank you for your reply,

    Not a single query got resolved till now, I have shared the project also its been pending from more than 1.5 months. Please resolve them one by one. 

    Does case 3 use the same stack size as case 2? => yes

  • Please find the map file in attachment,

    It will be helpful if you explain the memory utilization, in the map file. 

    Regards,

    Kishor

  • I hope you are talking about these registers.

    Regards,

    Kishor

  • Hello, Can you please guide me to fix the issue?

    Regards,

    Kishor

  • HI Kishor,

    Can I have the link to download your code? 

    The status value (0x80D) means your code is trying to write data to a protected location. Do you switch the tasks into user mode? The MPU setting for SRAM is read-only in user mode.

  • I have attached the project please acknowledge once you download successfully.

    Regards,

    Kishor

  • Hi Kishor,

    I didn't get the link.

  • I have attached the project in message itself. Please let me know the method to share the project if attachment does not work.

  • D:\Project_OS\FOS\02

    I tried all methods but can not share the zip file, please let me know the possible method.

  • I tried all of them but none of them work to attach a zip folder of full project.

  • I am not sure if there is a size restriction for a attachment to e2e thread. Can you attach a small file to e2e thread?

  • Hi, Mr. Wang,
    I am Kishor please check if you get the attachment.

    Regards,
    Kishor

    Hi, Mr. Wang,
    I am Kishor please check if you get the attachment.
    
    Regards,
    Kishor

  • I think I can attached a file but not project, please tell me how can I share the project. I am facing lots of issue which I guess are related.

  • Hi Kishor,

    I didn't get your email with a attachment. 

  • Its not possible to attach the project in the forum, please provide me alternate method or your email id.

    Regards,

    Kishor

  • Hi Kishor,

    I run a test with 15 tasks as you did, but I didn't get data abort. Attached is my working main file. 

    In my test code

    when abc=0, your original setting

    when abc=1, the stack and priority are changed

    when abc=2, the task changed, but the priority keep same

    Case 2: Changed stack and priority
    Result: Works with abnormal period

    How do you measure the period?

    Case3: Changed only stack size with respect to working version
    Result: Get stuck at b dataEntry

    I don't get data abort. 

    /** @file HL_sys_main.c 
    *   @brief Application main file
    *   @date 11-Dec-2018
    *   @version 04.07.01
    *
    *   This file contains an empty main function,
    *   which can be used for the application.
    */
    
    /* 
    * Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com  
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    /* Include Files */
    
    #include "HL_sys_common.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_gio.h"
    #include "HL_esm.h"
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    /* Define Task Handles */
    void vPrintString( const char *pcString )
    {
         static char cBuffer[60];
         /* Write the string to stdout, using a critical section as a crude method
          of mutual exclusion. */
         taskENTER_CRITICAL();
         {
           sprintf( cBuffer, "%s", pcString );
           printf( cBuffer );
         }
         taskEXIT_CRITICAL();
    }
    
    void vEv_20ms1(void *pvParameters)
    {
        const char *pcTaskName = "Task #1   vEv_20ms1  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 20 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 20 / portTICK_RATE_MS ) );
        }
    }
    void vEv_50ms1(void *pvParameters)
    {
        const char *pcTaskName = "Task #2   vEv_50ms1  \n";
        portTickType xLastWakeTime;
    
        pcTaskName = ( char * ) pvParameters;
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            vPrintString( pcTaskName );
            vTaskDelayUntil( &xLastWakeTime, ( 50 / portTICK_RATE_MS ) );
        }
    }
    
    void vEv_50ms2(void *pvParameters)
    {
        const char *pcTaskName = "Task #3   vEv_50ms2  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 50 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 50 / portTICK_RATE_MS ) );
        }
    }
    
    void vEv_100ms1(void *pvParameters)
    {
        const char *pcTaskName = "Task #4   vEv_100ms1  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 100 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 100 / portTICK_RATE_MS ) );
        }
    }
    
    void vEv_100ms2(void *pvParameters)
    {
        const char *pcTaskName = "Task #5   vEv_100ms2  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 100 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 100 / portTICK_RATE_MS ) );
        }
    }
    void vEv_100ms3(void *pvParameters)
    {
        const char *pcTaskName = "Task #6   vEv_100ms3  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 100 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 100 / portTICK_RATE_MS ) );
        }
    }
    void vEv_100ms4(void *pvParameters)
    {
        const char *pcTaskName = "Task #7   vEv_100ms4  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 100 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 100 / portTICK_RATE_MS ) );
        }
    }
    void vEv_100ms5(void *pvParameters)
    {
        const char *pcTaskName = "Task #8   vEv_100ms5  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 100 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 100 / portTICK_RATE_MS ) );
        }
    }
    void vEv_100ms6(void *pvParameters)
    {
        const char *pcTaskName = "Task #9   vEv_100ms6  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 100 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 100 / portTICK_RATE_MS ) );
        }
    }
    
    void vEv_500ms1(void *pvParameters)
    {
        const char *pcTaskName = "Task #10   vEv_500ms1  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 500 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 500 / portTICK_RATE_MS ) );
        }
    }
    
    void vEv_500ms2(void *pvParameters)
    {
        const char *pcTaskName = "Task #11   vEv_500ms2  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 500 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 500 / portTICK_RATE_MS ) );
        }
    }
    void vEv_500ms3(void *pvParameters)
    {
        const char *pcTaskName = "Task #12   vEv_500ms3  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 500 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 500 / portTICK_RATE_MS ) );
        }
    }
    void vEv_500ms4(void *pvParameters)
    {
        const char *pcTaskName = "Task #13   vEv_500ms4  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 500 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 500 / portTICK_RATE_MS ) );
        }
    }
    
    void vEv_1000ms1(void *pvParameters)
    {
        const char *pcTaskName = "Task #14   vEv_1000ms1  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 1000 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 1000 / portTICK_RATE_MS ) );
        }
    
    }
    
    void vEv_1000ms2(void *pvParameters)
    {
        const char *pcTaskName = "Task #15   vEv_1000ms2  \n";
        portTickType xLastWakeTime;
    
        /* The xLastWakeTime variable needs to be initialized with the current tick
        count. Note that this is the only time the variable is written to explicitly.
        After this xLastWakeTime is updated automatically internally within
        vTaskDelayUntil(). */
        xLastWakeTime = xTaskGetTickCount();
    
        /* As per most tasks, this task is implemented in an infinite loop. */
        for(;;)
        {
            /* Print out the name of this task. */
            vPrintString( pcTaskName );
            /* This task should execute exactly every 1000 milliseconds. As per
            the vTaskDelay() function, time is measured in ticks, and the
            portTICK_RATE_MS constant is used to convert milliseconds into ticks.
            xLastWakeTime is automatically updated within vTaskDelayUntil() so is not
            explicitly updated by the task. */
            vTaskDelayUntil( &xLastWakeTime, ( 1000 / portTICK_RATE_MS ) );
        }
    
    }
    /* USER CODE END */
    
    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */
    
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    
    int main(void)
    {
    /* USER CODE BEGIN (3) */
        esmREG->SR1[0] = 0xFFFFFFFF;
        esmREG->SR1[1] = 0xFFFFFFFF;
        esmREG->SR1[2] = 0xFFFFFFFF;
        esmREG->SSR2 = 0xFFFFFFFF;
        esmREG->EKR = 0x0A;
        esmREG->EKR = 0x0;
    
        uint8 abc;
    
        abc = 1;
    
    if (abc == 0)
    {
     /* all task executes with configured period*/
             xTaskCreate(vEv_20ms1,"Test_20ms1", 1000, NULL, 23, NULL);
             xTaskCreate(vEv_50ms1,"Test_50ms1", 100, NULL, 28, NULL);
             xTaskCreate(vEv_50ms2,"Test_50ms2", 100, NULL, 25, NULL);
             xTaskCreate(vEv_100ms1,"Test_100ms1", 100, NULL, 1, NULL);
             xTaskCreate(vEv_100ms2,"Test_100ms2", 100, NULL, 1, NULL);
             xTaskCreate(vEv_100ms3,"Test_100ms3", 100, NULL, 1, NULL);
             xTaskCreate(vEv_100ms4,"Test_100ms4", 100, NULL, 1, NULL);
             xTaskCreate(vEv_100ms5,"Test_100ms5", 100, NULL, 1, NULL);
             xTaskCreate(vEv_100ms6,"Test_100ms6", 100, NULL, 1, NULL);
             xTaskCreate(vEv_500ms1,"Test_500ms1", 100, NULL, 1, NULL);
             xTaskCreate(vEv_500ms2,"Test_500ms2", 100, NULL, 1, NULL);
             xTaskCreate(vEv_500ms3,"Test_500ms3", 100, NULL, 1, NULL);
             xTaskCreate(vEv_500ms4,"Test_500ms4", 100, NULL, 1, NULL);
             xTaskCreate(vEv_1000ms1,"Test_1000ms1", 100, NULL, 1, NULL);
             xTaskCreate(vEv_1000ms2,"Test_1000ms2", 100, NULL, 1, NULL);
    }else if (abc == 1)
    {
     /* Task lost its periodicity*/
             if (xTaskCreate(vEv_20ms1,"Test_20ms1", 4000, NULL, 23, NULL) != pdTRUE)   {
                while(1);
             };
             if (xTaskCreate(vEv_50ms1,"Test_50ms1", 200, NULL, 27, NULL) != pdTRUE)    {
                while(1);
             };
             if (xTaskCreate(vEv_50ms2,"Test_50ms2", 500, NULL, 25, NULL) != pdTRUE)    {
                while(1);
             };
             if (xTaskCreate(vEv_100ms1,"Test_100ms1", 1000, NULL, 21, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms2,"Test_100ms2", 1000, NULL, 18, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms3,"Test_100ms3", 200, NULL, 17, NULL) != pdTRUE)   {
                while(1);
             };
             if (xTaskCreate(vEv_100ms4,"Test_100ms4", 4000, NULL, 16, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms5,"Test_100ms5", 500, NULL, 15, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms6,"Test_100ms6", 1000, NULL, 14, NULL) != pdTRUE) {
                while(1);
             };
             if (xTaskCreate(vEv_500ms1,"Test_500ms1", 500, NULL, 12, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_500ms2,"Test_500ms2", 400, NULL, 10, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_500ms3,"Test_500ms3", 400, NULL, 8, NULL) != pdTRUE)   {
                while(1);
             };
             if (xTaskCreate(vEv_500ms4,"Test_500ms4", 1000, NULL, 6, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_1000ms1,"Test_1000ms1", 1000, NULL, 4, NULL) != pdTRUE) {
                while(1);
             };
             if (xTaskCreate(vEv_1000ms2,"Test_1000ms2", 500,  NULL, 2, NULL) != pdTRUE) {
                while(1);
             };
    }else
    {
             /* Task lost its periodicity*/
             if (xTaskCreate(vEv_20ms1,"Test_20ms1", 4000, NULL, 23, NULL) != pdTRUE)   {
                while(1);
             };
             if (xTaskCreate(vEv_50ms1,"Test_50ms1", 200, NULL, 28, NULL) != pdTRUE)   {
                while(1);
             };
             if (xTaskCreate(vEv_50ms2,"Test_50ms2", 500, NULL, 25, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms1,"Test_100ms1", 1000, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms2,"Test_100ms2", 1000, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms3,"Test_100ms3", 200, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms4,"Test_100ms4", 4000, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms5,"Test_100ms5", 500, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_100ms6,"Test_100ms6", 1000, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_500ms1,"Test_500ms1", 500, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_500ms2,"Test_500ms2", 400, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_500ms3,"Test_500ms3", 400, NULL, 1, NULL) != pdTRUE)  {
                while(1);
             };
             if (xTaskCreate(vEv_500ms4,"Test_500ms4", 1000, NULL, 1, NULL) != pdTRUE) {
                while(1);
             };
             if (xTaskCreate(vEv_1000ms1,"Test_1000ms1", 1000, NULL, 1, NULL) != pdTRUE) {
                while(1);
             };
             if (xTaskCreate(vEv_1000ms2,"Test_1000ms2", 500,  NULL, 1, NULL) != pdTRUE) {
                while(1);
             };
    }
    
    
        /* Start Scheduler */
        vTaskStartScheduler();
    
        /* Run forever */
        while(1);
    /* USER CODE END */
    
        return 0;
    }
    
    
    /* USER CODE BEGIN (4) */
    
    
    /* USER CODE END */