2080 views|0 replies

15

Posts

0

Resources
The OP
 

NUCLEO-G071RB Review: Serial Printing and LED Flashing [Copy link]

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 After entering, the dialog box in the lower right corner will display two options as shown below. We choose the chip in LQFP64 package and double-click this option After double-clicking, the following interface will be displayed At this time, be sure to pay attention to whether the MCU option at the bottom is the one shown below Enter PA5 in the interface search window . After entering, PA5 will flash or change color [attach]454810 [/attach] 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. It is possible to observe whether the MCU is working and its working status through this LED [attach]454811 [/attach]

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 modify the communication interface of LPUART1 to the interface that the hardware of the Nucleo board has been connected to ( PA2 , PA3 ) The method to modify the communication interface of LPUART1 is as follows. Press and hold the CTRL key and drag PC0 to PA3 with the mouse, and press and hold the CTRL key and drag PC1 to PA2 with the mouse. After modification, it is as shown in the following figure

In the 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 the Baud Rate to 115200 Bits/s , Word Length to 8 Bits , Parityn to None , and Stop Bits to 1 , as shown in the following figure

Now, we just need to enter the project name in the project manager and select the 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

Seconds.7z (11.08 MB, downloads: 7)



en.MB1360-G071RB-C01_Schematic.pdf (4.84 MB, downloads: 8)

STM32G071串口打印及LED.pdf (2.63 MB, downloads: 6)

Seconds.7z

en.MB1360-G071RB-C01_Sche ...

STM32G071 serial port printing and LED.pd ...

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

图片1.png (40.3 KB, downloads: 0)

图片1.png

图片11.png (22.59 KB, downloads: 0)

图片11.png

图片12.png (31 KB, downloads: 0)

图片12.png
This post is from stm32/stm8
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

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