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: need help with Software Timer in tms570

Part Number: TMS570LS0432

hello

i

#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();

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



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 

  • 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 

  • 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