7252 views|27 replies

931

Posts

3

Resources
The OP
 

GD'32 Learning Process [Copy link]

 
    After retirement, I picked up my hobby when I was young and started a project on automatic control of a small hydropower station. The first step of the plan is to automatically control the water inlet valve of the turbine generator set according to the amount of water inflow, so as to fully utilize the efficiency of water energy. There is a small wheel on the control panel of the small hydropower station. The small wheel is manually turned to adjust the water inlet valve. I used a small DC motor to drive the wheel and adjust the water inlet valve by controlling the forward and reverse rotation of the small motor. The water level monitoring part adopts the ultrasonic ranging method, which is controlled by a 51 single-chip microcomputer to transmit the detected data to the computer room. The data transmission adopts wireless mode, using a 433M data transceiver module. At present, the water level monitoring part has been completed, and the wireless transmission part is in the debugging process. Considering that AD conversion is needed for future expansion, the control part of the computer room will not continue to use 51 microcontrollers, and will be replaced by 32-bit microcontrollers. It happened that the forum launched the GD32F350 Innovation Design Competition of GigaDevice, and I signed up and was fortunate to be shortlisted. Before that, I learned the tutorials of SMT32 series microcontrollers through online videos, downloaded and installed IAR7.X, and found that my IAR version was too low after downloading the moderator's routines from the forum, and could not open the project file, so I tried to upgrade the version. I searched the Internet and found no suitable one. I was ready to switch to keil's MDK, but I installed it 6 to 7 times repeatedly. KeilMDK conflicted with keil51, and MDK could only be started occasionally. In most cases, I clicked to enter the startup window, and there was no response after the window disappeared. I tossed for 6 to 7 days without any results. After receiving the development board, I felt even more anxious. Fortunately, a forum friend introduced me to keil5. After downloading and installing it from the official website, I encountered troubles in downloading cracked software. I downloaded two so-called cracked software successively. They were both fake. The cracked program I really needed was not there. Instead, I was forced to use 7 to 8 software I don’t like, such as Xqiyi, KuaiX, XX Butler, etc. In order to get rid of these "rogues", I uninstalled, used the task manager, and directly deleted the folders. I used all kinds of tricks, and I did this twice. As a result, I have to use uncracked programs now. Anyway, the restrictions will not be broken at present.
After nearly half a month of hard work, keil51 and keilMDK are now coexisting on my computer without affecting each other. The development environment of the 32-bit machine is basically ready, and I can enter the code writing process. The first step is to prepare to drive the LCD5110 display. The reason why I didn't light up the LED first is that the display is more intuitive than the LED, and the display is also an important part of my project. I will report to you after the display is lit up.

This post is from GD32 MCU

Latest reply

Tribute to veteran engineers  Details Published on 2018-11-6 15:03
 

16

Posts

0

Resources
2
 
Salute to the old engineers~! Learn from the old drivers!
This post is from GD32 MCU

Comments

I am just an older new student. Although I bought books on 8051 microcontrollers 20 years ago, my actual work has nothing to do with electronics. I only really came into contact with microcontrollers two years ago. I bought a development board from Puzhong and started with 51 microcontrollers. I have a basic understanding of 51 microcontrollers. Now I have just started to learn 32-bit microcontrollers. I hope  Details Published on 2018-8-30 11:34
 
 
 

931

Posts

3

Resources
3
 
swordroo posted on 2018-8-30 10:49 Salute to the old engineers~! Learn from the old drivers!
I am just an older new student. Although I bought a book on 8051 microcontrollers twenty years ago, my actual work has nothing to do with electronics. I really came into contact with microcontrollers only the year before last. I bought a Puzhong development board and started with the 51 microcontroller. I have a basic understanding of the 51 microcontroller. Now I have just started to learn 32-bit microcontrollers. I hope to get your advice here. Thank you!
This post is from GD32 MCU
 
 
 

13

Posts

0

Resources
4
 
Learn from you
This post is from GD32 MCU
 
 
 

7422

Posts

2

Resources
5
 
Salute to the old drivers! The old engineers have a very solid foundation. I hope the old drivers will come to the community for guidance.
This post is from GD32 MCU
 
 
 

1368

Posts

6

Resources
6
 
Salute to the old engineer!
This post is from GD32 MCU
 
Personal signature专注智能产品的研究与开发,专注于电子电路的生产与制造……QQ:2912615383,电子爱好者群: void
 
 

931

Posts

3

Resources
7
 
Thank you for your support. I am here to learn and sincerely hope to get your help so that I can get started as soon as possible.
This post is from GD32 MCU
 
 
 

3180

Posts

0

Resources
8
 
Salute to the old engineer!
This post is from GD32 MCU
 
