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.

F28M35M52C: How to read more than 8 bytes from UART?

Part Number: F28M35M52C
Other Parts Discussed in Thread: CONTROLSUITE

I am trying to read strings of variable length into an array for processing.

The FIFO in the F28M35 is 16x8 but I can not read more than 8 bytes into the array. See attached modified example code (from ControlSuite) I have been playing around with below.

If I send 8 or less bytes the UART functions work fine. However, when sending more than 8 or, even more than 16, I can get to the end of the string but the array is overwritten. I only get the last 8 bytes.

I have inserted an interrupt counter which showed I get an interrupt every 8 bytes worth of data. So it seems the "UARTCharsAvail" function jumps out of the loop at 8 bytes even when more than 8 bytes is sent to the UART.

How do I make the UART read continuously (more than 8 bytes at a time), realize the data string is finished (store the array), and then wait for the next set ?

//*****************************************************************************

// The UART interrupt handler.

//*****************************************************************************

void

UARTIntHandler(void)

{

unsigned long ulStatus;

// IntDisable(INT_UART0);

f=0;

// Loop while there are characters in the receive FIFO.

while(UARTCharsAvail(UART0_BASE))

{

// Read the next character from the UART and write it back to the UART.

// 2018-01-17 Function changed to store character in "data1uart0" for examination.

//data1uart1 = UARTCharGetNonBlocking(UART0_BASE);

//for (i=0; i<8; i++)

MB_Rbuf[f] = (unsigned char) UARTCharGetNonBlocking(UART0_BASE);

f++;

}

bufnow=f;

// Get the interrupt status.

ulStatus = UARTIntStatus(UART0_BASE, true);

// Clear the asserted interrupts.

UARTIntClear(UART0_BASE, ulStatus);

 

UARTintCnt++;

// IntEnable(INT_UART0);

}

Thanks,

Mark C.

  • Hi Mark,

    What is the interrupt trigger level set for the Rx FIFO?

    By default the level is 1/2 .Ie. 8 bytes receive trigger.

    Is there a difference in behavior when using blocking mode of getchar?

    What is the status of FIFO when the interrupt is triggered ?

    Regards.

  • Hi Meghana,

    The interrupt trigger level is set to 1/2. So 8 bytes receive trigger.

    There is no difference between UARTCharGetNonBlocking and UARTCharGet.


    However, something interesting happens when I set a breakpoint in the UART interrupt handler routine. I set the breakpoint at the line "f=0;", before the routine does anything. When looking at the "Value" column in the register view, the UARTDR register steps through all the data bytes I sent. Then shows an empty register (00....00). Below is the status of the UART registers when the interrupt occurred.

    When interrupt occurs - before running handler routine;
    - values in (hex)

    UARTDR 00 - was stepping through data at breakpoint
    UARTRSR_TECR 0
    UARTFR 197
    UARTILPR 0
    UARTIBRD 1E8
    UARTFBRD 12
    UARTLCRH 70
    UARTCTL 301
    UARTIFILS 12
    UARTTIM 50
    UARTRIS 0
    UARTMIS 0
    UARTICR 0
    UARTDMACTL 0
    UARTLCTL 0
    UARTLSS 0
    UARTLTIM 0
    UARTPERIPHID4 60
    UARTPERIPHID5 0
    UARTPERIPHID6 0
    UARTPERIPHID7 0
    UARTPERIPHID0 11
    UARTPERIPHID1 0
    UARTPERIPHID2 18
    UARTPERIPHID3 1
    UARTPCELLID0 D
    UARTPCELLID1 F0
    UARTPCELLID2 5
    UARTPCELLID3 B1


    see what you think.
    Sorry for weird formatting from MS notebook.

    Mark
  • hi Mark,

    Based on the below register content : There are no interrupt flags set when the breakpoint is at the line "f=0;"
    UARTTIM 50
    UARTRIS 0
    UARTMIS 0
    Moreover the interrupts are masked as per the configuration .

    Also , UARTCTL 301
    Some of the configurations seem to be unnecessary . Are you using SMART mode or SIRLP mode ?

    Are you using the example below as reference ? It will give you an idea on the configurations needed.
    controlSUITE\device_support\f28m35x\v220\F28M35x_examples_Master\uart_echo\m3

    Regards.
  • Hi Meghana,

    The application is built on top of the uart_echo example. So the config we are looking at is actually from the example.

    I am not using Smart or iR. The config (UARTCTL 301) should be good as it only enables the Uart and Tx / Rx, rest of the modes are off.

    As you pointed out, the interrupt flag is not set after entering the Uart Interupt Handler. This make a lot of sense as the routine seems to only move 8 bytes at time. Once the handler completes, there is another interrupt (which somehow gets cleared), then 8 bytes are moved .. and so on until there is no more data coming in.

    I am looking into where / why the receive interrupt gets cleared.

    Regards,

    Mark

  • Hi Mark ,

    So this UARTCTL 301 was in hex and not decimal ? Then you are correct .

    If you let the interrupt get called once ( status =0 ) then does it reenter again? Is the status still 0 ?

    UARTFR 197 (hex )  -> Seems that the FIFO is empty still so hasn't received any data yet .

    Regards.

  • Hi Mark ,

    Any progress on this?

    Regards.