2011-01-15 02:47 PM
Setting up RS232 USART on STM32-P103
2012-08-14 06:51 AM
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
}