Personal signature为江山踏坏了乌骓马,为社稷拉断了宝雕弓。
 
 

5216

Posts

239

Resources
9
 
Welcome, welcome. If you have any unresolved problems, you can come to the competition area to communicate at any time.
This post is from GD32 MCU
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
 
 

931

Posts

3

Resources
10
 
I have encountered two problems during the experiment. Please help me solve them! I am using the English version of keil5MDK, which does not support Chinese. All Chinese characters are displayed as question marks, whether it is a program or a comment. Copying and pasting from other files does not work either. However, the Chinese comments in the file itself can be displayed normally. Now I have to add comments to the program in Notepad. My header file is clearly in the same directory as the .C file, but keil prompts that it cannot find the header file. What is the reason? Compilation error: lcd5110.h is clearly in the same directory as the .c file:

This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
11
 
The Chinese input problem has been solved. Just select it in the settings.
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
12
 
This post was last edited by hujj on 2018-9-4 21:39 After I moved the project files from the "keil_project" folder to the folder where main.c is located, I can add header files to main.c, but I can't add header files to system_gd32f3x0.c under CMSIS.

TIM截图20180904173918.jpg (176.4 KB, downloads: 0)

TIM截图20180904173918.jpg
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
13
 
The picture above was sent wrongly, please send it again:
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
14
 
  Continue to solve the problem of header files not being able to be added: Searching online, some people say that the path cannot start with Chinese characters or numbers. There is no Chinese character in my relative path, but there is a folder starting with a number, so I changed the folder name and tried again but it still didn't work; Preliminary analysis shows that it should be a path problem, so I moved both the .c file and the .h file to the same folder as the project file, but it still didn't work. I accidentally found that among the multiple header files added, the first one always has a red "X". If I comment out the header file with a red "X", a red "X" will appear in the next line. Suddenly, I had an idea in my mind. If I can't afford to offend, I can hide from it! So I created a new header file with the same content but a different name to bypass this hurdle. There are multiple header files added, but only the first line has a problem: After commenting out the problematic line, the next line will have a problem: I suddenly had an idea and created two header files with the same content but different names to bypass this problem: Finally, I checked and found that both header files should be included. Anyway, there is an if statement, so there will be no duplicate definition.


首个头文件找不到0.jpg (71.82 KB, downloads: 0)

首个头文件找不到0.jpg
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
15
 
This post was last edited by hujj on 2018-9-6 09:33 The screen display interface of the main control device is completed. After porting the LCD5110 driver originally under the 51 single-chip microcomputer, I started debugging. As usual, I used a logic analyzer to capture the timing of the relevant pins of LCD5110. Connect the logic analyzer (see the figure below) Watch the timing of each pin on the computer (see the figure below). Because the screen of my netbook is too small, I connected an external LCD display I was confused when I saw the timing. It was not the timing I controlled in the program at all. I repeatedly checked the program code but could not find the reason. Finally, I checked the expansion interface of the board and found that the interface I chose was repeated with the communication port of the development board. See the figure below I originally used the five pins PB10~PB14 to control LCD5110, but it conflicted with SPI2 on the development board, so I couldn't understand the timing captured by the logic analyzer. I blamed myself for not reading the reference materials carefully, so I used the five pins PB2~PB6 to control LCD5110. The reason why I didn't choose PB0 and PB1 was because the reference materials marked different colors, and PB2~PB6 happened to be connected together. I took over the pins of LCD5110 again, modified the relevant pin definitions in the program, downloaded the program and turned it on for testing. The program passed smoothly and achieved the expected purpose, as shown in the figure below: So far, the screen interface design of the main control device has been successfully completed!
   


LCD5110引脚安排(新).jpg (92.45 KB, downloads: 0)

LCD5110引脚安排(新).jpg
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
16
 
    During the test, I encountered another problem: my font data was originally stored in the code area in the 51 MCU through the code command, but the code command in MDK was wrong, so I had to temporarily put it in RAM, anyway, it would not cause insufficient RAM at present. In addition, the quality of the data cable provided by the manufacturer is really too poor, and now there is often a problem of poor connection and computer failure to recognize it. I wonder if you have also encountered this.
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
17
 
