コード例 #1
0
ファイル: debug.c プロジェクト: frankzzcn/M2_SE_RTOS_Project
int_t fputc(int_t c, FILE *stream)
{
   //Standard output?
   if(stream == stdout)
   {
      //Display current character
      lcdPutChar(c);

      //On success, the character written is returned
      return c;
   }
   //Standard error output?
   else if(stream == stderr)
   {
      //Wait for the transmitter to be ready
      while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET);
      //Send character
      UART_SendData(UART0, c);
      //Wait for the transfer to complete
      while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET);

      //On success, the character written is returned
      return c;
   }
   //Unknown output?
   else
   {
      //If a writing error occurs, EOF is returned
      return EOF;
   }
}
コード例 #2
0
ファイル: platform.c プロジェクト: BackupTheBerlios/elua-svn
int platform_s_uart_recv( unsigned id, s32 timeout )
{
  if( timeout == 0 )
  {
    // Return data only if already available
    if( UART_GetFlagStatus( STR9_UART, UART_FLAG_RxFIFOEmpty ) != SET )
      return UART_ReceiveData( STR9_UART );
    else
      return -1;
  }
  while( UART_GetFlagStatus( STR9_UART, UART_FLAG_RxFIFOEmpty ) == SET );
  return UART_ReceiveData( STR9_UART );
}
コード例 #3
0
ファイル: platform.c プロジェクト: BackupTheBerlios/elua-svn
int platform_s_uart_recv( unsigned id, s32 timeout )
{
  UART_TypeDef* p_uart = ( UART_TypeDef* )uarts[ id ];

  if( timeout == 0 )
  {
    // Return data only if already available
    if( UART_GetFlagStatus( p_uart, UART_FLAG_RxFIFOEmpty ) != SET )
      return UART_ReceiveData( p_uart );
    else
      return -1;
  }
  while( UART_GetFlagStatus( p_uart, UART_FLAG_RxFIFOEmpty ) == SET );
  return UART_ReceiveData( p_uart ); 
}
コード例 #4
0
/*******************************************************************************
* Function Name  : SenderFunc
* Description    : Sender interrupt handler.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
static void SenderFunc(void)
{
  for (; (send_data_pos < send_data_length && (UART_GetFlagStatus (UART, UART_FLAG_TXFF) == RESET)); send_data_pos++)
  {
    UART_SendData(UART, SendBuffer[send_data_pos]);
  }
}
コード例 #5
0
ファイル: platform.c プロジェクト: BackupTheBerlios/elua-svn
void platform_uart_send( unsigned id, u8 data )
{
  id = id;
//  while( UART_GetFlagStatus( STR9_UART, UART_FLAG_TxFIFOFull ) == SET );
  UART_SendData( STR9_UART, data );
  while( UART_GetFlagStatus( STR9_UART, UART_FLAG_TxFIFOFull ) != RESET );  
}
コード例 #6
0
ファイル: platform.c プロジェクト: BackupTheBerlios/elua-svn
void platform_s_uart_send( unsigned id, u8 data )
{
  UART_TypeDef* p_uart = ( UART_TypeDef* )uarts[ id ];

//  while( UART_GetFlagStatus( STR9_UART, UART_FLAG_TxFIFOFull ) == SET );
  UART_SendData( p_uart, data );
  while( UART_GetFlagStatus( p_uart, UART_FLAG_TxFIFOFull ) != RESET );  
}
コード例 #7
0
ファイル: ublox.c プロジェクト: ctraabe/NaviCtrl
// -----------------------------------------------------------------------------
static void ReceiveUBloxData(void)
{
  while (!UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty))
  {
    rx_buffer_head_ = (rx_buffer_head_ + 1) % UBLOX_RX_BUFFER_LENGTH;
    rx_buffer_[rx_buffer_head_] = UART_ReceiveData(UART0);
  }
}
コード例 #8
0
ファイル: ublox.c プロジェクト: ctraabe/NaviCtrl
// -----------------------------------------------------------------------------
// This function sends the contents of buffer to the u-blox device. This
// function blocks program execution until the entire buffer is sent.
static void UBloxTxBuffer(const uint8_t * buffer, size_t length)
{
  while (length--)
  {
    while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull)) continue;
    UART_SendData(UART0, *buffer++);
  }
}
コード例 #9
0
ファイル: main.c プロジェクト: Wiznet/W7500
int main()
{
	 /*System clock configuration*/
	SystemInit();
