2265 views|1 replies

1w

Posts

16

Resources
The OP
 

[GD32E231 DIY Contest] 2. Light up a digit of the digital tube [Copy link]

My project is a digital clock, I want to build one first. I have some time these two days, I went to the electronic parts store and bought four red 1-inch LEDs, with a common cathode. My design is like this, use 8050 to connect the cathode, 8050 base with 1K, and the other end is connected to the single-chip microcomputer. The 8-bit digital tube is connected in series with an 82-ohm resistor, and the other end is connected to the single-chip microcomputer. In order to verify whether it works well, I only used two pins PB3 and PB4, PB3 drives the transistor, and PB4 drives the 8-bit pin. At the beginning, I ran it for a while and it didn't light up. I checked with a multimeter and it was only about 1.25 volts. What's going on? I checked the manual and found that the output can be pulled up. So I changed them all to pull-up output, tried it, and one of the digital tubes lit up The program is as follows:
  1. #include "gd32e23x.h" #include "gd32e231c_start.h" #include "systick.h" #include<stdio.h>
  2. /*!
  3.     \brief      main function
  4.     \param[in]  none
  5.     \param[out] none
  6.     \retval     none
  7. */
  8. int main(void)
  9. {
  10.     systick_config();
  11.    
  12.     /* enable the LED1 GPIO clock */
  13.     rcu_periph_clock_enable(RCU_GPIOB);
  14.     /* configure LED1 GPIO port */
  15.     gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO_PIN_3);
  16.     gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_3);
  17.            gpio_mode_set(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, GPIO_PIN_4);
  18.     gpio_output_options_set(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_4);
  19.     /* reset LED1 GPIO pin */
  20.     gpio_bit_set(GPIOB,GPIO_PIN_3);
  21.     while(1){
  22.         /* turn on LED1 */
  23.         gpio_bit_set(GPIOB,GPIO_PIN_4);
  24.         delay_1ms(1000);
  25.         /* turn off LED1 */
  26.         gpio_bit_reset(GPIOB,GPIO_PIN_4);
  27.         delay_1ms(1000);
  28.     }
  29. }
复制代码


连线有点麻烦,正考虑打个板来这。
This post is from GD32 MCU

Latest reply

Thanks for sharing!  Details Published on 2019-5-5 09:22
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 

172

Posts

0

Resources
2
 
Thanks for sharing!
This post is from GD32 MCU
 
 
 

Just looking around
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