2909 views|4 replies

15

Posts

0

Resources
The OP
 

ST NUCLEO-G071RB evaluation serial port printing and LED flashing [Copy link]

This post was last edited by Jack Zhang on 2020-1-3 17:04

Test a cost-effective MCU . This MCU is definitely a must-have sword for embedded engineers. The most amazing thing is that ST company gives you the sword and also provides a sword manual to ward off evil spirits (see the picture below)

I have the sword and the sword manual, but I still need to practice.

STM32G071 is a newcomer to the industry. Let me show you how to flip GPIO and print serial port. Please don't laugh at me.

Now it starts

Double-click the icon below to open the STM32CubeMX software

Enter the following interface

Find the ACCESS TO MCU SELECTOR option in this interface as shown below

Click to open the MCU selection interface as shown below

Find the image below and enter STM32G071RB in the Search MCU dialog box.

When the input is completed, the dialog box in the lower right corner will display two options as shown below. We select the chip with LQFP64 package and double-click this option.

Double-click to enter the following interface

At this time, you must pay attention to whether the MCU option at the bottom is as shown below

Enter PA5 in the interface search window . After entering, PA5 will flash or change color.

Click PA5 and select the PGIO_Output option as shown in the figure below. Please also refer to the schematic diagram. PA5 is connected to an external yellow LED light. We use this as an output display. We can use this LED to observe whether the MCU is working and its working status.

The LED related schematic diagram is as follows

Then select LPUART1 in the Commectivity tab , find the Mode tab in LPUART1 Mode and Configuration and select Asynchronous communication , as shown below

After selection, the following figure is shown. At this time, the default interface of LPUART1 is PC0 and PC1. We need to change the communication interface of LPUART1 to the interface that the hardware of Nucleo board has been connected to ( PA2 and PA3 ).

The method to modify the communication interface of LPUART1 is as follows: hold down the CTRL key and drag PC0 to PA3 with the mouse, hold down the CTRL key and drag PC1 to PA2 with the mouse. The modified interface is as shown below

In the Time Configuration tab, find the yellow box in the picture below and fill it with 64 and press Enter. Then check whether the values in the three red boxes are the same as the picture below.

After completing the above settings, return to the Pinout & Configuration tab and find the Parameter settings tab. In Basic Parameters, change Baud Rate to 115200Bits/s , Word Length to 8Bits , Parityn to None , and Stop Bits to 1 , as shown below.

Now, we just need to enter the project name in the project manager and select IDE , as shown below

After completing this step, click GENERATE CODE to generate the code.

After generating the code, open MDK, find the main file and add #include <stdio.h> around line 26 as shown below

Add #define PUTCHAR_PROTOTYPE int fputc (int ch, FILE *f) around line 56 as shown below

Add around line 237

PUTCHAR_PROTOTYPE

{

HAL_UART_Transmit(&hlpuart1,(uint8_t *)&ch,1,0xff);

return ch;

}

Add to the main function

uint32_t countS=0;

Add in the main loop

printf("** Seconds Count %dS** \n\r",countS);

HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);

HAL_Delay(1000);

countS++;

When everything is complete, compile and download and run

The running results are as follows: the serial port prints the running seconds, and the LED of PA5 flips once per second



This content is originally created by EEWORLD forum user Zhang Jack . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

This post is from stm32/stm8

Latest reply

Very detailed, thanks for sharing   Details Published on 2020-1-3 19:13
 

1w

Posts

16

Resources
2
 

Can't see any pictures

This post is from stm32/stm8
 
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 

9717

Posts

24

Resources
3
 

I think this is a good post, please upload the picture

This post is from stm32/stm8
 
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 

15

Posts

0

Resources
4
 

Sorry, the picture of this post was not uploaded properly. Below is a new post. Please go there to see it. Thank you!

https://bbs.eeworld.com.cn/thread-1106737-1-1.html

Here is the project file Seconds.7z

The PDF file of this processing post, the picture is not uploaded well, you can download the PDF to view STM32G071 serial port printing and LED.pd ...

Seconds.7z

11.08 MB, downloads: 4

STM32G071串口打印及LED.pdf

2.63 MB, downloads: 6

This post is from stm32/stm8
 
 
 

1

Posts

0

Resources
5
 

Very detailed, thanks for sharing

This post is from stm32/stm8
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list