Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Problem using DMA and UART

Hello,

I made a project with a Nios II processor, and I am currently trying to send data to UART. I first tried using the UART register and it works well (see code below).

After I tried using DMA (see code below) but it doesnot work. I looked the DMA status register and the bits are like if it do its work (it sets the DONE and LEN bits at the end). I also looked the outside signal with an oscilloscope, there is nothing.

And, if I send data using the first method after to have used the DMA method, I have false data that transit at high speed ('0' during ~150 ns and '1' during ~800 ns, and that is repeated during ~200 µs).

In the SOPC Builder the read Master port of the DMA is connected to the memory (I have only onchip memory in my system) and the write master port of the DMA is connected to the UART. The UART is configured with a baudrate of 115 200. The code looks good for me, so I don't see what can cause this problem. If anyone has an idea.

Thanks in advance.

Jérôme


unsigned char buffer; 
// Fill the buffer with data
...
// Send data using UART register
    for(i=0;i<200;i++)
    {
        IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, buffer);                   // Write a character on the tx register
        do                                                                      // Wait the bit TRDY is high
        {
            status = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);
        }while((status & ALTERA_AVALON_UART_STATUS_TRDY_MSK) == 0);
    }
// Send data using DMA
    IOWR_ALTERA_AVALON_DMA_STATUS(DMA_BASE, 0);
    IOWR_ALTERA_AVALON_DMA_RADDRESS(DMA_BASE, (int) buffer);
    IOWR_ALTERA_AVALON_DMA_WADDRESS(DMA_BASE, (int) IOADDR_ALTERA_AVALON_UART_TXDATA(UART_BASE));
    IOWR_ALTERA_AVALON_DMA_LENGTH(DMA_BASE, 200);
    IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_BASE, ALTERA_AVALON_DMA_CONTROL_BYTE_MSK |
                                             ALTERA_AVALON_DMA_CONTROL_LEEN_MSK |
                                             ALTERA_AVALON_DMA_CONTROL_WCON_MSK |
                                             ALTERA_AVALON_DMA_CONTROL_GO_MSK);
No RepliesBe the first to reply