Post Go back to editing

SC59x UART Tx DMA

Category: Software
Product Number: ADSP-SC592
Software Version: CCES 2.12.0

Hi

I'm trying to use a UART on a Sharc core using DMA so I can send strings of data in the background.  I have been able to configure the UART to transmit using core register access, but having difficulty getting a small DMA test function working.  My code is below.  The ARM just calls adi_gic_Init() before enabling the Sharc.

My code should output '[Hello][world!]', but only outputs '[][]' which are done using core access of the UART.

Can you point me towards where I'm going wrong?

Thanks

Howard


#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include "services/int/adi_sec.h"
#include "services/int/adi_int.h"
#include "platform_include.h"
#include "ADSP-SC59x_typedefs.h"


void uart_init(void) {

/* Use UART 0 for testing
* UART0_TX = PA_06 (multiplexed function 1)
* UART0_RX = PA_07 (multiplexed function 1)
*/

ADI_SPU_SECUREP_t secure_peripheral_reg;
secure_peripheral_reg.VALUE32 = 0;
secure_peripheral_reg.SSEC = 1;
secure_peripheral_reg.MSEC = 1;
*pREG_SPU0_SECUREP29 = secure_peripheral_reg.VALUE32; /* UART0 */

ADI_PORT_FER_SET_t port_func_set;
port_func_set.VALUE32 = 0;
port_func_set.PX6 = 1;
port_func_set.PX7 = 1;
*pREG_PORTA_FER_SET = port_func_set.VALUE32;

ADI_PORT_MUX_t port_mux;
port_mux.VALUE32 = 0;
port_mux.MUX6 = 1;
port_mux.MUX7 = 1;
*pREG_PORTA_MUX = port_mux.VALUE32;

/* Set baud rate to 300 - looks like SCLK0 is 125 MHz, not 100MHz as hinted in Hardware reference manual */
ADI_UART_CLK_t uart_clk;
uart_clk.VALUE32 = 0;
uart_clk.EDBO = UART_CLK_DIS_DIV_BY_ONE;
uart_clk.DIV = 26041;
*pREG_UART0_CLK = uart_clk.VALUE32;

ADI_UART_CTL_t uart_ctl;
uart_ctl.VALUE32 = 0;
uart_ctl.EN = UART_CTL_CLK_EN;
uart_ctl.MOD = UART_CTL_UART_MODE;
uart_ctl.WLS = UART_CTL_WL8BITS;
*pREG_UART0_CTL = uart_ctl.VALUE32;

*pREG_DMA20_STAT = 0xffffffff;
*pREG_DMA20_CFG = 0;
*pREG_DMA20_DSCPTR_NXT = 0;
*pREG_DMA20_ADDRSTART = 0;
*pREG_DMA20_XCNT = 0;
*pREG_DMA20_XMOD = 0;
*pREG_DMA20_YCNT = 0;
*pREG_DMA20_YMOD = 0;

adi_int_ClearPending(INTR_UART0_TXDMA);

}

void uart_print(const char * p_str) {

while ((*pREG_UART0_STAT & (1<<5)) == 0) {
;
}
*pREG_UART0_THR = '[';

/*
* From page 22-24 of SC592 HRM
*
* 1. Make sure that the UART_IMSK.ETBEI or the UART_IMSK.ERBFI bits are cleared before configuring the DMA.
* 2. Configure the dedicated DMA channel.
* 3. Set the UART_IMSK.ETBEI or UART_IMSK.ERBFI bits to start the transfer.
*
* From page 34-4 of SC592 HRM
*
* DMA20 UART0_TXDMA UART0 Transmit DMA
*/

ADI_UART_IMSK_CLR_t uart_imsk_clr;
uart_imsk_clr.VALUE32 = 0;
uart_imsk_clr.ETBEI = UART_IMSK_ETBEI_HI;
*pREG_UART0_IMSK_CLR = uart_imsk_clr.VALUE32;

ADI_DMA_CFG0_CFG_t dma_cfg;
dma_cfg.VALUE32 = 0;
dma_cfg.EN = DMA_CFG_EN;
dma_cfg.WNR = DMA_CFG_READ;
dma_cfg.PSIZE = DMA_CFG_PSIZE01;
dma_cfg.MSIZE = DMA_CFG_MSIZE01;
dma_cfg.FLOW = DMA_CFG_STOP;
dma_cfg.INT = DMA_CFG_XCNT_INT;
dma_cfg.TWOD = DMA_CFG_ADDR1D;

*pREG_DMA20_CFG = 0;
*pREG_DMA20_ADDRSTART = (uint32_t *)p_str;
*pREG_DMA20_XCNT = strlen(p_str);
*pREG_DMA20_XMOD = 1;
*pREG_DMA20_CFG = dma_cfg.VALUE32;

ADI_UART_IMSK_SET_t uart_imsk_set;
uart_imsk_set.VALUE32 = 0;
uart_imsk_set.ETBEI = UART_IMSK_ETBEI_HI;
*pREG_UART0_IMSK_SET = uart_imsk_set.VALUE32;

while ((*pREG_UART0_STAT & (1<<5)) == 0) {
;
}
*pREG_UART0_THR = ']';

adi_uart_DMAWrite()

return;
}


