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.

UART_read return UART_ERROR when another task perform uSD operations

Other Parts Discussed in Thread: SYSBIOS

Hello to everyone.

I'm using Concerto-M3 with TI-RTOS 1.21.00.09

(sysbios is 6.37.00.20)

and I write two tasks:

- "communication" priority 1, task is vital, stack 2048

- "logging" priority 1, task is vital, stack 2048.

"communication" open UART and in infinite loop perform RX - decode - TX.

"logging" wait for an event and then open SDSPI and then create a file to write some data.

If "logging" is waiting for the event "communication" work perfectly,

when the "logging" event is trigged and the task start to do its operations

"communication" fail to read (it return UART_ERROR) so I have to

close driver and re-open in order to restart communication.

Can someone help me ?

Thank you in advice

  • Hi Mauro,

    I'll need more information to help you solve this:

    What mode(blocking or callback) did you configure the UART driver to use?

    Also it'll help me if I could see what you're doing in your code: i.e how you configure the UART, logging and so on.

    Thanks,

    Moses

  • Void comunicationFxn(UArg arg0, UArg arg1)
    {
    CommRestart:{}
    
        UART_Handle uart;
        UART_Params uartParams;
    
        //create UART
        UART_Params_init(&uartParams);
        uartParams.writeDataMode  = UART_DATA_BINARY;
        uartParams.readDataMode   = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho       = UART_ECHO_OFF;
        uartParams.readTimeout    = 10;//ms ?
        uartParams.baudRate       = 57600;
        uart = UART_open(0, &uartParams);
    
        while(TRUE)
        {
        	//receive
        	Int pck_len=UART_read(uart, (Char*)req_buf, sizeof(req_buf));
    
        	//if error RESTART
        	if(pck_len==UART_ERROR)
        	{
        		diagnosticPrintfBuffer("RX ERROR", NULL);
        		UART_close(uart);
        		goto CommRestart;//non esiste qualcosa del tipo "Task_rewind" o "Task_restart" ?
        	}
    
        	//create buffers
        	BUFFER request = {req_buf,sizeof(req_buf),pck_len,0};
    	    BUFFER answer = {answ_buf,sizeof(answ_buf),0,0};
    
    	    //diagnostic
    	    diagnosticPrintfBuffer("RX", IN &request);
    
        	//decode
        	modbus_decode(0x13, IN &request, OUT &answer);
    
        	//diagnostic
        	diagnosticPrintfBuffer("RX", IN &answer);
    
        	//answer
    		Int w_len=UART_write(uart, (Char*)answer.buffer, answer.w_ptr);
    
        	//if error RESTART
        	if(w_len==UART_ERROR)
        	{
        		diagnosticPrintfBuffer("TX ERROR", NULL);
        		UART_close(uart);
        		goto CommRestart;//non esiste qualcosa del tipo "Task_rewind" o "Task_restart" ?
        	}
        }
    }

  • Sorry for the delay. 

    Are you still having issues with this?

    Moses

  • Hi Moses. I have same problem with UART (UART_read return UART_ERROR, SPI work in another Task). Can you help me?

  • Hi CNO CNO,
    I recommend you make a fresh post for your issue with more details of your application. Also it will be helpful to include the versions TI-RTOS, CCS and what device you're using.

    Thanks,
    Moses