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: Program hangs in printf() function

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

I have a Hercules Safety Development Kit that is running on FreeRTOS v9. I am using Code Composer Studio v11 and HALCoGen v4.
My program hangs in printf(). My SCI is working properly. I included the stdio.h library. The code builds without any issue. As I am new to this platform, I am surely missing something.

A snippet of a test code is given below

#include "FreeRTOS.h"
#include "os_task.h"
#include "HL_sci.h"
#include "HL_het.h"
#include "HL_gio.h"
#include "stdio.h"
#include "HL_sys_common.h"

#define UART sciREG1
#define LENGTH 18

xTaskHandle xTas1kHandle, xTask2Handle;
uint8 TEXT[LENGTH] = {'B', 'u', 't', 't', 'o', 'n', ' ', 'i', 's', ' ', 'p', 'r', 'e', 's', 's', 'e', 'd', ' '};

void consolePrint(sciBASE_t *sci, uint8 *text, uint32 length){
    while(length--){
        while((sci->FLR & 0x4) == 4);
        sciSendByte(sci, *text++);
    }

}

void vTask1(void *pvParameters){
    for(;;){
        gioSetBit(hetPORT1, 0, (gioGetBit(hetPORT1, 0)^1));
        printf("Hello World\n\r"); //code hangs here
        vTaskDelay(100);
    }
}

void vTask2(void *pvParameters){
    for(;;){
        if((gioGetBit(gioPORTA, 7) == 0)){
        consolePrint(UART, &TEXT[0], LENGTH);
        vTaskDelay(100);
        }
    }
}

int main(void)
{
    sciInit();
    gioSetDirection(hetPORT1, 0xFFFFFFFF);
    gioSetDirection(gioPORTA, 0x00000000);

    if (xTaskCreate(vTask2, "Task 2", configMINIMAL_STACK_SIZE, NULL, 1, &xTask2Handle) != pdTRUE){
        while(1);
    }

    if (xTaskCreate(vTask1, "Task 1", configMINIMAL_STACK_SIZE, NULL, 1, &xTas1kHandle) != pdTRUE){
        consolePrint(UART, &TEXT[0], LENGTH);
    }

    vTaskStartScheduler();
    while(1);

    return 0;
}

Can anyone please help me with this issue? Any suggestion is appreciated.

Thank you.

Regards
UA

  • Hi UA,

    The printf() takes bigger stacks, please adjust the Stacksize from HALCoGen GUI:

    HalCoGen->RAM->UserStack

    You can change the stack size manually defined in sys_core.asm:

    _coreInitStackPointer_

  • _coreInitStackPointer_

    Thank you QJ Wang for your reply. But it didn't solve the issue.

    Case1


        .def     _coreInitStackPointer_
        .asmfunc
    
    _coreInitStackPointer_
    
            cps   #17
            ldr   sp,       fiqSp
            cps   #18
            ldr   sp,       irqSp
            cps   #19
            ldr   sp,       svcSp
            cps   #23
            ldr   sp,       abortSp
            cps   #27
            ldr   sp,       undefSp
            cps   #31
            ldr   sp,       userSp
            bx    lr
    
    userSp  .word 0x08000000+0x00000900
    svcSp   .word 0x08000000+0x00000900+0x00000100
    fiqSp   .word 0x08000000+0x00000900+0x00000100+0x00000100
    irqSp   .word 0x08000000+0x00000900+0x00000100+0x00000100+0x00000100
    abortSp .word 0x08000000+0x00000900+0x00000100+0x00000100+0x00000100+0x00000100
    undefSp .word 0x08000000+0x00000900+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100
    
        .endasmfunc


    Case 2

        .def     _coreInitStackPointer_
        .asmfunc
    
    _coreInitStackPointer_
    
            cps   #17
            ldr   sp,       fiqSp
            cps   #18
            ldr   sp,       irqSp
            cps   #19
            ldr   sp,       svcSp
            cps   #23
            ldr   sp,       abortSp
            cps   #27
            ldr   sp,       undefSp
            cps   #31
            ldr   sp,       userSp
            bx    lr
    
    userSp  .word 0x08000000+0x00050000
    svcSp   .word 0x08000000+0x00050000+0x00000100
    fiqSp   .word 0x08000000+0x00050000+0x00000100+0x00000100
    irqSp   .word 0x08000000+0x00050000+0x00000100+0x00000100+0x00000100
    abortSp .word 0x08000000+0x00050000+0x00000100+0x00000100+0x00000100+0x00000100
    undefSp .word 0x08000000+0x00050000+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100
    
        .endasmfunc

    The program hangs in printf() in both cases.

    Thank you.

    Regards
    UA