Quantcast
Channel: Infineon Forums
Viewing all articles
Browse latest Browse all 9892

UART - streaming data

$
0
0
Hi All,

I have been trying to stream data from the xmc1300 boot kit using DAVE4 to the PC. The micro controller is streaming data, but often it seems to mess up what it is streaming. I tried something I though should be very basic and simply working

my main while loop
Code:

  while(1U)
  {
            //Check if transmit buffer is idle
            if(UART_GetFlagStatus(&UART_0, XMC_UART_CH_STATUS_FLAG_TRANSMISSION_IDLE))
            {
              //Check if receive request is successful

              if(UART_Receive(&UART_0, rec_data, 10) == UART_STATUS_SUCCESS)
              {
                //Wait for reception of 10 bytes
                while(UART_0.runtime->tx_busy)
                {
                }
                //Transmit the received data.
                        if (rec_data[0] == '1') {
                                UART_Transmit(&UART_0, rec_data, sizeof(rec_data));
                        }
              }
            }
  }

and an end of transmit interrupt
Code:

//Callback functin for "End of transmit" event.
void EndofTransmit()
{
        uint8_t Data[4] = {};
        uint8_t message[6] = {};

    Data[0] = result / 1000        +48;
    Data[1] = (result % 1000) / 100 +48;
    Data[2] = (result % 100)  / 10  +48;
    Data[3] = (result % 10)  / 1  +48;

    message[0]  = Data[0];
    message[1]  = Data[1];
    message[2]  = Data[2];
    message[3]  = Data[3];
    message[4]  = (int)13; // CR
    message[5]  = (int)10; // NL

        if(result>1){
                UART_Transmit(&UART_0, message, sizeof(message));
                result--;
        } else {
                UART_Transmit(&UART_0, message, sizeof(message));
            result = 4095;
        }

}

The idea is for the code to count down from 4095 and stream each result to a PC. This happens, but the results I get when examining the stream is that sometime it sends the wrong number of bytes, this I checked with Hterm.

Is there anyone that has gotten streaming to work with an XMC controller to the PC without using xpsy? Is there any example project that someone is willing to share? I just want to stream the ADC data to the PC, see it on the scope and save the scope data.

Regards
Ludwig

Viewing all articles
Browse latest Browse all 9892

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>