I am using an STM 32 F401 Nucleo and i want to send numbers from PC via UART.
For example I need to set the frequency and amplitude.
Can some one help me to provide the code?
Thank you in advance.
PC code, or STM32F401 code?
Should be able to use USART2 via PA2/PA3, buffer inbound data, parse, and process with sscanf(), etc.
Might want to start with output, and adapt
Hi,how can i use scanf ? is not working
scanf is a standard 'C' library function: scanf - C++ Reference
To find out how to link a UART to stdin, you will have to study your toolchain documentation.
Alternatively, you could just receive characters form the UART into a buffer to form a string, and use sscanf:
sscanf - C++ Reference
Or you could just parse the received characters manually.
Vasile Guta_Ciucur has already pointed you to UART examples...
Andrei, in your STM32CubeF4 package you should find UART examples (Polling, IT and DMA) for your Nucleo board. Download it from here if you don't have it yet:
STM32CubeF4 - Embedded software for STM32F4 series (HAL, Low-Layer APIs and CMSIS (CORE, DSP, RTOS), USB, TCP/IP, File s…
Ai mai folosit placa te pricepi?
Salut, am alta placa, cu viteza mai mica, Nucleo-L152RE, prima de genul asta si primul meu micro STM32. Invat din mers
vreau sa trimit niste numere de la tastatura catre placa crezi ca i stii cum se face?
De exemplu sa setez frecventa si amplitudinea.
For the benefit of other readers, please keep the conversation in English
I did that (sending characters from PC to board) to AVR and PIC boards, and also sending from Android via bluetooth (you can find a bluetooth module at http://robofun.ro) but not yet for STM32... right now I have to finish a project, and the next will be an application with something similar, just basic stuff. Even if it won't be on time to help you.
Meantime, go to the page I sent you before, and download the package from the bottom (the last link), is an archive from over 400Mb in size, unpack it and go to the Projects subfolder, search inside, and even if your board doesn't have those examples, other boards have - it is the same family of microcontrollers. Search for a polling communication between two boards and look at the UART preparations and at the receiving part. For the PC part, you can send code from a terminal (look for one that has that ability) or you can program an application that has access to serial port (I did it in Object Pascal - Delphi, Lazarus + FreePascal but as I always install an interesting linux distro, my projects dies in that process ).
But I advise you to start with an Arduino board to get proficient and then will be easy to migrate
Thank you for the feedback.
Its ok with you if you give me your email address so i can update you with my project?
Retrieving data ...