当前位置:网站首页>Blue Bridge Cup embedded learning summary (new version)
Blue Bridge Cup embedded learning summary (new version)
2022-06-26 07:13:00 【Yinzz2】
1.LED
GPIO_output level Set to high
void led_show(uint16_t led,uint8_t state)
{
if(state == 1)
{
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_All,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC,led<<8,GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
}
else
{
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_All,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC,led<<8,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
}
}2.KEY
GPIO Input is set to pull up , Three line key anti shake is specifically known from other blogs
_Bool key_flag=0;
unsigned char Trg;
unsigned char Cont;
void key_read(void)
{
unsigned char ReadData = (KEYPORT)^0xff;
Trg = ReadData & ( ReadData ^ Cont );
Cont = ReadData;
}
// Specific usage: search three lines to eliminate trembling
//inter.h
#ifndef _INTER_H_
#define _INTER_H_
#include "main.h"
#define KB1 HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_0)
#define KB2 HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_1)
#define KB3 HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_2)
#define KB4 HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0)
#define KEYPORT KB1 | (KB2 << 1) | (KB3 << 2) | (KB4 << 3) | 0xf0
void key_read(void);
extern unsigned char Trg;
extern unsigned char Cont;
extern _Bool key_flag;
#endif
// Remember to add... To the main function
HAL_TIM_Base_Start_IT(&htim3);
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef * htim)
{
static uint16_t key_count =0;
if(htim->Instance == TIM3)
{
key_count++;
if(key_count==10)
{
key_count=0;
key_flag=1;
}
}
}
// Timer 1ms Trigger once ,key_count by 10 when , amount to 0.1s Make key_flag Set one
3.PWM Output
Mainly in the Cubemx Open selection PWM Generation CH1 Set it up according to your needs Period,Prescaler and Pulse
// Add... To the main function HAL_TIM_PWM_Start(&htim16,TIM_CHANNEL_1);
// Set duty cycle __HAL_TIM_SetCompare(&htim16,TIM_CHANNEL_1,pa6duty);
// It is equivalent to setting... In one cycle pa6duty Number of pulses
// Set the frequency __HAL_TIM_SetAutoreload(&htim16,2000-1);
// It is equivalent to setting a cycle with 2000 Pulse 边栏推荐
- NumPy学习挑战第五关-创建数组
- QTreeWidget And QTableWidget
- Installation homebrew error summary
- Tetradecanoxy tetraphenylporphyrin methacrylate mm-tpp-14c; Cetanoxy tetraphenyl porphyrin methacrylate mm-tpp-16c; Purple solid; Qiyue supply
- MySQL storage and custom functions
- Typescript: use polymorphism instead of switch and other conditional statements
- [path planning] robot path planning based on improved artificial potential field with matlab code
- 高德地图使用自定义地图无效问题
- Redis series - redis startup, client day1-2
- Professional course - Code question record
猜你喜欢

一项听起来大胆,并且非常牛逼的操作——复刻一个 Netflix

报错问题Parameter index out of range(0 < 1) (1 > number of parameters,which is 0

GMP模型

Parameter index out of range (0 < 1) (1> number of parameters, which is 0

Alkynyl crosslinked porphyrin based polyimide materials (ppbpi-h-cr, ppbpi Mn cr.ppbpi Fe Cr); Metalloporphyrin based polyimide (ppbpi Mn, ppbpi FE) supplied by Qiyue

【元胞自动机】基于元胞自动机实现高速公路收费站交通流问题附matlab代码

Shengshi Haotong enterprise wechat sector creates a digital ecological community

Redis series - five common data types day1-3
![[image detection] image target size measurement system based on morphology with matlab code](/img/b4/87c9b1dc3e6fdf6bd58ee7d5a8f37b.png)
[image detection] image target size measurement system based on morphology with matlab code

In depth analysis of redis object structure
随机推荐
安装homebrew报错汇总
Rust中的过程宏
【图像融合】基于耦合特征学习的多模式医学图像融合附matlab代码
Meso tetra (4-bromophenyl) porphyrin (tbpp); 5,10,15,20-tetra (4-methoxy-3-sulfonylphenyl) porphyrin [t (4-mop) ps4] supplied by Qiyue
Introduction to mapping in ES
网络io,磁盘io
item2安装配置及环境失效问题解决
Which of the top ten securities companies has the lowest commission fee and is the most safe and reliable?
Liquid crystal texture diagram of purple solid mm-tpp-10c methacrylic acid decanoxy tetraphenyl porphyrin and mm-tpp-12c methacrylic acid dodecanoxy tetraphenyl porphyrin - Qi Yue display
炒股怎么选择证券公司?手机开户安全么?
If you don't understand, please hit me
Crosslinked metalloporphyrin based polyimide ppbpi-h) PPBP Mn; PBP-Fe; PPBPI-Fe-CR; Ppbpi Mn CR product - supplied by Qiyue
【推荐一款实体类转换工具 MapStruct,性能强劲,简单易上手 】
一项听起来大胆,并且非常牛逼的操作——复刻一个 Netflix
NumPy学习挑战第一关-NumPy的下载与安装
php array_merge详解
Calculate division in Oracle - solve the error report when the divisor is zero
Matlab linear programming model learning notes
Easyar use of unity
China's Ni MH battery industry development overview analysis and investment trend forecast report 2022 Edition