2805 views|3 replies

174

Posts

1

Resources
The OP
 

【Fudan Micro FM33LC046N Review】+ LED and KEY [Copy link]

 This post was last edited by chrisrh on 2021-2-8 22:24

As the year draws to a close, problems have arisen one after another, disrupting the original schedule...Stay strong...

I used LED and key briefly, and will continue...

The DEMO comes with four LED lights. Calling library functions to light up the LEDs uses a library similar to ST.

in:

LED1----->PC0

LED2----->PC1

LED3----->PB10 (J42 jumper short-circuit)

LED4----->PB9 (J43 jumper short-circuit)

First, simply use the key to call IO to light up the LED light

led.h

#ifndef __LED_H__
#define __LED_H__

#include "main.h"

#define LED1_GPIO   GPIOC
#define LED1_PIN    FL_GPIO_PIN_0

#define LED1_ON()   FL_GPIO_ResetOutputPin(LED1_GPIO, LED1_PIN)
#define LED1_OFF()  FL_GPIO_SetOutputPin(LED1_GPIO, LED1_PIN)
#define LED1_TOG()  FL_GPIO_ToggleOutputPin(LED1_GPIO, LED1_PIN)

#define LED2_GPIO   GPIOC
#define LED2_PIN    FL_GPIO_PIN_1

#define LED2_ON()   FL_GPIO_ResetOutputPin(LED2_GPIO, LED2_PIN)
#define LED2_OFF()  FL_GPIO_SetOutputPin(LED2_GPIO, LED2_PIN)
#define LED2_TOG()  FL_GPIO_ToggleOutputPin(LED2_GPIO, LED2_PIN)

#define LED3_GPIO   GPIOB
#define LED3_PIN    FL_GPIO_PIN_10

#define LED3_ON()   FL_GPIO_ResetOutputPin(LED3_GPIO, LED3_PIN)
#define LED3_OFF()  FL_GPIO_SetOutputPin(LED3_GPIO, LED3_PIN)
#define LED3_TOG()  FL_GPIO_ToggleOutputPin(LED3_GPIO, LED3_PIN)

#define LED4_GPIO   GPIOB
#define LED4_PIN    FL_GPIO_PIN_9

#define LED4_ON()   FL_GPIO_ResetOutputPin(LED4_GPIO, LED4_PIN)
#define LED4_OFF()  FL_GPIO_SetOutputPin(LED4_GPIO, LED4_PIN)
#define LED4_TOG()  FL_GPIO_ToggleOutputPin(LED4_GPIO, LED4_PIN)

void My_LEDInit(void);
void LED_Blink(uint8_t BlinkNum,uint16_t BlinkTime);

#endif

led.c

#include "led.h"
#include "user_init.h"

void My_LEDInit(void)
{
    uint8_t count = 5;
    
    FL_GPIO_InitTypeDef GPIO_InitStruct;// = {0};
   
    FL_GPIO_ResetOutputPin(LED1_GPIO, LED1_PIN);
	FL_GPIO_ResetOutputPin(LED2_GPIO, LED2_PIN);
    
    GPIO_InitStruct.pin = LED1_PIN|LED2_PIN;
    GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT;
    GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    GPIO_InitStruct.pull = DISABLE;
    FL_GPIO_Init(LED1_GPIO, &GPIO_InitStruct);
	FL_GPIO_Init(LED2_GPIO, &GPIO_InitStruct);
    
		
	FL_GPIO_ResetOutputPin(LED3_GPIO, LED3_PIN);
	FL_GPIO_ResetOutputPin(LED4_GPIO, LED4_PIN);
    
    GPIO_InitStruct.pin = LED3_PIN|LED4_PIN;
    GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT;
    GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    GPIO_InitStruct.pull = DISABLE;
    FL_GPIO_Init(LED3_GPIO, &GPIO_InitStruct);
	FL_GPIO_Init(LED4_GPIO, &GPIO_InitStruct);
		
    while (count--)
    {
        LED1_ON();LED2_ON();
        DelayMs(100);
		LED1_OFF();LED2_OFF();
		DelayMs(100);
		LED3_TOG();LED4_TOG();
		DelayMs(100);
    }
}


void LED_Blink(uint8_t BlinkNum,uint16_t BlinkTime)
{
	uint8_t count = BlinkNum;
	uint16_t time = BlinkTime;
	while(count--)
	{
		LED1_ON();LED2_OFF();
        DelayMs(time);
		LED1_OFF();LED2_ON();
		DelayMs(time);
	}
	FL_GPIO_SetOutputPin(LED1_GPIO, LED1_PIN);
	FL_GPIO_SetOutputPin(LED2_GPIO, LED2_PIN);
}

Button 1 and button 4 are directly connected to MCU, and buttons 2 and 3 are short-circuited.

KEY1----->PA10

KEY2----->PB12 (J40 jumper short circuit)

KEY3----->PD11 (J41 jumper short circuit)

KEY4----->PC6

key.h

#ifndef __KEY_H__
#define __KEY_H__

#include "main.h"

