Post Go back to editing

uart dma stops sending data

Category: Software
Product Number: ADSP-21583
Software Version: CCES 2.11.0

Hi team, 

in adsp sharc 21583 , with cross core embedded studio 2.11.0. 

i have 1ms ISR where the buffer tx_msg_buffer is filled and the Message_length is total number of bytes filled in the tx_msg_buffer. 

the Baud rate is 460800.

Message length will be 36 bytes.

Issue:

  1. the uart is to be used in DMA mode. but after few bytes of data transmission the data stops coming on UART. the code is running (verified by stopping the execution and checking the buffer). the buffer will contain data but, the data won't come on terminal 
  2. the core clock is 450 MHz, and SCLK_0 is 112.5MHz, At 921600 baud rate the data gets corrupted. HRM mentions that it supports the baud rate, but the data does not come correct. the bytes will be wrong.  So, I had to use 460800 baud. 

please suggest what is going wrong.

void WriteUartDsp (volatile unsigned char* tx_msg_buffer)
{




	/* Loop in while until the previous transmission is completed  */
	while (M_TRUE)
	{
		test = 0;
		test = *pREG_DMA20_STAT;

		/* Check the DMA status, if DMA status is Idle/Stop break the while loop*/
		if (M_ZERO == (test & M_DMA_RUN_STOP))
		{
			break;
		}

	}
	
	*pREG_SPU0_SECUREP82 =0x3; //uart rx dma 20
	*pREG_SPU0_SECUREP83 =0x3; //uart tx dma 21
	
	/* Set the UART0 Interrupt mask to zero*/
	*pREG_UART0_IMSK_SET = M_ZERO;

	/* Wait till the UART0 transmit hold and shift register are empty */
	while (M_ZERO == (*pREG_UART0_STAT & BITM_UART_STAT_TEMT))
	;
	while (M_ZERO == (*pREG_UART0_STAT & ENUM_UART_STAT_THR_EMPTY))
	;


	/* Disable the DMA 20 */
	*pREG_DMA20_CFG = ENUM_DMA_CFG_DIS;

	/* Assign the DMA start address for transmission */
	*pREG_DMA20_ADDRSTART = (void *) (M_MP_OFFSET | (T_U32) tx_msg_buffer);

	/*
	 * Configure DMA0 Registers, set STOP mode flow control, memory and
	 * physical transfer as 1 byte
	 */

	*pREG_DMA20_CFG = ( ENUM_DMA_CFG_MSIZE01 |
	ENUM_DMA_CFG_MSIZE01 |
	ENUM_DMA_CFG_STOP);


	/* Number of bytes to be transmitted */
	*pREG_DMA20_XCNT = Message_length

	/* Address increments in bytes */
	*pREG_DMA20_XMOD = M_ONE;

	/*~ GPSB-SDD-FNC-7576 ~*/
	/* Enable the DMA 20 */
	*pREG_DMA20_CFG |= ENUM_DMA_CFG_EN;

	/*
	 * Set the UART0 Interrupt mask to enable Receiver full interrupt and
	 * transmit full interrupt
	 */
	*pREG_UART0_IMSK_SET = M_THREE;


}

  • Hi Rajesh,

    We have tested our BSP example (driver-based) with your configuration (at a baud rate of 921600), and it is functioning correctly on our end.

    We suspect the clock configuration may causing the issue, as the code works correctly at a baud rate of 460800. So, could you please share us your UART_CLK Register value? and please let us know if you are encountering any errors or exceptions.

    Additionally, please check the following Ezone thread, which contains BareMetal code for the UART Tx DMA in the ADSP-SC594 that may be helpful for you:
    https://ez.analog.com/dsp/sharc-processors/f/q-a/581346/sc59x-uart-tx-dma

    Regards,
    Nandini.C

  • Hi Nandini, thanks for response. 

    I have referred the link above. and the codes are made similar. here is my UART baud rate initialization. 

    this is done once before interrupt is enabled. and uart write is done in 1ms ISR. 
    when called in 1ms ISR, the uart sends data for some time and then the code crashes after running for 4-5 minutes. 

    #define M_CCLK				(450e6)
    /*processor SCLK0 clock frequency*/
    #define M_SCLK0				M_CCLK/4 //(112.5e6)
    
    void InitUartDsp(void)
    {
        T_U32  baudrate = M_CLEAR;
    
    	/*~ GPSB-SDD-FNC-7536 ~*/
    	/* Enable un-secure transaction */
    	*pREG_SPU0_SECUREP31 = M_THREE; /* UART 0*/
    	*pREG_SPU0_SECUREP83 = M_THREE; /*UART0 TX DMA20*/
    	*pREG_SPU0_SECUREP82 = M_THREE; /*UART0 RX DMA21*/
    
    	baudrate = M_SCLK0 / 460800;
    
    	*pREG_UART0_CLK = (1u << 31) | baudrate  ; // edbo =1 
    
    	/* Clear the interrupt mask*/
    	*pREG_UART0_IMSK_SET = M_ZERO;
    
    	/* Enable the UART0 and choose the word length 8 with no parity */
    	*pREG_UART0_CTL = ENUM_UART_CTL_CLK_EN | ENUM_UART_CTL_WL8BITS;
    
    
    }

  • Hi team

    please respond to this and let me know if you need more info

  • Hi Rajesh,

    We are currently replicating the issue on our EZkit. In the meantime, could you please confirm if you have tested at any lower baud rates, and if so, whether it worked?

    Regards,
    Nandini.C

  • hi Nandini

    we needed to send about 500 bytes of data every 1ms, so we were trying for higher baud rate. 
    just curious, what is relation of DMA with baud rates.  UART protocol will get address to send and baud rate, DMA should place data on UART lines. 

    is there any timing constraint on that? is there any timing diagram of how much DMA will take to finish the xcount data move? 

  • Hi Rajesh,

    Sorry for the delay in getting back to you.

    There are no such constraints. We requested your confirmation in order to isolate whether the issue is related to the hardware design.

    Please refer to the attached project, which works correctly on the ADSP-SC589 Ezkit at both 460800 and 921600 baud rates.

    UART_TX_All_Cores_SC589_Core0.zip

    Please take this as a reference and modify it as per your requirement.

    Regards,
    Nandini.C

  • Nandini 

    the project attached does not replicate my issue. the UART operation is in main and not in ISR. 

    issue appears in 1ms ISR.

    in real time operation, giving delay of 200000 in between each byte write to UART is a lot of delay. 

    in project shared there is no DMA operation. 

    and there is no need for UART1 TX interrupt handler

    please consider the fact, that in 1ms ISR there are other processing to be done. example 5 FFT operation. in 1ms. UART should not take so much of processor clocks. 

    please reconsider the approach. 

  • Hi Rajesh,
    Thank you for your feedback and for your patience.
    Please note that the previous code (general UART code for all the uart instances) was shared for reference purposes only. Please find the attached project for UART on the ADSP-SC589 processor.
    In this updated version, we’ve implemented a 1ms Pulse Width Modulation (PWM) signal using a timer, and the UART buffer size has been set to 36 bytes as per your specifications. Both the UART and DMA configurations are now done within the timer interrupt handler.
    We have tested the code at baud rates of 460800 and 921600, and it is working fine. Please refer the below image.
    Please check and let us know if it meets your requirements. 
    Regards,
    Nandini.C
  • Hi Nandini 

    I tried the way it is done in the sample code 

    but this line of code did not compile in my ADSP21583 processor. 

     

    char iUART0TxBuffer[MESSAGE_LENGTH] __attribute__((section(".l2_uncached_data"))); 

    hence i tried like this 

    section ("seg_l2_uncached") volatile unsigned char     tx_msg_buffer[512]; 

    There is improvement.

    At 460800 baud, 

    • the code does not crash.
    • and it sends more number of bytes 
    • but i need to send some additional bytes before the actual data one time to start the data transmission on UART. (not sure why ? )
    • Also, in code shared above only 36 bytes are sent.  Does it work on your system if you send nearly 400-500 bytes ? 

    At 912600 baud

    • The bytes are getting corrupted. 

    what could be missing? 

  • Hi Rajesh,

     

    Initially, we used 36 bytes in the example because that was the original transfer size you provided.

    Regarding your updated requirement of transferring 400 or 500 bytes, it appears that achieving the transfer within 1 millisecond is not possible at the current baud rates.

    At 921,600 baud, the baud rate represents 921,600 bits per second. You can send approximately 921 bits in 1 millisecond. Similarly, at 460,800 baud, you can send approximately 460 bits in 1 millisecond.

    However, since you're trying to transfer 3,200 bits (for 400 bytes), this exceeds the 1 millisecond window at both baud rates, making the transfer unfeasible within that timeframe. Therefore, you need to adjust either the timing or the amount of data to be transferred.

     

    Regards,
    Nandini.C