BF514 UART DMA Transmit using Drivers library

Hi,

Im using the drivers library in my project. I have a problem with the UART DMA Transmit side of things.

I want to initialize the driver as is recommended by various examples and also by the documentation. See below.

     // UART0  Give driver the inbound buffer

      Result = adi_dev_Read(U0DriverHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *) &U0InboundBuffer);

      if(Result != ADI_DEV_RESULT_SUCCESS)

      {

        return (FAIL);

      }

      // UART0  Give driver the outbound buffer

      Result = adi_dev_Write(U0DriverHandle, ADI_DEV_1D, (ADI_DEV_BUFFER *) &U0OutboundBuffer);

      if(Result != ADI_DEV_RESULT_SUCCESS)

      {

        return (FAIL);

      }

      // UART0 Enable Data Flow

      Result = adi_dev_Control(U0DriverHandle, ADI_DEV_CMD_SET_DATAFLOW, (void *) TRUE);

      if(Result != ADI_DEV_RESULT_SUCCESS)

      {

        return (FAIL);

      }

The UART DMA transmit works. Only problem I currently have is the moment I call the last function, adi_dev_Control() to enable data flow, the UART sends of one byte. Obviously this is the byte of data I have initiales the U0OutboundBuffer with. I dont want this one byte of data to be transmitted. If I dont initialize the driver this way, my code gets stuck in the interrupt section (adi_int.asm or adi_dma.c etc.).

I want to send data over later in my application but have found that if I do not call the adi_dev_write() function as above before adi_dev_control(), my application does not run correct. I have tried setting the U0OutboundBuffer up with a element count = 0, but then the UART DMA blasts of a few hundred bytes of junk data at startup and only after that continues to send my 50ms interval packets.

I just want to initialise the driver without it sending that byte of data off at startup. Is it possible or will I have to make do with it like that and just the connected processor to ignore that one byte? I need the rx buffer initialized at startup so I cant wait until I have something to send to call the adi_dev_control function to enable data flow. It must always be ready to send data and always be ready to receive.

The examples using the UART driver are always the same, setup the tx buffer and rx buffer before calling adi_dev_control fucntion and then the DMA sends and receives the data as soon as control is called and voila, finished. Theres no example setting the UART DMA up with the driver. And then maybe pushing a button will send the data off and receive it.

Please let me know if you need more information.

Kind regards,

Quintin.

  • Hi, I also have an idea to to DMA RX. But, Im going to setup the buffer as a 1 byte buffer. Thus, I will get a DMA finished interrupt every byte I receive, essentially making it a interrupt driven UART anyways. But to be able to use the system uart driver in DMA mode I need to do this.

    I have tried with no success so far. I keep getting the first byte 4 times instead of getting it once and then the next byte. I do submit the new buffer as soon as I get the callback from the UART DMA. Will this work or am I making the DMA work to hard. We want to do comms at a BUAD of 3125000. The interrupt driven driver I wrote previously worked well. But it seems like the system uart dma driver does not like being used like that for now. Maybe I am doing something wrong.

  • Hi,

    Just an update. I still have the original issue of the driver sending a byte of at initialization. I did get my UART driver working with the system driver RX and TX DMA. The one byte RX DMA is working well, I dont know if it is very efficient use of the DMA but at least it is efficient use of my time as I now dont need to rewrite the driver to suite my needs. Could someone still please help me with my original problem. Any suggestions would be welcome.

    Quintin.

  • 0
    •  Analog Employees 
    on Mar 2, 2016 10:17 AM

    Hi Quintin

    I am looking in to this. If BIDIRECTIONAL is enabled, as you said, you are far stretching the DMA too control RX and TX DMAs separately, its the way driver is designed. I am checking this and looking at another option, though I am skeptical about that one too. Using DMA only for 1 byte is not efficient as you mentioned, but you could use the non DMA driver for RX to do that as well (again that means not using continuous transfer facility for more than 1 byte).

    Regards

    Prasanth

  • Hi Prasanth,

    Look, Im happy with the way the DMA UART is working. I wont be receiving a lot of packets. So using the DMA in a 1-byte RX is not a problem for me. Well yet. I am also not too worried by the one byte that the DMA TX Initialization sends off, our protocol handles it. But I would like to not send it off as its just unnecessary in my mind. OCD? So if you could just help me on that point. If it is not possible to do a DMA TX Initialization without sending a byte off I fine with that and we can close this query. 

    Kind regards,

    Thanks for the help and reply.

  • 0
    •  Analog Employees 
    on Apr 1, 2016 1:49 AM

    Quintin, sincere apologies that it took a while. Talking to developers, what we thought is still relevant that - The answer is, if the application submits a buffer and then enables data flow then the contents of the buffer will be transmitted. There’s no way around that. Whatever you could achieve by tweaking application is best in this case.

    Best Regards

    Prasanth