3430 views|10 replies

1452

Posts

1

Resources
The OP
 

【CH579M-R1】+KEY control LED program [Copy link]

 
 This post was last edited by jinglixixi on 2020-9-8 00:49

In the post about PWM breathing lights, it was said that none of the PWM outputs are connected to LEDs, which is true. But it does not necessarily require an external LED module, why?

Because there is actually an LED available on the development board, as shown in Figure 1, but I looked through the schematic diagram and couldn't find out what the LED was connected to. At first I thought it was careless and the mark was forgotten. So I scanned it with a multimeter, but still found nothing. It was then that I suddenly realized: it turned out that the LED was indeed not connected to anywhere!

This makes it much more convenient to use, and you can connect wherever you need it!

The test of the PWM breathing light can be solved with just one wire. Of course, if you don’t want to connect the wires, you can find the nearest PB18 or PB19 and use a short connector to do it.

Figure 1 Schematic diagram

When running the following program, 4 LED lights can be turned on at once, and the effect is shown in Figure 2.

int main()
{
 GPIOB_ModeCfg( GPIO_Pin_18, GPIO_ModeOut_PP_5mA );
 GPIOB_ModeCfg( GPIO_Pin_19, GPIO_ModeOut_PP_5mA );
 GPIOB_ModeCfg( GPIO_Pin_4, GPIO_ModeOut_PP_5mA );
GPIOB_ModeCfg( GPIO_Pin_7, GPIO_ModeOut_PP_5mA );
 while(1)
{
GPIOB_SetBits( GPIO_Pin_18 );
  GPIOB_SetBits( GPIO_Pin_19 );
GPIOB_SetBits( GPIO_Pin_4 );
GPIOB_SetBits( GPIO_Pin_7 );
       mDelaymS( 500 );
       GPIOB_ResetBits( GPIO_Pin_18 );
GPIOB_ResetBits( GPIO_Pin_19 );
GPIOB_ResetBits( GPIO_Pin_4 );
GPIOB_ResetBits( GPIO_Pin_7 );
mDelaymS( 500 );
 }
}

Figure 2 LED light test results

There are two buttons on the development board, one is the reset button and the other is the download button. In order to save trouble, it is better not to use these two buttons for programming. For this reason, an ultra-thin soft button is used here for KEY testing.

The test program is as follows, one key controls one LED.

int main()
{
      GPIOB_ModeCfg( GPIO_Pin_18, GPIO_ModeOut_PP_5mA );
      GPIOB_ModeCfg( GPIO_Pin_19, GPIO_ModeOut_PP_5mA );
      GPIOB_ModeCfg( GPIO_Pin_4, GPIO_ModeOut_PP_5mA );
  GPIOB_ModeCfg( GPIO_Pin_7, GPIO_ModeOut_PP_5mA );
 
  GPIOB_ModeCfg( GPIO_Pin_8, GPIO_ModeIN_PU );
  GPIOB_ModeCfg( GPIO_Pin_16, GPIO_ModeIN_PU );
  GPIOA_ModeCfg( GPIO_Pin_7, GPIO_ModeIN_PU );
  GPIOA_ModeCfg( GPIO_Pin_9, GPIO_ModeIN_PU );

  while(1)
{
  if(GPIOB_ReadPortPin(GPIO_Pin_8)) GPIOB_SetBits( GPIO_Pin_18 );
 else GPIOB_ResetBits( GPIO_Pin_18 );

  if(GPIOB_ReadPortPin(GPIO_Pin_16)) GPIOB_SetBits( GPIO_Pin_19 );
 else GPIOB_ResetBits( GPIO_Pin_19 );

  if(GPIOA_ReadPortPin(GPIO_Pin_7)) GPIOB_SetBits( GPIO_Pin_4 );
 else GPIOB_ResetBits( GPIO_Pin_4 );

if(GPIOA_ReadPortPin(GPIO_Pin_9)) GPIOB_SetBits( GPIO_Pin_7 );
 else GPIOB_ResetBits( GPIO_Pin_7 );
     }
}

Figure 3 KEY test results

This post is from Domestic Chip Exchange

Latest reply

Qinheng CH579M-R1 Development Board Review Summary post: https://en.eeworld.com/bbs/thread-1140005-1-1.html   Details Published on 2020-9-14 11:33
 
 

1w

Posts

204

Resources
From 2
 

Qinheng CH579M-R1 Development Board Review

Summary post: https://en.eeworld.com/bbs/thread-1140005-1-1.html

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 
 

1w

Posts

204

Resources
3
 

That's really good. Is this LED drawn in the schematic?

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Comments

These are LED1 and LED2 in Figure 1.  Details Published on 2020-9-9 19:40
These are LED1 and LED2 in Figure 1.  Details Published on 2020-9-8 16:16
 
 
 

7422

Posts

2

Resources
4
 

Is this small keyboard included with the board?

This post is from Domestic Chip Exchange

Comments

No, it is a leftover from a previous project. It doesn’t take up space and is more convenient to use.  Details Published on 2020-9-8 16:14
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

1452

Posts

1

Resources
5
 
freebsder posted on 2020-9-8 16:05 Is this small keyboard shipped with the board?

No, it is left over from previous projects. It doesn’t take up space and is more convenient to use.

This post is from Domestic Chip Exchange
 
 
 

1452

Posts

1

Resources
6
 
okhxyyo posted on 2020-9-8 15:51 It's really good. Is this LED drawn in the schematic?

These are LED1 and LED2 in Figure 1.

This post is from Domestic Chip Exchange
 
 
 

3

Posts

0

Resources
7
 

Worth learning

This post is from Domestic Chip Exchange

Comments

Thanks for your support  Details Published on 2020-9-9 12:09
 
 
 

1452

Posts

1

Resources
8
 

Thanks for your support

This post is from Domestic Chip Exchange
 
 
 

6062

Posts

4

Resources
9
 
Nice little keyboard.
This post is from Domestic Chip Exchange
 
 
 

931

Posts

3

Resources
10
 
okhxyyo posted on 2020-9-8 15:51 It's really good. Is this LED drawn in the schematic?

Yes, the two LEDs marked yellow and green are them.

This post is from Domestic Chip Exchange

Comments

This approach is really thoughtful.  Details Published on 2020-9-9 19:52
 
 
 

1w

Posts

204

Resources
11
 
hujj posted on 2020-9-9 19:40 Yes, the two LEDs marked yellow and green are them.

This approach is really thoughtful.

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 
 

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