TMS570LC4357 FreeRTOS on Launchpad

In this example, will see how to use Free RTOS on TMS570LC43570 Launchpad and toggle the in-build user LEDs(GIOB-6 and GIOB7).

  • What is HCG? Hardware Abstraction Layer Code Generator

HALCoGen

Configure the microcontroller in HALCoGen

  • Open the HALCoGen and Create a new project: File -> New -> Project

Select Device TMS570LC4357ZWT or RM57L843ZWT

  • Select the family, my case “TMS570LC43x”
  • Select Device “TMS570LC4357ZWT_FREERTOS”
  • Provide the name of the project, if already not created the CCS project name. When naming the project, take care to use the same name later in CCS, and check that the location is your CCS working directory.
  • Select location of the project you wanna store the BSP (My case D:\ArunEworld_CCS)
  • Check in “Create directory for project” if you wanna create a directory
  • Once click OK button, then pop up will come like “Project Directory does not exist, Create directory: D:ArunEworld_CCS\TMS570LC4357_FREERTOS_LANCHPAD\” for click okay if you does not have directory already. This will create the directory name of “TMS570LC4357

Configure driver code generation:

  • In Driver Enable tab: Enable GIO driver, Disable others.
  • In PINMUX tab, Select Pin Muxing tab: Enable the GIOB.
  • In Same PINMUX tab, Select Input Pin Muxing tab: Enable the GIOB.

Others

Interrupt handling Configuration

  • In Interrupt tab, Enable SVC and Enter FreeRTOS SVC handler name ‘vPortSWI’

Configure VIM RAM

  • Enter FreeRTOS Timer Tick handler name ‘vPortPreemptiveTick’ at offset 0x0000000C
  • Enter SSI handler name ‘vPortYeildWithinAPI ‘ at offset 0x00000058

Vectored Interrupt Module Channels Configuration:

  • Enable VIM Channel 2
  • Map VIM Channel 2 to IRQ
  • Enable VIM Channel 21
  • Map VIM Channel 21 to IRQ

Configure OS timer tick to 1 ms:

  • Enter Tick Rate of 1000

Generate code

  • Navigate: -> File -> Generate Code

Code

  • Replace this below code in HL_sys_main.c
  • Note: please make sure that you link in the right main function or copy the source into the user code sections of this file.
/* 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"

/* Define Task Handles */
xTaskHandle xTask1Handle;

/* Task1 */
void vTask1(void *pvParameters)
{
    for(;;)
    {
        /* Taggle GPIO-7 LED bin tick */
        gioSetBit(gioPORTB, 7, gioGetBit(gioPORTB, 1) ^ 1);
        vTaskDelay(100);
    }   
}
/* 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) */
    /* Init the GIO*/
    gioInit();    

    /* Set  pin direction to all output */
    gioSetDirection(gioPORTB, 0xFFFFFFFF);


    /* Create Task 1 */
    if (xTaskCreate(vTask1,"Task1", configMINIMAL_STACK_SIZE, NULL, 1, &xTask1Handle) != pdTRUE)
    {
        /* Task could not be created */
        while(1);
    }

    /* Start Scheduler */
    vTaskStartScheduler();

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


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

Please turn AdBlock off, and continue learning

Notice for AdBlock users

Please turn AdBlock off
Index

Discover more from ArunEworld

Subscribe now to keep reading and get access to the full archive.

Continue reading