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: Arm-based microcontrollers forum

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN, LAUNCHXL2-570LC43

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_

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

    The printf() is being called from inside a FreeRTOS task, so don't think adjusting the Stacksize in the HALCoGen GUI will make a difference.

    Think it is 3rd argument of the xTaskCreate function which needs to be increased to give the task which calls printf() a larger stack size:

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

  • Hi UA,

    Please use Chester's method to increase the stack size for your task1.

  • I changed the stack size of that task. It didn't resolve the issue. 
    Just to make things simpler, I created a project nothing but printf(). I gave enough stack size. The code still hangs.

    
    #include "HL_sys_common.h"
    #include <stdio.h>
    
    int main(void)
    {
        sciInit();
        printf("hello world\n\r");
    
        return 0;
    }
    

  • Just to make things simpler, I created a project nothing but printf().

    Which compiler are you using for the project?

    The compiler version in use is shown in the CCS project properties under Compiler Selection

  • I am using TI v20.2.6.LTS

  • Thank you QJ Wang and Chester Gillon for your reply. I appreciate your help.
    I am still stuck. I can print data using sciSend and sciByteSend without any issue. So my sci is working. 
    Any suggestions on this matter?

    Thank you.

  • I am using TI v20.2.6.LTS

    I had the https://github.com/Chester-Gillon/E2E_example_projects/tree/master/TMS570LC4357_div_by_zero example which runs on a LAUNCHXL2-570LC43.

    Just updated the project to TI v20.2.6.LTS compiler, and when ran it the printf() output appeared on the CCS Console:

    Can't remember having to do anything specific when created the project to make printf() work.

    Can you try that project and see if the printf() works for you?

  • I have tried for long time, but I am not sable to se the data abort:

    int main(void)
    {
         /* USER CODE BEGIN (3) */
         sciInit();
         printf("hello world\n\r");

         while(1){
                 printf("hello world 123\n\r");
         }

    }

    Would you please tell me more about your project? 

    Does your printf() function print char to CCS console or to a UART terminal? 

  • In my test, printf() outputs string to ccs console only.

  • I tried the example. It builds without any issue but can't see anything on the console.

    To test my SCI I tried the following code which works fine. I can see output in my serial terminal.

    int main(void)
    {
    /* USER CODE BEGIN (3) */
        sciInit();
        sciSend(sciREG1, 15, (unsigned char *)"Hello World! \r\n");
    /* USER CODE END */
    
        return 0;
    }
    


    Thank you very much for your patience Chester Gillon.

  • I didn't try anything fancy. I just enabled SCI1 drivers from HALCoGen and created the hello world source code.
    I want to mention that, after programming the MCU Board, the following error messages were displayed in the console. 
    I am using XDS100v2 USB Debug Probe.

    CortexR5: GEL Output: 	Memory Map Setup for Flash @ Address 0x0CortexR5: GEL Output: 	Memory Map Setup for Flash @ Address 0x0 due to System Reset
    CortexR5: GEL Output: 	Memory Map Setup for Flash @ Address 0x0 due to System Reset
    Dap: Error: (Error -242 @ 0x0) A router subpath could not be accessed. The board configuration file is probably incorrect. (Emulation package 9.7.0.00213) 
    CortexR5: Error: (Error -2063 @ 0x0) Unable to reset device. Power-cycle the board. If error persists, confirm configuration and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 9.7.0.00213) 
    CortexR5: Error: (Error -1170 @ 0x0) Unable to access the DAP. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 9.7.0.00213) 
    CortexR5: Unable to determine target status after 20 attempts
    CortexR5: Failed to remove the debug state from the target before disconnecting.  There may still be breakpoint op-codes embedded in program memory.  It is recommended that you reset the emulator before you connect and reload your program before you continue debugging
    



    Thank you for your patience QJ Wang. 

  • It builds without any issue but can't see anything on the console.

    When the string you pass printf does not include a newline (usually written \n), then no output is seen.  Here is your code:

    		printf("Hello World_2");
    

    The fix is to add a newline to the end of the string:

    		printf("Hello World_2\n");
  • after programming the MCU Board, the following error messages were displayed in the console. 

    The problem might be caused by the code you have programmed. The code in the flash makes the CPU enter an exception state repeatedly, and the CPU is not able to enter a debug state.

    Please try this procedure to let CPU enter a debug state:

    1. Open the target configuration window, and launch the selected the configuration
    2. Switch to debug window.
    3. Press the reset (nRST) button and hold it.
    4. Click “Connect Target” immediately after you release the nRST button.
    5. The board should be connected after couple tries.
  • It solved my problem. 

  • Thank you QJ Wang and Chester Gillon for your time and patience. Kudos to you.