problem with two usart running together

Hi,
I encounter with a weird problem with my arduino due.
I am writing my code in Atmel Studio. most of my project is complete.
but when I tried to add a new feature to the project that utilize another usart my code began to stuck in the function that I Set the PDC pointer, counter and setting the time-out timer…

the function that the controller stuck in worked before I added the new feature…

I came here because after a week of fighting I am clueless…

any advice?

With no code to look at, we are also clueless. If your project is large, try to write a new, small, program which shows the error.

here are the relevant code parts

//// GPS USART TIMEOUT INTERRUPT ////
void USART1_Handler()
{
	gps_sample_ready_falg = 1;
	IMU.read_gps_buffer();
	USART1->US_CR |= 0x1u << 11;  //Clears USART TO flag
}
void CUsart_Dma::ActivateUSART0()
{
	/* Write Protect Mode */
	PMC->PMC_WPMR   = 0x504D43   << 8;
	PIOA->PIO_WPMR  = 0x50494F   << 8;
	DMAC->DMAC_WPMR = 0x444D4143 << 1;
	USART0->US_WPMR = 0x555341   << 8;
	
	/* USART */
	PMC->PMC_PCER0  = 0x1u << 17;
	PIOA->PIO_PDR  |= PIO_PA11 | PIO_PA10;
	PIOA->PIO_OER  |= PIO_PA11 | PIO_PA10;
	PIOA->PIO_ABSR &= 0xfffff3ff;


	USART0->US_CR   = 0x00000050; //5
	USART0->US_MR   = 0x000808D0;
	USART0->US_IDR  = 0xFFFFFFFF;
	USART0->US_BRGR = 34;

	USART0->US_RTOR = 10;

	/* PDC */
	USART0->US_PTCR = 0x00000101;
	USART0->US_TNCR = 0;
	USART0->US_RNCR = 0;	
}
void CUsart_Dma::SetReciveBuffer(char *str, int buf_size)
{
	mRx_buffer = str;
	mRx_buffer_add = (int)mRx_buffer;
	RCR_size = buf_size;
	
	USART0->US_RPR = mRx_buffer_add;
	USART0->US_RCR = RCR_size;
	
	USART0->US_CR  |= 0x00000800;
}
void CUsart::ActivateUSART1()
{
	/* Write Protect Mode */
	PMC->PMC_WPMR   = 0x504D43   << 8;
	PIOA->PIO_WPMR  = 0x50494F   << 8;
	DMAC->DMAC_WPMR = 0x444D4143 << 1;
	USART1->US_WPMR = 0x555341   << 8;
	
	NVIC_EnableIRQ(USART1_IRQn);
	NVIC_SetPriority(USART1_IRQn,2);
	
	/* USART */
	PMC->PMC_PCER0  = 0x1u << 18;
	PIOA->PIO_PDR  |= PIO_PA12 | PIO_PA13;
	PIOA->PIO_OER  |= PIO_PA12 | PIO_PA13;
	PIOA->PIO_ABSR &= 0xffffcfff;


	USART1->US_CR   = 0x00000050; // RX1 & TX1 enable
	USART1->US_MR   = 0x000808D0;
	USART1->US_IDR  = 0xFFFFFFFF;
	USART1->US_BRGR = 273;		  //4807bps
	USART1->US_RTOR = 16;		  //time out interrupt after  16 X 1 / 4807 seconds
	USART1->US_IER  = 0x00000100; //time out interrupt enable	
	
	USART1->US_PTCR = 0x00000101;
	
	/* PDC */
	USART1->US_PTCR = 0x00000101;
	USART1->US_TNCR = 0;	
}

and here is the function I get stuck in:

void CUsart::SetReciveBuffer(char *str, int buf_size)
{
	//g_led.ON();
	m_ReciveBuffer = str;
	m_ReciveBuffer_add = (int)(m_ReciveBuffer);
	RCR_size = buf_size;
	
	USART1->US_RPR = m_ReciveBuffer_add;
	USART1->US_RCR = RCR_size;
	
	USART1->US_CR  |= 0x00000800;
	g_led.TOGGLE();
}

when I used usart1 for receiving and transmitting and usart0 for transmitting only the code ran fullness the second I added usart0 rx and open its timeout mechanisms the problem start…

here is the function that check the usart0 timeout

int isReciveFromGnd()
{
	volatile int time_out_flag = 0;
	
	if (tx_to_flag == 0)
	{
		time_out_flag  = USART0->US_CSR >> 8;
		time_out_flag &= 0x01;
		
		if (time_out_flag == 0x01)
		{	
			return 1;
		}
		else
		{
			return 0;
		}
	}
	else
	{
		return 0;
	}
}

and here are the one that I use to retriggered usart0 timeout counter

void sendReset2Gnd()
{
	debug_str[0] = 0;
	strcpy(debug_str,"r r r\n");
	usart_dma.SetReciveBuffer(rx_buffer,100);
	usart_dma.SetMessage(debug_str);
	usart_dma.SendViaUSART0();
	
}

void sendContinue2Gnd()
{
	debug_str[0] = 0;
	usart_dma.SetReciveBuffer(rx_buffer,100);
	strcpy(debug_str,"c c c\n");
	usart_dma.SetMessage(debug_str);
	usart_dma.SendViaUSART0();
}

I don’t know why the controller get stuck there… but it does… until the watch-dog reset the processor and then its stuck again…