2017-05-11 06:27 AM
Hello St Community,
I'm working on STM32F103 RB microcontroller, I've download STM32CubeMX and STM32CubeF1 .I want to show a message on my computer, thanks to a terminal, which I code on my STM32.I know that an example exist in the STM32CubeF1 but I don't succeed to enable and show the messsage on the terminal.I use Putty for the terminal and configure as thay say.Q1: What terminal can I use to do what I want?
Q2: Is it possible to, when I pressed the button send the message in a loop and when I pressed a second time it stopThanks to replie to my questionsNicolas2017-05-11 06:53 AM
Hi
Cmb.Nicolas
,I supposed that you are using theSTM32F103RB-Nucleo board
The example under the
STM32CubeF1
package is the following : STM32Cube_FW_F1_V1.4.0\Projects\STM32F103RB-Nucleo\Examples\UART\UART_HyperTerminal_DMAWord Length = 7 Bits
- One Stop Bit - Odd parity - BaudRate = 9600 baud - flow control: None-Nesrine-
2017-05-11 06:59 AM
Hi Nicolas,
To make a correct communication between the microcontroller and you computer you should have several things as a usb-to-serial adapter, to you have it?
Giving answer to your question:
Q1. You can use any terminal, the only thing to take on count is to configure it rigth (I use hercules and works really fine to me).
Q2. Off course is possible to make a code with that works like that, the best way is to do (in my opinion) is making a flow char and after that convert in to code.
For give to you a better help I would like that you post some screenshots of the Cube configurations or the .ioc file to check it, and if its possible a figure with the schematic of your implementation whit the pins that you are ussing for serial port, with that we could suggest to you a code.
2017-05-11 09:22 AM
Hi
ELMHIRI.Syrine
and thanks for your help, Yes you're right I talked aboutSTM32F103RB-Nucleo board,however I think that the word lenght has to be on 8 bits (8 Bits = 7 data bit + 1 parity bit).
My other question is: I haven't find into the HAL_library, the eventwhen you push the button (not when you pressed or release).Is this exist? It's for my project; I have to send some messages in terms of numbers of pushing the button. I actuelly do a little program on when I pressed the button, it switched the lightning rate Led; but this wasn't really accurated.-Nicolas-
2017-05-12 01:32 AM
Hi Elkin,
In fact, I have just an USB-to-microUSB connector but not anUSB To Serial Adapter. I think this
http://www.mouser.fr/ProductDetail/Gravitech/USB-SER-NANO-5/?qs=sGAEpiMZZMvq007EO%252bXAYYlbvgKp85ZE
should work for the UART.My configuration is the following one :I will transmit and receive messages with the UART via PIN PA_10 and PA_9I enable the CAN communication for another program which will sends message to another STM32F103 RB microcontrolerThank you for your help,-Nicolas-
2017-05-12 07:33 PM
Hi Nicolas,
Well, if you have a Nucleo board, you have an advantage, the ST-Link microcontroller that is embeddedfor programming works not only as ST-Link but generates a virtual serial port also (Cool, don't?), for fast testing is really good and helpful, because you don't need an external USB-Serial converter. If you are not quite sure about how to use it, you can refer to the Nucleo's user manual (UM1724), page
So, for a fast testing, as said in the user manual you have to configure USART2 in pins PA2 and PA3. I'm going to show you a little example about how to use the CubeMX and how to make a test code for System Workbench, I'm using a F030 Nucleo board, but in the practice works same.
In the Cube, select the micro an create the new project, and cofigure the USART2 in pins PA2 and PA3, also configure pin PC13 for the user switch as GPIO input.
After that, go to configuration tab and configure the peripherals: USART2 at 9600bps, 8 bits including parity
, parity none, and 1 stop bit. And name your GPIO, I'll call it SWITCH.
After that configure the outputs of the project, choose you IDE, I'll select SW4STM32, and name your project:
And after that generate the code:
Well, now pass to System Workbench, and import the code to your workspace:
After the project have been imported, open the main.c file that is in Src folder, and enter to stand on the mainline:
As your peripherals are initialized, you can use those rigth now with the HAL libraries, so, I want that when I press the switch, send a message, and don't send anymore while is pressed, so I declare a char array for the text and make the code, the switch button is normaly High, and when is pressed goes to Low. For the uart, past the arguments that are on the figure, be sure that timeout be enough to send all the characters (20ms)
With those code lines now is time to build the project, just make clic on hammer:
If the build is right, now is moment to programming your board, so make right clic the project, select target and program chip:
See attachementsAfter that, the board is now programed, so lets test the uart communication:
See attachementsCheck which serial port is assigned to the ST-Link:
See attachementsAnd almost for finish, in your favorite terminal software configure the serial terminal, I'm using Hercules, so I set, port COM7, 9600 bps, 8 bits data size, no parity, open the port and press the switch, every time you press the button, the message should appear on the terminal:
See attachementsHope this info be useful not just for you but for all community!
2017-05-13 06:53 AM
in STM32Cube_FW_F1_V1.4.0/Drivers/BSP/STM32F1xx_Nucleo/ you will find stm32f1xx_nucleo.h and stm32f1xx_nucleo.c
those are the board support package. they have hooks to make it easy to use the LEDs and buttons
2017-05-13 10:52 AM
Thank you so much for helping me
2017-05-13 10:53 AM
Thank you I will see that