int main(int argc, char *argv[]) {

if (adi_sec_Init() != ADI_SEC_SUCCESS) {
return 1;
}

uart_init();
uart_print("Hello");
uart_print("world!");

return 0;
}
  • Hi Howard,

    We tried replicating your issue with the code snippet you provided, and we are facing some issues to run it.

    Can you please provide us your expected process flow and source code/project for us to replicate the issue and run the code at our end for analysis?

    Also, have you done any external connection to the board and are you using any serial port connectors to view your output or is it on your console window only?

    Regards,
    Ranjitha.R
  • uart-dma.zip

    Here's a complete project of the example.  I am expecting to see [Hello][world!] on UART0_TX (PA_06) at 300 baud.  This code is a test for getting DAM working with the UART.

    The '[][]' are sent using core routines and seem to work.  The Hello world! are sent by DMA and don't work.

    Hope this helps.

    Howard

  • Hi Howard,

    We tried to run your code and replicate the issue, as you mentioned [][] being printed at your end, but even that didn't work for us.

    We checked your code and came across few missing information in the code:

    1. The adi_uart_DMAWrite() call available in your snippet is missing in the source code.
    2. There was no DMA configuration for UART Rx, as UART0 Tx DMA had DMA20 configured, DMA21 for UART0 Rx DMA were missing.
    3. Were you able to see [][] printed on your console window?

    Regards,
    Ranjitha.R

  • Hi Ranjith

    I'm not using the UART driver.  I'm trying to follow the instructions in the SC592 hardware reference manual.  On page 22-24 it says:

    * Make sure that the UART_IMSK.ETBEI or the UART_IMSK.ERBFI bits are cleared before configuring the DMA.
    * Configure the dedicated DMA channel.
    * Set the UART_IMSK.ETBEI or UART_IMSK.ERBFI bits to start the transfer.

    Which is what I'm doing in lines 97 - 121 of uart-dma_Core1.c

    In the code I sent, everything is being sent to UART0 at 300 baud (no start, 1 stop, no parity).  I'm using a TTL/RS232 USB dongle on a PC and a terminal program to view the output.

    I want to be able to send data over UART0 under DMA and receive and receive an interrupt when it's completed.  Do you have any examples which do that?

  • Hi Howard,

    We were not able to replicate the issue at our end, so we are still analyzing the code.

    In meanwhile, can you refer to the example code "UARTDMAMode", available in the BSP package link provided below for DMA configuration.

    download.analog.com/.../ADI_EV-SC59x_EZ-KIT-Rel3.2.0.exe

    The example code will be available in the below path after BSP package installation.

    [Installed Path]: \Analog Devices\EV-SC59x_EZ-KIT-Rel3.0.0\EV-SC59x_EZ-KIT\Examples\drivers\uart\UARTDMAMode

    Regards,
    Ranjitha.R

  • Hi Howard,

    Sincere apologies for the delay.

    After analyzing your code, we discovered that the following configurations are missing.

    Add the off-set value (0x28240000) to DMA channel address start register for SHARC core1's L1 memory space. SPU register configuration to UART0TX DDE (WP80) for protecting UART TX DMA channel. Setting DMA_CFG.SYN bit for Mixing DMA and Core Modes.

    We have included the aforementioned configurations in your code and attached the code here

    3276.uart-dma.zip.

    This project was tested on an ADSP-SC594 processor, and both the core and DMA modes functioned as intended.

    Regards,
    Nandini C