//    *(volatile uint32_t *)(0x41001014) = 0x0060100; //clock setting 48MHz
    
    /* CLK OUT Set */
//    PAD_AFConfig(PAD_PA,GPIO_Pin_2, PAD_AF2); // PAD Config - CLKOUT used 3nd Function
    /* UART0 and UART1 configuration*/
    UART_StructInit(&UART_InitStructure);
    /* Configure UART0 */
    UART_Init(UART0,&UART_InitStructure);
    /* Configure UART1 */
    UART_Init(UART1,&UART_InitStructure);

    while(TxCounter < TxBufferSize)
    {
        /* Send one byte from UART0 to UART1 */
        UART_SendData(UART0,TxBuffer[TxCounter++]);

        /* Loop until UART0 TX FIFO Register is empty */
        while(UART_GetFlagStatus(UART0,UART_FLAG_TXFE) == RESET)
        {
        } 

        /* Loop until the UART1 Receive FIFO Register is not empty */
        while(UART_GetFlagStatus(UART1,UART_FLAG_RXFE) == SET)
        {
        }
        
        /* Store the received byte in RxBuffer */
        RxBuffer[RxCounter++] = (UART_ReceiveData(UART1) & 0xFF);
    }

    /* Check the received data with the send ones */
    TransferStatus  = Buffercmp(TxBuffer, RxBuffer, TxBufferSize);
    /* TransferStatus = PASSED, if the data transmitted from USARTy and  
       received by USARTz are the same */
    /* TransferStatus = FAILED, if the data transmitted from USARTy and 
       received by USARTz are different */

    while(1)
    {
    } 
}
コード例 #10
0
ファイル: uart0.c プロジェクト: Paulxia/navictrl
void UART0_IRQHandler(void)
{
	u8 c;
	// if receive irq (FIFO is over trigger level) or receive timeout irq (FIFO is not empty for longer times) has occured
 	if((UART_GetITStatus(UART0, UART_IT_Receive) != RESET) || (UART_GetITStatus(UART0, UART_IT_ReceiveTimeOut) != RESET) )
 	{
   		UART_ClearITPendingBit(UART0, UART_IT_Receive);			// clear receive interrupt flag
   		UART_ClearITPendingBit(UART0, UART_IT_ReceiveTimeOut);	// clear receive timeout interrupt flag

		// if debug UART is UART0
		if (DebugUART == UART0)
		{	// forward received data to the UART1 tx buffer
		 	while(UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)
			{
				// wait for space in the tx buffer of the UART1
				while(UART_GetFlagStatus(UART1, UART_FLAG_TxFIFOFull) == SET) {};
				// move the byte from the rx buffer of UART0 to the tx buffer of UART1
				UART_SendData(UART1, UART_ReceiveData(UART0));
			}
		}
		else // UART0 is not the DebugUART (normal operation)
		{
			// repeat until no byte is in the RxFIFO
	  		while (UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)
	  		{  
				c = UART_ReceiveData(UART0); // get byte from rx fifo
				switch(UART0_Muxer)
				{
					case UART0_MKGPS:
						UBX_RxParser(c); // if connected to GPS forward byte to ubx parser
						MKProtocol_CollectSerialFrame(&UART0_rx_buffer, c);	// ckeck for MK-Frames also
						break;
					case UART0_MK3MAG:
						// ignore any byte send from MK3MAG
						break;
					case UART0_UNDEF:
					default:
						// ignore the byte from unknown source
						break;
				} // eof switch(UART0_Muxer)
			} // eof while
		}  // eof UART0 is not the DebugUART
	} // eof receive irq or receive timeout irq
}
コード例 #11
0
ファイル: link_pult.c プロジェクト: maxk9/etro_new
void UART1_send_byte(uint8_t byte)
{
	UART_SendData(MDR_UART1,byte);
	time_out_byte = 0;
	/*while(!UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF))
	{
		if( time_out_byte>3)
			break;
	}
	UART_ReceiveData (MDR_UART1);
	*/
	
	while(UART_GetFlagStatus (MDR_UART1,UART_FLAG_BUSY) || !UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF))
	{
// 		if(time_out_byte>3)
// 			break;
	}
	UART_ReceiveData (MDR_UART1);
	UART_ClearITPendingBit(MDR_UART1,UART_IT_RX);
}
コード例 #12
0
ファイル: main.c プロジェクト: Wiznet/W7500P
int main()
{
	 /*System clock configuration*/
	SystemInit();
    /* UART0 and UART1 configuration*/
    UART_StructInit(&UART_InitStructure);
    /* Configure UART0 */
    UART_Init(UART0,&UART_InitStructure);
    /* Configure UART1 */
    UART_Init(UART1,&UART_InitStructure);

    while(TxCounter < TxBufferSize)
    {
        /* Send one byte from UART0 to UART1 */
        UART_SendData(UART0,TxBuffer[TxCounter++]);

        /* Loop until UART0 TX FIFO Register is empty */
        while(UART_GetFlagStatus(UART0,UART_FLAG_TXFE) == RESET)
        {
        } 

        /* Loop until the UART1 Receive FIFO Register is not empty */
        while(UART_GetFlagStatus(UART1,UART_FLAG_RXFE) == SET)
        {
        }
        
        /* Store the received byte in RxBuffer */
        RxBuffer[RxCounter++] = (UART_ReceiveData(UART1) & 0xFF);
    }

    /* Check the received data with the send ones */
    TransferStatus  = Buffercmp(TxBuffer, RxBuffer, TxBufferSize);
    /* TransferStatus = PASSED, if the data transmitted from USARTy and  
       received by USARTz are the same */
    /* TransferStatus = FAILED, if the data transmitted from USARTy and 
       received by USARTz are different */

    while(1)
    {
    } 
}
コード例 #13
0
ファイル: main.c プロジェクト: maxk9/etro_new
//==================================================================================
void UART1_send_byte(uint8_t byte)
{
	UART_SendData(MDR_UART1,byte);
	//time_out_byte=0;
	//while(!UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF))
	//while(UART_GetFlagStatus (MDR_UART1,UART_FLAG_BUSY) || !UART_GetFlagStatus (MDR_UART1,UART_FLAG_RXFF))
	while(UART_GetFlagStatus (MDR_UART1,UART_FLAG_BUSY))
	{
	}
	UART_ReceiveData (MDR_UART1);
	UART_ClearITPendingBit(MDR_UART1,UART_IT_RX);
}
コード例 #14
0
ファイル: link_pult.c プロジェクト: maxk9/etro_new
uint8_t UART1_receiv_data(void)
{
	uint8_t rec_data=0;
	/* Check RXFF flag */
    while (UART_GetFlagStatus (MDR_UART1, UART_FLAG_RXFF)!= SET)
    {
		__nop();
    }
	rec_data = UART_ReceiveData (MDR_UART1);
	
	return rec_data;
}
コード例 #15
0
ファイル: platform.c プロジェクト: BackupTheBerlios/elua-svn
int platform_uart_recv( unsigned id, unsigned timer_id, int timeout )
{
  timer_data_type tmr_start, tmr_crt;
  int res;
    
  if( timeout == 0 )
  {
    // Return data only if already available
    if( UART_GetFlagStatus(STR9_UART, UART_FLAG_RxFIFOEmpty) != SET )
      return UART_ReceiveData( STR9_UART );
    else
      return -1;
  }
  else if( timeout == PLATFORM_UART_INFINITE_TIMEOUT )
  {
    // Wait for data
    while( UART_GetFlagStatus(STR9_UART, UART_FLAG_RxFIFOEmpty) == SET );
    return UART_ReceiveData( STR9_UART );
  }
  else
  {
    // Receive char with the specified timeout
    tmr_start = platform_timer_op( timer_id, PLATFORM_TIMER_OP_START,0 );
    while( 1 )
    {
      if( UART_GetFlagStatus(STR9_UART, UART_FLAG_RxFIFOEmpty) != SET  )
      {
        res = UART_ReceiveData( STR9_UART );
        break;
      }
      else
        res = -1;
      tmr_crt = platform_timer_op( timer_id, PLATFORM_TIMER_OP_READ, 0 );
      if( platform_timer_get_diff_us( timer_id, tmr_crt, tmr_start ) >= timeout )
        break;
    }
    return res;    
  }
}
コード例 #16
0
void INT_UART0_Handler(void)
{
	uint32_t temp_1;

  if (UART_GetITStatusMasked(MDR_UART0, UART_IT_RX) == SET)
  {
		temp_1 = UART_ReceiveData(MDR_UART0);	
		
		UART_ClearITPendingBit(MDR_UART0, UART_IT_RX);

				while (UART_GetFlagStatus (MDR_UART0, UART_FLAG_TXFE)!= SET)
				{
				}
				UART_SendData (MDR_UART0,temp_1);
  }
}
コード例 #17
0
ファイル: init.c プロジェクト: LupusDei/8LU-DSP
int uartEcho()
{
  uartPut("Echo keypress mode:");

  do
  {
    if((UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)&&(RxCounter < RxBufferSize))
    {
       RxBuffer[RxCounter] = UART0->DR;
       UART_SendData(UART0, RxBuffer[RxCounter++]);
    }

  }while((RxBuffer[RxCounter - 1] != '@')&&(RxBuffer[RxCounter - 1] != '\r')&&(RxCounter != RxBufferSize));

  return 1;
}
コード例 #18
0
/*******************************************************************************
* Function Name  : ReceiverFunc
* Description    : Receiver interrupt handler.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
static void ReceiverFunc(void)
{
  uint16_t receive_data;

  /* Read data from UART */
  for (receive_data_length = 0; ((UART_GetFlagStatus(UART, UART_FLAG_RXFE) == RESET) && (receive_data_length < BUFFER_LENGTH)); )
  {
    receive_data = UART_ReceiveData(UART);

    if (UART_Flags(receive_data) == 0)
    {
      ReceiveBuffer[receive_data_length++] = UART_Data(receive_data);
    }
  }
  /* Initiate data portion sending via USB */
  USB_CDC_SendData(ReceiveBuffer, receive_data_length);
}
コード例 #19
0
void UART1_IRQHandler(void)
{
  uint32_t temp_1;
  
  //UARTx_HandlerWork(MDR_UART2);
  if (UART_GetITStatusMasked(MDR_UART1, UART_IT_RX) == SET)
  {
    temp_1 = MDR_UART1->DR;
    
    UART_ClearITPendingBit(MDR_UART1, UART_IT_RX);

    while (UART_GetFlagStatus (MDR_UART1, UART_FLAG_TXFE)!= SET)
    {
    }
    UART_SendData (MDR_UART1,0x44);
    

  }
}
コード例 #20
0
void TIMER1_IRQHandler(void)
{
  uint32_t temp_2 = 0;


    if (TIMER_GetITStatus(MDR_TIMER1, TIMER_STATUS_CNT_ARR) == SET)
    {   
    //TIMER_ClearITPendingBit(MDR_TIMER1, TIMER_STATUS_CNT_ARR);
        MDR_TIMER1->STATUS &= ~TIMER_STATUS_CNT_ARR;
      
          while (UART_GetFlagStatus (MDR_UART1, UART_FLAG_TXFE)!= SET)
    {
    }
    UART_SendData (MDR_UART1,0x35);



    }
}
コード例 #21
0
ファイル: uart0.c プロジェクト: Paulxia/navictrl
void UART0_Transmit(void)
{
	u8 tmp_tx;

	IENABLE;

	if(DebugUART == UART0) return; // no data output if debug uart is rederected to UART0
	// if something has to be send and the txd fifo is not full
	if((UART0_tx_buffer.Locked == TRUE) && (UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) == RESET))
	{
		tmp_tx = UART0_tx_buffer.pData[UART0_tx_buffer.Position++]; // read next byte from txd buffer
		UART_SendData(UART0, tmp_tx); // put character to txd fifo
		// if terminating character or end of txd buffer reached
		if((tmp_tx == '\r') || (UART0_tx_buffer.Position == UART0_tx_buffer.Size))
		{
			Buffer_Clear(&UART0_tx_buffer);
		}
	}

	IDISABLE;
}
コード例 #22
0
/**
 * @brief  Main program.
 * @param  None
 * @retval None
 */
