2015-08-29 10:58 AM
Hello,
I have some questions (they might seems easy to you, but not to me).Im using a STM32F0 discovery and I want to read the USART2 data with putty.Since the USART2 is not directly connected to the PC, I don't know which COM is it, do I have to use a UART ->Serial adaptor between the UART and the PC to use putty ?Do I have to use printf with putty or a function like this will automatically display the data on putty ? :uint8_t Usart2Read(void){ while ( USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET); return (uint8_t)USART_ReceiveData(USART2);}Thanks a lot for your help.2015-08-29 01:17 PM
Use either a serial adapter with F0 TTL to PC USB connections, or a TTL to RS-232 chip connected to an RS-232 to USB adapter. The adapter driver on the PC will pick a COM channel.
To display the data, you need to transmit, not receive, and set up a compatible baud rate, parity, word length and stop bit. And you need to transmit ASCII characters with printf or your custom character generator. The read statement can be used to poll the PC for any characters you wish to send to the F0. This will hang the F0 waiting for a character, so receive interrupts are often used instead of polling. Cheers, Hal2015-08-30 12:39 AM
Hello, thanks for your help.
I can also only use a ttl to rs232 adaptor no ? Since my PC has 2 COM ports.So can not avoid the printf use ? I thought with putty, everytime the USART_Senddata() function was used, Putty would automatically displayed the data.2015-08-30 06:41 AM
Yes, you can use a TTL to RS-232 adapter and connect direct to a PC COMM port.
See M's post approximately 10 posts below this one for more information on transmitting to putty. Note that M is sending character strings using printf. If you wish to use SendData, you will have to ensure that ASCII character codes are being sent, otherwise strange looking characters are displayed. Cheers, Hal2015-08-30 08:54 AM
The NUCLEO boards have a VCP off USART2 using board level connectivity, the DISCO boards do not. You have to facilitate the connectivity, by finding the pins you want to use and interface them to other serial hardware, either RS232 level converters for PC serial ports, or by using USB CMOS Serial dongles (ie FTDI and CP2102 type devices).