USART Transmit Issue

Nov 28, 2007 5 Replies

Hi All,



I am facing an issue with the USART Transmit. My code is as show below......



#include #include void main( void ) { char group[10]="Microchip "; int i; OpenUSART( USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH,



129 ); while( 1 ) { for(i=0; i

Perhaps the UART TxD pin was not in an idle condition before it got enabled ?

If so, the first character would not have a clear start bit, and would be garbled in the receiver.

Try adding a delay (e.g. 10 bit times) between enabling the UART and sending the first data.

You might want to try a delay between initialising the USART and starting to write to it. The fact that it is outputting the string correctly after the first character suggests that the busyUART() wait is working correctly.

TW

As pointed by Arlet that you got to provide a decent time for initialization. And another quick fix would be adding/sending a dummy single char that will do the initialization for sure.

ali

Will it need such a time between initalizing and starting to write ? Strange :(:( What could be the possible reasons ? Any ideas ?

Accepted .

Karthik Balaguru

Well, at a guess the USART HW is being clocked much slower than the processor clock, and may take a while to initialise. So you need to wait for it.

TW

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required