9841 views|2 replies

1455

Posts

1

Resources
The OP
 

[GigaDevice GD32F310 Review] +KEY expansion and parameter settings [Copy link]

Since there is only one user key on board, it is very limited when setting parameters. For this reason, it can be equipped with a membrane soft key for key expansion. The membrane key has a total of 4 key positions to meet the needs of general parameter settings. Its connection form is shown in the figure.

Key Extensions

The pins to which this button is connected are:

K1---PA6

K2---PA7

K3---PB0

K4---PB1

The corresponding button initialization function is:

void key_init(void)
{
 rcu_periph_clock_enable(RCU_GPIOA);
 rcu_periph_clock_enable(RCU_CFGCMP);
 gpio_mode_set(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO_PIN_6|GPIO_PIN_7);
rcu_periph_clock_enable(RCU_GPIOB);
 gpio_mode_set(GPIOB, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, GPIO_PIN_0|GPIO_PIN_1);
}

The functions equipped with key states are:

uint8_t key1_state_get(void)
{
 return gpio_input_bit_get(GPIOA,GPIO_PIN_6);
}

uint8_t key2_state_get(void)
{
 return gpio_input_bit_get(GPIOA,GPIO_PIN_7);
}

uint8_t key3_state_get(void)
{
 return gpio_input_bit_get(GPIOB,GPIO_PIN_0);
}

uint8_t key4_state_get(void)
{
 return gpio_input_bit_get(GPIOB,GPIO_PIN_1);
}

The main test program to implement RTC parameter settings is:

int main(void)
{
 uint16_t i=0,j=0,k=0;
systick_config();
 rcu_periph_clock_enable(RCU_GPIOA);
 gpio_mode_set(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_1);
 gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_1);
 gpio_bit_reset(GPIOA, GPIO_PIN_1);
 gd_eval_led_init(LED1);
rcu_periph_clock_enable(RCU_GPIOB);
gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO_PIN_6|GPIO_PIN_7);
 gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_6|GPIO_PIN_7);
 gpio_bit_reset(GPIOB, GPIO_PIN_6);
 gpio_bit_reset(GPIOB, GPIO_PIN_7);
OLED_Init();
 OLED_Clear();
 OLED_ShowString(20,0,"GD32F310G",16);
 OLED_ShowString(20,2,"OLED & RTC ",16);
OLED_ShowString(20,4," : :",16);
OLED_ShowNum(68,4,i,2,16);
 key_init();
delay_1ms(100);
while(1){
 if(RESET == key1_state_get()){
 i=i+1;
delay_1ms(50);
 while(RESET == key1_state_get());
 }
OLED_ShowNum(68,4,i,2,16);
 if(RESET == key4_state_get()){
 j=j+1;
delay_1ms(50);
 while(RESET == key4_state_get());
 }
OLED_ShowNum(44,4,j,2,16);
 if(RESET == key3_state_get()){
 k=k+1;
delay_1ms(50);
 while(RESET == key3_state_get());
 }
OLED_ShowNum(20,4,k,2,16);
 delay_1ms(50);
 }
}

In this way, you can use this button to set the RTC test value.

This post is from GD32 MCU

Latest reply

There are quite a few tools, I look forward to your wonderful works!  Details Published on 2022-5-9 22:05
 

6841

Posts

11

Resources
2
 
There are quite a few tools, I look forward to your wonderful works!
This post is from GD32 MCU

Comments

Haha, they are all old things at the bottom of the box.  Details Published on 2022-5-9 22:47
 
 
 

1455

Posts

1

Resources
3
 
lugl4313820 posted on 2022-5-9 22:05 There are quite a few tools, looking forward to your wonderful works!

Haha, they are all old things at the bottom of the box.

This post is from GD32 MCU
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Nine tricks for special applications of online neighborhood

This post was last edited by jameswangsynnex on 2015-3-3 19:58 1. Searching Network Neighborhoods.   As we all know, ...

PIC mid-range microcontroller series-10-bit AD converter

Previously, we talked about the AD converter of 8-bit microcontroller. This article will introduce the converter of 10-b ...

Discussing STM32H750 Part 4 (Briefly Talking about CANFD Part 1)

It's been a long time since I posted. The EE editor has just been changed, and it is indeed more comfortable to read t ...

The ampere-second product of capacitance and the volt-second product of inductance

  In the textbooks of "Electrical Engineering" or "Circuit Analysis", the definition of capacitance is as follows, as ...

【LAUNCHXL-CC2650】Pressure gasket pressure test

First, let's introduce the sensor used for pressure gaskets - thin film pressure sensor. Thin film pressure sensor is a ...

Complain about this development environment. It does not support the previous ARM simulation tools and you have to buy more tools.

1. The language switching of this software is very simple, but the Chinese localization is not complete, and the debuggi ...

Learn to make and use Tina's Docker image compilation from scratch

This post was last edited by walker2048 on 2022-8-28 10:43 ### Foreword This is the first time that a novice player has ...

I found that the numbers displayed on the LCD screen are shaking up and down. What is the reason?

This post was last edited by Yishayishi on 2023-4-21 16:35 I found that the numbers displayed on the LCD screen were sh ...

Each person says one thing, what is the most difficult part of this?

What is the most difficult refractory material?

Offline conference assembly order丨Three cities "Carbon Tour" future green infrastructure and smart travel "core" trend

Give back what you love with sincerity, and bring great gifts to engineers at the end of the year. ON Semiconductor (ons ...

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