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.

TMS570LS0432: problem with Software Timer functions (xTimerCreate(), xTimerReset() etc.)

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

hello

i need help in Software Timer .

I am trying to use Software Timer with tms570ls0432 but I have a problem with Software Timer functions (xTimerCreate()xTimerReset(),xTimerStop() etc.):

after calling xTimerCreate inside main func.  causes the program stop runing there (xTimerCreate )and does not move to next line(xTimerStart) even thogh i have opened os timer in halcogen 

#include "sys_common.h"
#include "system.h"

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>


#include "FreeRTOS.h"
#include "os_task.h"
#include "os_timer.h"
#include "het.h"
#include "gio.h"

/* Define Task Handles */
xTaskHandle xTask1Handle,
            xTask2Handle;

xTimerHandle xTimer1;
uint32 i = 0;


void vTimerFunction(xTimerHandle xTimer1)
{
    // toggle port bits
    gioToggleBit(hetPORT1, i);
    i++;
    if (i>31)
        i=0;
    // restart timer
    xTimerReset(xTimer1, 0);
    xTimerStop( xTimer1 ,0 );
}


void main(void)
{
/* USER CODE BEGIN (3) */
    gioInit();
    gioSetDirection(gioPORTA, 0xFFFFFFFF);
    gioSetDirection(hetPORT1, 0xFFFFFFFF);
    gioSetBit(gioPORTA, 2U,  1);


    xTimer1 = xTimerCreate("Timer1", 500, pdTRUE, (void*) 0, vTimerFunction);
    xTimerStart( xTimer1, 0 );

    /* Start Scheduler */
    vTaskStartScheduler();

    while(1);
}



  • is there any one can help me to solve this problem

  • Hello,

    To use FreeRTOS timers, you have to turn them on with the following entry in FreeRTOSConfig.h:

    #define configUSE_TIMERS 1

    This macro is set to 0 by default. When enabled, the application is using more resources than necessary. Because it creates the ‘Tmr Svc’ task during vTaskStartScheduler().

    The timer task is responsible to handle all FreeRTOS software timers in the system. Basically it checks if a timer has been expired and calls the associated timer hook. The timer task name, priority and stack size can be configured with the following macros in FreeRTOSConfig.h

    I recommend to give the timer task the highest task priority in the system, otherwise you will see some latency in the timer hook execution. The timer stack size really depends on what you are doing in the timer hooks called from the timer task.

    Because a timer creation can fail, it is good practice to check the returned timer handle. For example, 

    if (xTimer1==NULL) {
       for(;;); /* failure! */
    }

    and

    if (xTimerStart(xTimer1, 0)!=pdPASS) {

      for(;;); /* failure! */

    }
    The timer may not start properly if the timer queue is not larger enough.
     
    Please see mare information at 

     

  • thank you very much for replying I wıll check those things 

  • ı chandef thıngs you have indicate in  FreeRTOSConfig.h to be lıke bellow

    /* Timers */
    #define configUSE_TIMERS 1
    #define configTIMER_TASK_PRIORITY ( 0 )
    #define configTIMER_QUEUE_LENGTH 10
    #define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )

    then I modify my code to be lıke this

    #include "sys_common.h"
    #include "system.h"
    
    #include <stdio.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    #include <math.h>
    #include <stdlib.h>
    
    #include "FreeRTOS.h"
    #include "os_task.h"
    #include "os_timer.h"
    #include "include/os_mpu_wrappers.h"
    
    #include "het.h"
    #include "gio.h"
    
    xTaskHandle xTask1Handle,
                xTask2Handle;
    
    
    bool tick = true;
    
    xTimerHandle xtimer;
    
    
    void mytimer(xTimerHandle xtimer)
    {
    
        tick=!tick;
    }
    void vTask1(void *pvParameters)
    {
        for(;;)
        {
            gioSetBit(gioPORTA, 2U,  1);
            vTaskDelay(100);
            gioSetBit(gioPORTA, 2U,  0);
            vTaskDelay(100);
        }
    }
    
    void vTask2(void *pvParameters)
    {
        for(;;)
        {
            gioSetBit(hetPORT1, 8, gioGetBit(hetPORT1, 8) ^ 1);
            vTaskDelay(100);
        }
    }
    
    
    
    void main(void)
    {
        gioInit();
        gioSetDirection(gioPORTA, 0xFFFFFFFF);
        gioSetDirection(hetPORT1, 0xFFFFFFFF);
        gioSetBit(gioPORTA, 2U,  1);
    
        if (xTaskCreate(vTask1,"Task1", configMINIMAL_STACK_SIZE, NULL, 1, &xTask1Handle) != pdTRUE)
        {
            while(1);
        }
    
        if (xTaskCreate(vTask2,"Task2", configMINIMAL_STACK_SIZE, NULL, 1, &xTask2Handle) != pdTRUE)
        {
            while(1);
        }
    
    
        xtimer = xTimerCreate("xtimer", 500 , pdTRUE , (void *) 0 , mytimer);
        if (xtimer==NULL) {
           for(;;);
        }
    
    
        if (xTimerStart(xtimer, 0)!=pdPASS) {
    
          for(;;);
    
        }
        vTaskStartScheduler();
    
        while(1);
    }
    
    

    and I used breakpoint to follow my program .

    when it move from timer create line to next line (in the next line there is a breakpoint ) program just stop before passing to next line 

  • I wish these images could show you what is going on 

  • I used same way to create timer, and did not see any issue.