void main ( void )
{
	uint8_t DataByte = 0x00;
	static uint8_t ReciveByte = 0x00;

	/* Enables the HSI clock on PORTD */
	RST_CLK_PCLKcmd(RST_CLK_PCLK_PORTD, ENABLE);

	/* Fill PortInit structure*/
	PortInit.PORT_PULL_UP = PORT_PULL_UP_OFF;
	PortInit.PORT_PULL_DOWN = PORT_PULL_DOWN_OFF;
	PortInit.PORT_PD_SHM = PORT_PD_SHM_OFF;
	PortInit.PORT_PD = PORT_PD_DRIVER;
	PortInit.PORT_GFEN = PORT_GFEN_OFF;
	PortInit.PORT_FUNC = PORT_FUNC_MAIN;
	PortInit.PORT_SPEED = PORT_SPEED_MAXFAST;
	PortInit.PORT_MODE = PORT_MODE_DIGITAL;

	/* Configure PORTD pins 13 (UART2_TX) as output */
	PortInit.PORT_OE = PORT_OE_OUT;
	PortInit.PORT_Pin = PORT_Pin_13;
	PORT_Init(MDR_PORTD, &PortInit);
	/* Configure PORTD pins 14 (UART1_RX) as input */
	PortInit.PORT_OE = PORT_OE_IN;
	PortInit.PORT_Pin = PORT_Pin_14;
	PORT_Init(MDR_PORTD, &PortInit);

	/* Select HSI/2 as CPU_CLK source*/
	RST_CLK_CPU_PLLconfig(RST_CLK_CPU_PLLsrcHSIdiv2, 0);

	/* Enables the CPU_CLK clock on UART2 */
	RST_CLK_PCLKcmd(RST_CLK_PCLK_UART2, ENABLE);

	/* Set the HCLK division factor = 1 for UART2*/
	UART_BRGInit(MDR_UART2, UART_HCLKdiv1 );

	/* Initialize UART_InitStructure */
	UART_InitStructure.UART_BaudRate = 9600;
	UART_InitStructure.UART_WordLength = UART_WordLength8b;
	UART_InitStructure.UART_StopBits = UART_StopBits2;
	UART_InitStructure.UART_Parity = UART_Parity_Even;
	UART_InitStructure.UART_FIFOMode = UART_FIFO_OFF;
	UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_RXE
												| UART_HardwareFlowControl_TXE;

	/* Configure UART2 parameters*/
	UART_Init(MDR_UART2, &UART_InitStructure);
	/* Enables UART2 peripheral */
	UART_Cmd(MDR_UART2, ENABLE);

	while (1) {
		/* Check TXFE flag */
		while (UART_GetFlagStatus(MDR_UART2, UART_FLAG_TXFE) != SET);

		/* Send Data from UART2 */
		UART_SendData(MDR_UART2, DataByte);

		/* Check RXFF flag */
		while (UART_GetFlagStatus(MDR_UART2, UART_FLAG_RXFF) != SET);

		/* Recive data*/
		ReciveByte = UART_ReceiveData(MDR_UART2);

		/* Increment Data */
		DataByte++;
	}
}
コード例 #23
0
ファイル: init.c プロジェクト: LupusDei/8LU-DSP
int putchar(int c)
{
    while(UART_GetFlagStatus(UART0, UART_FLAG_TxFIFOFull) != RESET);
    UART_SendData(UART0, c);
    return c;
}
コード例 #24
0
ファイル: CRT.C プロジェクト: peteratebs/webcwebbrowser
void pc(const char c)
{
   while (UART_GetFlagStatus(CONSOLE_UART, UART_FLAG_TxFIFOFull)!= RESET) {}
   UART_SendData(CONSOLE_UART, c);
}
コード例 #25
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main (void)
{
uint8_t DataByte=0x01;
static uint8_t ReciveByte[16];
uint32_t i;

  /* Enables the HSI clock on PORTB,PORTD */
  RST_CLK_PCLKcmd(RST_CLK_PCLK_PORTB,ENABLE);
  RST_CLK_PCLKcmd(RST_CLK_PCLK_PORTD,ENABLE);

  /* Fill PortInit structure*/
  PortInit.PORT_PULL_UP = PORT_PULL_UP_OFF;
  PortInit.PORT_PULL_DOWN = PORT_PULL_DOWN_OFF;
  PortInit.PORT_PD_SHM = PORT_PD_SHM_OFF;
  PortInit.PORT_PD = PORT_PD_DRIVER;
  PortInit.PORT_GFEN = PORT_GFEN_OFF;
  PortInit.PORT_FUNC = PORT_FUNC_ALTER;
  PortInit.PORT_SPEED = PORT_SPEED_MAXFAST;
  PortInit.PORT_MODE = PORT_MODE_DIGITAL;

  /* Configure PORTB pins 5 (UART1_TX) as output */
  PortInit.PORT_OE = PORT_OE_OUT;
  PortInit.PORT_Pin = PORT_Pin_5;
  PORT_Init(MDR_PORTB, &PortInit);

  /* Configure PORTB pins 6 (UART1_RX) as input */
  PortInit.PORT_OE = PORT_OE_IN;
  PortInit.PORT_Pin = PORT_Pin_6;
  PORT_Init(MDR_PORTB, &PortInit);

  /* Configure PORTD pins 1 (UART2_TX) as output */
  PortInit.PORT_OE = PORT_OE_OUT;
  PortInit.PORT_Pin = PORT_Pin_1;
  PORT_Init(MDR_PORTD, &PortInit);
  /* Configure PORTD pins 0 (UART1_RX) as input */
  PortInit.PORT_OE = PORT_OE_IN;
  PortInit.PORT_Pin = PORT_Pin_0;
  PORT_Init(MDR_PORTD, &PortInit);

  /* Select HSI/2 as CPU_CLK source*/
  RST_CLK_CPU_PLLconfig (RST_CLK_CPU_PLLsrcHSIdiv2,0);

  /* Enables the CPU_CLK clock on UART1,UART2 */
  RST_CLK_PCLKcmd(RST_CLK_PCLK_UART1, ENABLE);
  RST_CLK_PCLKcmd(RST_CLK_PCLK_UART2, ENABLE);

  /* Set the HCLK division factor = 1 for UART1,UART2*/
  UART_BRGInit(MDR_UART1, UART_HCLKdiv1);
  UART_BRGInit(MDR_UART2, UART_HCLKdiv1);

  /* Initialize UART_InitStructure */
  UART_InitStructure.UART_BaudRate                = 115000;
  UART_InitStructure.UART_WordLength              = UART_WordLength8b;
  UART_InitStructure.UART_StopBits                = UART_StopBits1;
  UART_InitStructure.UART_Parity                  = UART_Parity_No;
  UART_InitStructure.UART_FIFOMode                = UART_FIFO_ON;
  UART_InitStructure.UART_HardwareFlowControl     = UART_HardwareFlowControl_RXE | UART_HardwareFlowControl_TXE;

  /* Configure UART1 parameters*/
  UART_Init (MDR_UART1,&UART_InitStructure);

  /* Configure DMA for UART1*/
  UART_DMAConfig (MDR_UART1, UART_IT_FIFO_LVL_12words, UART_IT_FIFO_LVL_12words);
  UART_DMACmd(MDR_UART1, UART_DMA_TXE | UART_DMA_RXE | UART_DMA_ONERR, ENABLE);

  /* Enables UART1 peripheral */
  UART_Cmd(MDR_UART1,ENABLE);

  /* Configure UART2 parameters*/
  UART_Init (MDR_UART2,&UART_InitStructure);

  /* Configure DMA for UART2*/
  UART_DMAConfig (MDR_UART2, UART_IT_FIFO_LVL_12words, UART_IT_FIFO_LVL_12words);
  UART_DMACmd(MDR_UART2, UART_DMA_TXE | UART_DMA_RXE | UART_DMA_ONERR, ENABLE);

  /* Enables UART2 peripheral */
  UART_Cmd(MDR_UART2,ENABLE);

  while (1)
  {
    /* Check TXFE flag */
    while (UART_GetFlagStatus (MDR_UART1, UART_FLAG_TXFE)!= SET)
    {
    }

    /* Send Data from UART1 */
    for (i=0;i<16;i++)
    {
      UART_SendData (MDR_UART1, (uint16_t)(i+16*DataByte));
    }

    /* Check RXFF flag */
    while (UART_GetFlagStatus (MDR_UART2, UART_FLAG_RXFF)!= SET)
    {
    }

    /* Recive data */
    for (i=0;i<16;i++)
    {
      ReciveByte[i] = UART_ReceiveData (MDR_UART2);
    }

    /* Increment Data */
    DataByte++;
  }
}