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.

TM4C123GH6PM: FreeRTOS code not working on the Tiva C Launchpad

Part Number: TM4C123GH6PM
Good day. I decided to run a basic FreeRTOS program on the TM4C123 board. vTask1 is supposed to put the variable 'count' into a queue (myqueue) while vTask2 is supposed to read the data from the queue
and print the result on console using the uartstdio utility function UARTprintf. The code doesn't print anything on the serial terminal and I can't pinpoint the fault as the same code works on an ESP32.

This is the code:

#include <stdbool.h> #include <stdint.h> #include "inc/hw_gpio.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" #include "utils/ustdlib.h" #include "FreeRTOS.h" #include "task.h" #include "queue.h" /* * FreeRTOS Queue Management * */ TaskHandle_t task1Handle = NULL; TaskHandle_t task2Handle = NULL; QueueHandle_t myQueue; uint32_t SystemCoreClock = 16000000; void ConfigureUART(void); void vTask1(void *pvParameters){ int count = 5; myQueue = xQueueCreate(5, sizeof(int)); for (;;){ if(uxQueueMessagesWaiting(myQueue) == 0){ xQueueSend(myQueue, &count, pdMS_TO_TICKS(5)); } } } void vTask2(void *pvParameters){ int receive; for (;;){ if(uxQueueMessagesWaiting(myQueue) != 0){ if(xQueueReceive(myQueue, &receive, pdMS_TO_TICKS(10))){ UARTprintf("data received: %d\n",receive); } } } } int main() { ConfigureUART(); xTaskCreate(vTask1, "Task 1", 1024, NULL, 1, &task1Handle); xTaskCreate(vTask2, "Task 2", 1024, NULL, 1, &task2Handle); // Startup of the FreeRTOS scheduler. The program should block here. vTaskStartScheduler(); for (;;); } void ConfigureUART(void) { /* Configure the UART and its pins. This must be called before UARTprintf(). */ // // Enable the GPIO Peripheral used by the UART. // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Enable UART0 // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); MAP_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UART0); // // Configure GPIO Pins for UART mode. // MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Use the internal 16MHz oscillator as the UART clock source. // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); // // Initialize the UART for console I/O. // UARTStdioConfig(0, 115200, SystemCoreClock); }

  • Hello Olaoluwa,

    I don't see anything for configuring the system clock at the start of the program. That may be the issue here depending how the problem is hanging (it sounds like you are getting a FaultISR?)

    Try adding this as the very first function call in the main routine:

        //
        // Set the clocking to run at 50 MHz from the PLL.
        //
        MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                           SYSCTL_OSC_MAIN);

  • Hi,

      I have no experience with FreeRTOS. As a matter of fact, the FreeRTOS has been removed from the latest TivaWare release as we will not support it. With that said, I will suggest you do several things. 

      - Instead of sending the data via the UART, simply toggle a pin for experiment. Will you see the pin go high and low? If you can't see the pin toggle then there is something wrong with your FreeRTOS code. It is not a UARTprintf problem.

      - If the above pin toggle works, then the issue might be with your COM port setup. Your UARTConfigure() looks ok to me. Write a simple non-RTOS program to send a "Hello World' to your COM port using UARTprintf. Can you see the message displayed on your terminal window?

      - You are setting the UART baud rate to 115200. Is your terminal window also configured for the same baud rate and have the same settings (e.g. stop bits, parity bit)?

      - If you rule out the problem is related to the UARTprintf and the COM port setting and also the pin toggle accordingly in your first experiment then the issue is likely to be with the FreeRTOS itself. You will need to post your question to FreeRTOS forum. Just one note to you. As I search pdMS_TO_TICKS on internet, there seems to be some issue/bug with it. You will need to find out if that is the case. I have not much knowledge about FreeRTOS and as stated in the beginning, we do not support FreeRTOS.