cancel
Showing results for 
Search instead for 
Did you mean: 

Putty and STM32F0

edouard
Associate II
Posted on August 29, 2015 at 19:58

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.

4 REPLIES 4
raptorhal2
Lead
Posted on August 29, 2015 at 22:17

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, Hal

edouard
Associate II
Posted on August 30, 2015 at 09:39

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.

raptorhal2
Lead
Posted on August 30, 2015 at 15:41

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, Hal

Posted on August 30, 2015 at 17:54

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).

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