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.

TMS320C6657: ti.sysbios.hal.Hwi: line 202: E_stackOverflow: ISR stack overflow error using UART

Part Number: TMS320C6657

Hello there,

I met Hwi stackOverflow in UART_read function. When I watch by ROV, stackpeak is under 1000 in program running but somtimes suddenly occur stackoverflow

Here attach .cfg file, and uart initialize code

I use TMS320C6657 board and PDK_c665x_2_0_16, bios_6_76_03_01

I've already try changing 'Hwi.checkStackFlag = false'
and also my setting of System (Hwi and Swi) stack size is 8192. I think it is enough size to deal with because received data size is 256 bytes.

Could you help me firgure out this problem?

Best regards,

Nam

Sadan.cfg

void UartTask::UART_Init()
{

    Board_initCfg boardCfg;
//    boardCfg = BOARD_INIT_PINMUX_CONFIG |
//               BOARD_INIT_MODULE_CLOCK  |
//               BOARD_INIT_UART_STDIO;
    boardCfg = BOARD_INIT_PINMUX_CONFIG |
    BOARD_INIT_MODULE_CLOCK;
    Board_init(boardCfg);
    UART_HwAttrs attr;
    UART_Params uparam = GetDefaultParams();
    UART_socGetInitCfg(0, &attr);
    UART_socSetInitCfg(0, &attr);
    UART_init();
    handle = UART_open(0, &uparam);
    if(handle != NULL)
    {
        printf("UART Open\n");
    }
}

UART_Params GetDefaultParams()
{
    UART_Params param;
    UART_Params_init(&param);
    param.baudRate = 115200;
    param.readDataMode = UART_DATA_BINARY;
    param.writeDataMode = UART_DATA_BINARY;
    param.parityType = UART_PAR_NONE;
    param.dataLength = UART_LEN_8;
    param.stopBits = UART_STOP_ONE;

    return param;
}

  • Hi,

    We have UART test examples inside PDK_c665x_2_0_16 and tested, we didn't see any problem. Have you verified that? What is the difference in your UART test vs TI provided test? You don't use DMA, correct? What if you make the stack even bigger?

    Regards, Eric

  • Hi Eric,

    Thanks to reply.

    I don't use DMA, correctly. And I made the stack size is 8,192 to 131,072 but in similar time, same problem occurs.

    The difference in my UART test vs TI provided test is "ModuleTaskBase" class.

    I attach ModuleTaskBase.hpp

    #ifndef MODULETASKBASE_HPP_
    #define MODULETASKBASE_HPP_
    #include <libcxx/map>
    #include <libcxx/cstring>
    #include <ti/sysbios/knl/Task.h>
    #include <stdio.h>
    template<class T>
    class ModuleTaskBase
    {
    public:
        ModuleTaskBase() {};
        ~ModuleTaskBase() {};
    
        int Main(char* arg)
        {
            if(strcmp(arg, "start") == 0)
            {
                default_param;
                Task_Params_init(&default_param);
                default_param.arg0 = (xdc_UArg)this;
                Handle = Task_create(ModuleTaskBase::Task_Pointer, &default_param, NULL);
                if(Handle != NULL)
                {
                    printf("Task Create...\n");
                }
            }
            else if(strcmp(arg, "stop") == 0)
            {
                OnStop();
                Task_delete(&Handle);
            }
    
            return 0;
        };
    
        static void Task_Pointer(UArg arg0, UArg arg1)
        {
            ModuleTaskBase<T>* module = (ModuleTaskBase<T>*)arg0;
            module->OnInit();
            module->OnStart();
        }
    
    protected:
        virtual void OnInit(){};
        virtual void OnStart(){};
        virtual void OnStop(){};
        Task_Params Param;
        Task_Handle Handle;
    private:
        Task_Params default_param;
    };
    
    #endif /* MODULETASKBASE_HPP_ */
    

    There is UartTask class which is inherited ModuleTaskBase class.

    In OnInit function which is UartTask's member function, config Board and open UART. And Onstart function have infinity loop and call UART_Read function in there.

    main function is

    {

    UartTask ut;

    ut.Main("start");

    BIOS_start();

    }

    Maybe should I avoid using ModuleTaskBase?

    Best Regards,

    Nam

  • Hi,

    Thanks for the info! The original code is written in C, you modified with C++ and create a ModuleTaskBase class. Do you see similar stack issues in other test applications? I would suggest to use the original C code. You can call C code from C++ with extern C.

    Regards, Eric

  • Hi,

    I have done that use example C code provided by Ti as suggested, and no longer error.

    Perhaps I need to fix the ModuleBaseTask code.

    Thanks for advice!

    Best Regards,

    Nam