We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hai!
i am doing a project where i used LPC2378 controller,When i handle UARTO,i found some strange problem.When i want to write 26bytes of data continously for every 20msec,in the serial port it shows me garbage data.
My Code:
buf[30] = {0x01,0x02......0x03};
for(i=0;i<26;i++) UART_send(buf[i]);
when i want to see the data at the Hyper terminal,its not the buffer data which i was send.
Pls guide me to solve the problem.
void UART_Init() { PINSEL0 |= 0x00000050; // Enable TxD0 P0.2; RxD0 P0.3
U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit Fdiv = ( Fpclk / 16 ) / baudrate ; // baud rate U0DLM = Fdiv / 256; U0DLL = Fdiv % 256; U0LCR = 0x03; // DLAB = 0 U0FCR = 0x06; // Enable and reset TX and RX FIFO.
if(install_irq( UART0_INT, (void *)Uart0Handler, HIGHEST_PRIORITY ) == FALSE) { return (0); }
U0IER = IER_RBR | IER_THRE | IER_RLS; // Enable UART0 interrupt
}
26 bytes every 20 ms means 1300 characters / second.
With 8n1 you need about 10 bits/character or 13000 baud.
You don't seem to post what baudrate you have, and your code is totally impossible to read since you did not manage to follow the posting instructions for code.
Another thing: 26 bytes is larger than the FIFO, so you can't just jam in 26 bytes directly after each other and get any nice results. You have to either busy-loop or add an interrupt handler that fills up the serial port with any data you have pending.
thanks,problem has been solved.
And do you have a description of what you had to fix the problem?
Here i am using UART0Send() routine.Descriptio is below: Sending the charactrs using UART0 ISR routine:
void UARTSend(unsigned char portNum, unsigned char *BufferPtr, unsigned int Length) { if(portNum == 0) { while(Length != 0) { // THRE status, contain valid data while ( !(UART0TxEmpty & 0x01) ); U0THR = *BufferPtr; UART0TxEmpty = 0; // not empty in the THR until it shifts out BufferPtr++; Length--; }
} else if(portNum == 3) { while(Length != 0) { // THRE status, contain valid data while ( !(UART3TxEmpty & 0x01) ); U3THR = *BufferPtr; UART3TxEmpty = 0; // not empty in the THR until it shifts out BufferPtr++; Length--; } } return; }
Here i am using UART0 ISR function whree UART0TxEmpty is updated.