cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up RS232 USART on STM32-P103

cnocbarra
Associate
Posted on January 15, 2011 at 23:47

Setting up RS232 USART on STM32-P103

20 REPLIES 20
Posted on August 14, 2012 at 15:51

Do you have any ideas why I see garbage if I set the Data Bits parameter on Realterm to 8 bits, but I see the correct string if I set it to 7 bits?

No not really. Check you don't have parity enabled, and remove the code that forwards from the other port. Sara used some 9-bit masking based on the width of DR, but I don't see how high order bits could be set by an ASCII string.

int putChar2 (int c)
{
while(!(USART2->SR & USART_FLAG_TXE));
USART2->DR = (c & 0xFF);
return(c);
}
unsigned int i = 0;
char str[] = ''Welcome to wherever you are

'';
while(1) // Loop forever
{
char *s = str;
while(*s)
putChar2((char)*s++); // Send character from string to USART2 TX
for(i=0; i<0xFFFFF; i++); // wait
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..