The debugging of the external DIP switch for user settings is completed. In my project, users are required to set the standard water level and the allowable deviation according to the actual situation. When the actual water level changes within the allowable deviation range, the turbine generator set does not make any adjustments. When it exceeds the allowable deviation range, it automatically controls the opening or closing of the water inlet gate. The external setting is realized through the DIP switch. The DIP switch is connected to the IO pin of the microcontroller, and the program reads the set data, but this seemingly simple matter has troubled me for several days. First, I chose an idle PC port to connect the DIP switch, opened the clock of the PC port, set PC0~PC6 (only 4+3 pins are needed in the program) to input mode and pull-up resistor mode, and then read the pin status bit by bit from high to low and convert it into a value, and display the set data on the screen. The test results are all 0. No matter how the DIP switch is set, there is no reflection, and the program does not achieve the expected purpose. I first suspected that there was something wrong with the conversion program, so I modified it to determine the pin status bit by bit, and then calculate the value based on the status. The test result was still unsuccessful. Obviously, the program did not read the status of the IO pin, so I posted a post for help, see https://en.eeworld.com/bbs/thread-925982-1-1.html. After the tips of the moderator and forum friends, and referring to some examples, I set the pins to AF mode and pull up or pull down, etc., but still could not read the set data. This tossing and turning has been going on for two days. In desperation, I tried to use the idle pins of PB to connect the dip switch, and found that I could read the data. Since the idle pins of the PB port are limited, I changed the LCD5110 originally connected to the PB port to the PC port, freeing up the PB pins to connect the dip switch, and now I can read the set data. With the same settings, why can I read data on the PB port but not on the PC port? This question still bothers me. Being able to read data does not mean success. I found that the read data is constantly changing and cannot stably reflect the state of the DIP switch setting. I used a digital multimeter to measure the output voltage of the pin and found that in the pull-up resistor state (that is, the DIP switch is disconnected), the voltage of the pin is 0.8~1.2V, far from the high level 1.68~2.11V given in the data sheet. I judged that it might be that the pull-up ability of the microcontroller is weak, so I changed the pin to the pull-down resistor mode. After testing, I found that the pin voltage was also around 0.8~1.2V at a low level, which was higher than the 0.18~0.54V in the data sheet. In other words, the pull-up and pull-down capabilities of the microcontroller are very weak and cannot provide a stable level signal. I don’t know if this is an isolated case or a common problem. I don’t know if other forum friends have encountered this problem. After thinking about it, I had to solve this problem by connecting an external pull-up resistor. I installed a resistor on the DIP switch board, connected the jumper wires and tested it. The program fully achieved the expected purpose and was able to set and display data normally.
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
18
 
Below is the code for port configuration: void port_C_Config(void) { rcu_periph_clock_enable(RCU_GPIOB); gpio_mode_set(GPIOB,GPIO_MODE_INPUT,GPIO_PUPD_PULLUP,GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6); } Below is the code for reading pin data: /*************************************************************** * Read the set standard water level (stan) and deviation (devi) data * Unit: decimeter***********************************************************/ void get_set(void) { // Calculate the set standard water level height (D3~D0) stan = gpio_input_bit_get(GPIOB,GPIO_PIN_3); stan = (stan * 2) + gpio_input_bit_get(GPIOB,GPIO_PIN_2); stan = (stan * 2) + gpio_input_bit_get(GPIOB,GPIO_PIN_1); stan = (stan * 2) + gpio_input_bit_get(GPIOB,GPIO_PIN_0); stan = (stan * 5) + 20; //0.5 meters per unit, starting from the 2-meter base point //Calculate the setting allowable deviation (D6~D4) devi = gpio_input_bit_get(GPIOB,GPIO_PIN_6); devi = (devi * 2) + gpio_input_bit_get(GPIOB,GPIO_PIN_5); devi = (devi * 2) + gpio_input_bit_get(GPIOB,GPIO_PIN_4); devi = (devi *2) + 2; //0.2 meters per unit, starting from 0.2 meters }
This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
19
 
    I am so dizzy! I have been working on it for a whole day, but I still can't drive it into an LED light. I am going to use a finished four-bit micro relay group for the output control part, and I plan to use LED instead during the debugging process. Start to use pins 0~3 of the PC port. The configuration code is as follows: rcu_periph_clock_enable(RCU_GPIOC); gpio_mode_set(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); Then use gpio_bit_set(GPIOB,GPIO_PIN_0) in the main function; delay_1ms(1000); gpio_bit_reset(GPIOB,GPIO_PIN_0); But the LED light does not light up, and no obvious change is found when measuring the voltage of the pin. Later, I tried to use the unused PB7 and PB11 pins, which also didn't work. I checked the program and connections again and again, but couldn't find the problem. So I had to temporarily use the three onboard user LED lights (i.e., pins PB8~PB10) as a substitute.


This post is from GD32 MCU
 
 
 

931

Posts

3

Resources
20
 
Successfully "hanging out with a rich man": The three user LEDs on the development board are connected to the PB8~10 pins respectively. I searched for relevant LED settings and added LED4 to all the places. The corresponding pin is PB11. Finally, an LED4 was added. Originally, I was going to add an LED to the PB7 pin, but later I found that this pin was connected to USER_KEY, so I had to give up.
This post is from GD32 MCU
 
 
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

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