cancel
Showing results for 
Search instead for 
Did you mean: 

garbage on UART

Posted on June 09, 2006 at 13:04

garbage on UART

2 REPLIES 2
Posted on June 08, 2006 at 20:01

Hello folks,

I'm working with a UART interface between an ARM7 and ARM9 processor. This interface simply sends messages on an as needed basis- it's largely quiet, but will send a simple request/reply type protocol between the processors. The average message size is more than the 16 byte FIFOs, but less than, say, 256 bytes.

When the processors come up, the interface is quiet and there are no problems. The ARM9 sends a request to the ARM7, it's received fine and processed by the ARM7. The ARM7 replies, and this reply is received fine by the ARM9 and processed.

Sounds good, until the SECOND message is sent from the ARM9 to the ARM7, received fine on the ARM7, processed, and the reply is built. This reply is copied to RAM as it's shipped out in the ISR for debug purposes (I am able to query this buffer to ensure that it TRIED to send the right data) The ISR believes that it's sending the correct data. However, the ARM9 receives many (say 100-200) bytes of garbage immediately preceding the message, which on it's own is delivered uncorrupted and in its entirety.

So, it seems that the UART winds up sending some garbage before sending a second message.

Thoughts on what might be the cause? The ARM9 is somewhat trusted, as the software has been stable for some time here and it's handled this communication without issue for a long time.

Anyone have similar issues before? What was the cause?

Steve

[ This message was edited by: smacmull on 08-06-2006 23:33 ]

Posted on June 09, 2006 at 13:04

So, here's the associated code (I've tried a few things, with no success)

[Initialization]

GPIO_Config(GPIO0, UART0_Tx_Pin, GPIO_AF_PP);

GPIO_Config(GPIO0, UART0_Rx_Pin, GPIO_IN_TRI_CMOS);

UART0->IER = 0; // disable all interrupts for now

UART0->CR = 0x05A9; //Enable with FIFOs, 8bit, no parity, 1SB, no loop

UART0->RxRSTR = 0xFFFF; // UART_FifoReset(Uartx, UART_RxFIFO); /* Reset the UART_RxFIFO */

UART0->TxRSTR = 0xFFFF; // UART_FifoReset(Uartx, UART_TxFIFO); /* Reset the UART_TxFIFO */

// UART_Config(UartConsole, 9600, UART_NO_PARITY, UART_1_StopBits, UARTM_8D);

// Datarate

UART0->BR = (u16)(RCCU_FrequencyValue(RCCU_FCLK)/(16 * Centaur_BAUDRATE));

/* Configure the EIC channel interrupt */

EIC->IVR = (Bit32) UART0_IRQHandler; // load jump vector

// EIC_IRQChannelPriorityConfig(UART0_IRQChannel, 6);

EIC->SIR[UART0_IRQChannel] = 5 | ((Bit32)UART0_IRQHandler << 16);

EIC->IER |= 0x0001 << UART0_IRQChannel; //EIC_IRQChannelConfig(UART0_IRQChannel, ENABLE);

UART0->IER = UART_RxBufFull; // UART_ItConfig(Uartx, (UART_RxBufFull /*|UART_TimeOutIdle*/), ENABLE); // enable receiver interrupt only

[ to send, the application code puts the message and size in sendBuffer and sendSize. it sets

sendCursor to zero, and then enables the interrupt ]

UART0->IER |= UART_TxEmpty;

[ The interrupt handler- if there's anything to send, the application will have put it in sendbuffer

and set sendCursor to zero. It then would have enabled the tx empty interrupt... ]

IntStatus = UART0->SR;

[snip]

if (IntStatus & UART_TxEmpty)

{

// tx FIFO empty interrupt; check queue and transmit some characters if not empty

// Disable Tx empty interrupt before sending the last byte.

if (sendSize == 0)

{

// queue is empty, disable further interrupts

// UART0->TxBUFR = 0;

UART0->IER &= ~UART_TxEmpty;

UART0->RxRSTR = 0xFFFF; // UART_FifoReset(Uartx, UART_RxFIFO); /* Reset the UART_RxFIFO */

UART0->TxRSTR = 0xFFFF; // UART_FifoReset(Uartx, UART_TxFIFO); /* Reset the UART_TxFIFO */

}

if (sendSize != 0)

{

debugOutputRecord[debugCursor] = sendBuffer[sendCursor];

debugCursor = (debugCursor + 1) % 1024;

debugBytesSent++;

UART0->TxBUFR = sendBuffer[sendCursor++];

sendSize--;

}

}