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.

Using UART0 and UART1 for DM6437

Other Parts Discussed in Thread: CODECOMPOSER

 

Hi,

I'm trying to use UART0 and UART1 for my application using DM6437.

1st I tried using it just as the example included in DVSDK files (uart_bios_dm6437_drv_lib.pjt) , and it works just fine.  I followed it as a reference including it in my own project and it does not work, it all works ok up to the point to where I use "GPIO_write( )" to send characters to UART0.. and right afterwards a verification of this operation is done:

    memcpy(TestStringStart,"UART Demo Starts  \r\nEnter 32 characters for read write test  :\r\n",SIZEOF_UART_STRING_START);
    memcpy(TestStringStop,"\r\nUART Demo End                  ",SIZEOF_UART_STRING_STOP);

    /*
     * Input buffer
     */
    buf.addr = TestStringStart;
    /*
     * Time out value
     */
    buf.timeout = SYS_FOREVER;
    /*
     * Length of data
     */
    len = SIZEOF_UART_STRING_START;
    status = GIO_write(hUart_OUT, &buf, &len);

    /*
     * Error status detection
     */
    if(!((status == IOM_COMPLETED)||(status == IOM_PENDING))){
        LOG_printf(&trace, "\r\nError: 0: Error from GIO_write for UART Tests Start string\n");
    }

In my project, the status is neither COMPLETED or PENDING.. I don't know why.
I included all necessary libraries as indicated in the example (  edma3 libs and Uart lib), initialized UART0 with the init function using DSPBIOS, created the UART0 user defined device within DSPBIOS, configured the UART through the devparams in interrupt mode, and left everything according to example..
In my proyect  code runs exactly as example up to the point where the 1st GIO_write is executed.... then the status returned is an error,.. and the characters I see in the serial port console ( in my pc) are incomplete.

What could be wrong ??  I even tried including the whole sample code in my proyect and running it exactly as the example, still,  the same problem. In the example I see the "interrupt" mode is configured.. however I don't see within the example's DSPBIOS configuration any hardware interrupt or event within ECM, configured to be used with the UART0.. so, how is it that works ? ( in the example I mean),  shouldn't a hardware interrupt be configured somewhere as well  ?

What i want in final terms... (after solving this problem ) is to use UART0 and UART1 in EDMA mode, so I don't have to create an ISR to be attended each time I receive or send 'n' characters,   I would like to use the DMA so it interrupts my program flow each 'n' bytes( let's say 256, a personal serial protocol frame size for a command)  and then process the frame, leaving hard work to DMA.

How can I implement this, or what literature should I consult to know how to use the UART0 in DMA mode ?  ( All necessary steps, including DSPBIOS special configurations, DMA channels and how to create them, connect them, configure them, etc etc).

Thank you very much I've been into this for days with no considerable progress!!!

 

 

  • I finally got UART to work.

    I got UART to work in interrupt mode, I was forgetting for a moment that UART driver has to run within a TASK ( as it has a semaphore included in the driver). I assume that it's true since it worked when I did that change. Also, I had to use the  uart_bios_drv.lib  driver from the dvsk DEBUG folder, because the RELEASE folder didn't seem to work properly eventhough I rebuilt the library project.

    I implemented the UART in the following way:

    -  I have a task that writes a buffer to UART using GIO_write
    - I have another task that reads a buffer from UART using GIO_read
    - both tasks have the same priority

    Defining a tx buffer of 256 bytes, When writing a long message to UART ( say all 256 bytes) write task status becomes blocked as it completes the message in several executions.. (small parts of the message are sent and task is executed several times, I know this because I see terminal window filling up with my message characters in several task executions, while doing this the task status remains in blocked),    it is finally unblocked when the 256 bytes are sent , using GPIO_write to an UART object.

    Here's the code for my TX task:

    void ALV_UartTx(void)
    {
      // execute forever
      for ( ; ;)
     {
         if (TxStr[0] != NULL)        // verify if there is something to send
           {
             // Input buffer
                txbuf.addr = TxStr;
             // Time out value
              txbuf.timeout = SYS_FOREVER;
             // Length of data
             txlen = SIZEOF_UART_STRING_TX;
              txstatus = GIO_write(hUart_OUT, &txbuf, &txlen);

              // Error status detection
             if(!((txstatus == IOM_COMPLETED)||(txstatus == IOM_PENDING)))
                          {
                           printf("UART ERROR: 0: Error from GIO_write for UART TxStr\n");
                            }
                // there was no error, data was sent so mark tx buffer as clean
                 else
                 {
                     TxStr[0] = NULL;
                  }
        }
       // if there is nothing to send, just pass control to another task
       else
       {
        TSK_yield();
        }
    }

    Is this the normal behavior?  I know the UART driver uses a built-in semaphore which is involved into this.  But as soon as the code flow reaches the "GPIO_write" is the task supposed to be blocked until GPIO_write is done writing all bytes to UART ?

    shouldn't the task just pass the buffer to a lower level layer (which would be the one responsible to put all bytes to UART) and continue executing instead of blocking itself until all bytes are sent ?

    am I implementing UART driver the right way ?

    DSPBIOS ver: 5.31.09
    CodeComposer Ver: 7.0.3
    DSP:  DM6437
    for follow up: http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/99/p/82924/313797.aspx#313797

     

  • Hi Rafael,

    Since GIO_write() is a synchronous call, its behaviour is to block until it finishes its job, which is why the thread blocks until it completes the current IO.

    To have the asynchronous call, it is better to have the GIO_submit() call with proper time out parameter mentioned in "buf.timeout". The time out parameter provided with the buffer is being used by the driver to wait for the IO to complete for a given amount of time.

    With the use of GIO_submit(), it is also posssible to have a call back mechanism when the current IO completes.

    Please refer the BIOS user guide for the syntax of GIO_submit() and its usage.

    One more option to specify the time out is while opening the driver with GIO_create().

    The time out value for GIO layer can be provided as a GIO_Attrs.

    Eg: GIO_Attrs gioAttrs

          gioAttrs.timeout = <timeout value>; \\ Default value would be SYS_FOREVER

          hUart_OUT = GIO_Create("/UART0", IOM_OUTPUT, NULL, &chanParams, &gioAttrs);

    You can adopt any one of the above mechanism, as your requirement.

    Thanks and Regards,

    Sandeep K

  • I'm a bit confused. What is necessary to use GIO_write in my program? Where can I find the necessary libs and header files? What must be installed for DM6437? I tried ddk_1_20 but it doesn't seem to contain useful stuff for this.