#define KEY1_GPIO   GPIOA
#define KEY1_PIN    FL_GPIO_PIN_10
#define KEY2_GPIO   GPIOB
#define KEY2_PIN    FL_GPIO_PIN_12
#define KEY3_GPIO   GPIOD
#define KEY3_PIN    FL_GPIO_PIN_11
#define KEY4_GPIO   GPIOC
#define KEY4_PIN    FL_GPIO_PIN_6

#define KEY1_State FL_GPIO_GetInputPin(KEY1_GPIO,KEY1_PIN)
#define KEY2_State FL_GPIO_GetInputPin(KEY2_GPIO,KEY2_PIN)
#define KEY3_State FL_GPIO_GetInputPin(KEY3_GPIO,KEY3_PIN)
#define KEY4_State FL_GPIO_GetInputPin(KEY4_GPIO,KEY4_PIN)

#define KEY1_PRES  1	//KEY1按下
#define KEY2_PRES  2	//KEY2按下
#define KEY3_PRES  3	//KEY3按下
#define KEY4_PRES  4	//KEY4按下

void KEY_Init(void);
uint8_t KEY_Scan(uint8_t);

#endif

key.c

#include "key.h"
#include "user_init.h"

void KEY_Init(void)
{ 
    FL_GPIO_InitTypeDef GPIO_InitStruct;// = {0};
   
    FL_GPIO_SetOutputPin(GPIOA, FL_GPIO_PIN_10);
	FL_GPIO_SetOutputPin(GPIOC, FL_GPIO_PIN_6);
    
    GPIO_InitStruct.pin = KEY1_PIN|KEY4_PIN;
    GPIO_InitStruct.mode = FL_GPIO_MODE_INPUT;
    GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
    GPIO_InitStruct.pull = DISABLE;
	GPIO_InitStruct.remapPin   = DISABLE;
    FL_GPIO_Init(KEY1_GPIO, &GPIO_InitStruct);
	FL_GPIO_Init(KEY4_GPIO, &GPIO_InitStruct);
}

uint8_t KEY_Scan(uint8_t mode)
{	 	  
	if((KEY1_State==0||KEY4_State==0))
	{
		DelayMs(100);
		if(KEY1_State==0)return KEY1_PRES;
		else if(KEY4_State==0)return KEY4_PRES;
	}	    
	return 0;
}

main.c

#include "main.h"
#include "adc.h"
#include "led.h"
#include "key.h"

float  GetT;
  
int main(void)
{
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
	uint8_t key=0;

    /* SHOULD BE KEPT!!! */
    MF_Clock_Init();
    
    /* Configure the system clock */
    /* SHOULD BE KEPT!!! */
    MF_SystemClock_Config();
    /* user init */
    UserInit();
    /* Initialize all configured peripherals */
    /* SHOULD BE KEPT!!! */

    MF_Config_Init();

	My_LEDInit();
	DelayMs(1000);
	//LED_Blink(5,500);
		
	KEY_Init();          //初始化按键
		
	while(1)
	{
		key=KEY_Scan(1);	//得到键值
		if(key)
		{						   
			switch(key)
			{				 
				case KEY1_PRES:	//控制key1
				LED1_ON();LED2_ON();break;
				case KEY4_PRES:	//控制key4 
				LED1_OFF();LED2_OFF();LED3_TOG();LED4_TOG();break;
			};
		}
		DelayMs(10); 
	}
}


Some personal feelings:

1. I feel that FM should be building its own library functions and related library function manuals, so that it will be easier for users to get started. I look forward to the early release of the manual;

2. For the next demo, you can consider replacing the 5V power supply port with a commonly used USB port. It will be more convenient to power it. You can leave it unwelded like now, and you can add it yourself later .

3. The board is very good, to be continued...

This post is from Domestic Chip Exchange

Latest reply

I still don’t understand. Why don’t you add my QQ (QQ:1269909129) and I will ask you for detailed advice. Thank you, brother!   Details Published on 2021-10-12 10:41
 
 

2

Posts

0

Resources
2
 

Please advise!!!

Why after I burned your program, the four small lights on the development board kept on and the buttons didn't work?

This post is from Domestic Chip Exchange

Comments

Check if there is any problem with the IO driver function configuration. Only KEY1 and KEY4 are used. The following link contains some engineering codes with peripherals, which you can refer to: [Fudan Micro FM33LC046N Evaluation] + Use of some peripherals - Domestic chip exchange - Electronic Engineering World Forum (eewor  Details Published on 2021-10-11 08:37
 
 
 

174

Posts

1

Resources
3
 
Happy Bing posted on 2021-10-10 14:55 Please teach me! ! ! Why after I burned the program according to your program, the four small lights on the development board kept on and the buttons didn't work.

Check if there is any problem with the IO driver function configuration. Only KEY1 and KEY4 are used.

The following link contains some engineering codes for peripherals, which you can refer to:

[Fudan Micro FM33LC046N Review] + Use of some peripherals - Domestic chip exchange - Electronic Engineering World - Forum (eeworld.com.cn)

This post is from Domestic Chip Exchange
 
 
 

2

Posts

0

Resources
4
 
chrisrh posted on 2021-10-11 08:37 Check if there is any problem with the IO driver function configuration. Only KEY1 and KEY4 are used. The following link contains some peripheral configuration projects...

I still don’t understand. Why don’t you add my QQ (QQ:1269909129) and I will ask you for detailed advice. Thank you, brother!

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

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