Search code examples
csignal-processingti-dspcode-composerreal-time-data

Code Composer and Real Time Data Exchange: problems in Target to Host communication


dear fellow programmers!

I'd really appreciate a few answers or hints concerning following problem:

The topic is Digital Signal Processing (DSP), Code Composer Studio 3.1 and Real Time Data Exchange (RTDX), as explained in this paper. I've had a hard time understanding the topic, since I'm a DSP and C - Noob. After I read some papers and worked through Code Composer Help-Tutorials, I finally had some success (Yay, SOMETHING happens!), though I'm still running in some errors I don't understand while implementing a simple Target-to-Host Data Exchange.

The Code thats running on the target (TMS320C6713 DSK), obliged to send 100 integers, one after the other:

RTDX_CreateOutputChannel( ochan );
void main()
{

    int data = 0;
    int status;

    TARGET_INITIALIZE();
    RTDX_enableOutput( &ochan );

    puts( "Start writing!\n" );

    while(data < 100){

        data++;

        /* send an integer to the host                              */
        status = RTDX_write( &ochan, &data, sizeof(data) );

        if ( status == 0 ) {
            puts( "ERROR: RTDX_write failed!\n" );
            exit( -1 );
        }
    }
    while ( RTDX_writing != NULL ) {
            #if RTDX_POLLING_IMPLEMENTATION
            RTDX_Poll();
            #endif
    }

    /* disable the output channel                               */

    RTDX_disableOutput( &ochan );

    puts( "Program Complete!\n" );

}

On the Host I run a simple Java/Jacob Implementation as OLE Automation Client that writes the received integers to the Console.

So far, so good, the program works, BUT -> only till integer about 86, then the RTDX_write fails.

As stated in the paper I referred to, "The target application calls routines in the User Library Interface that buffer the data and pass it to the Communications Interface." So maybe it's a buffer problem? Nonetheless I didn't find any possibilities to handle the buffer...

Or maybe it's just a nooby-programming-mistake, as I said I'm not experienced with C.

So any hints are appreciated. Maybe someone has experience with RTDX and had the problem before or maybe someone can tell me how I can find out more about that error. Also I see that the topic is a quite specific one, so if more information is needed I can give...

Thank you very much in advance!

Andy


Solution

  • I think you are overwhelming the channel with data faster than it can handle. Note that in the example they have wrapped the write in a while loop:

    while ( /* limit TOY EXAMPLE data rate */
        !RTDX_Data_Write( &ochan, data, sizeof(data) ) /* send data */
    );
    

    The commentary says:

    This toy example generates data at an extremely high rate limited only by CPU speed. In the example, we are using the return value of RTDX_Data_Write to determine if the data was successfully logged. The surrounding while loop does a busy wait until the data can be accepted

    The idea is that when RTDX_Data_Write returns 0 it means the client was busy, so you just try again until it is ready to accept data.

    In a real embedded application, your main loop probably won't run at an unlimited speed, but at some fixed frame rate. So you can design your data packet with a size that the channel can handle. This TI forum post suggests that the maximum data rate is around 20Kbytes/sec.