当前位置:   article > 正文

蓝桥杯嵌入式第十四届省赛题目解析_蓝桥杯嵌入式真题

蓝桥杯嵌入式真题

前几天刚刚参加完第十四届的省赛,这届题目比我想象中的要难,其实想一想这也是应该的,以前的知识点都被摸透了,也是需要加入新的知识点了,但是我还是想说能不能别在我参加的时候加大题目难度啊。

不过听说隔壁单片机的省赛都比往年的国赛还难,这就有点离谱了。好了,进入正题了,老规矩先看看客观题。

客观题

收集的一些历年的比赛客观题和解析,以及程序设计题的PDF,在这里分享给大家。 

链接https://pan.baidu.com/s/1hTw0inSbLjX57hOtankgKw 
提取码:np1p

有什么不理解的地方,可以在评论区提出来嗷。

程序设计题 

题目解析

这届题目用到的模块是LCD,LED,按键,ADC,PWM和脉冲捕获。其中新考点就是按键的长按和脉冲输入捕获。

按键长按的话,由于我是在定时器中每10ms扫描一次按键,按照题目要求长按时间是2s以上,所以设置一个变量用来计数,如果在按键松开时计数值达到200以上就是长按,否则就是短按。

脉冲捕获,其实就是使用定时器获得一个方波周期的时间,再用定时器频率 / 时间t就可以计算出引脚的输出频率了。

 如图所示,当有上升沿发生就进入中断,开始计时,当下一个上升沿来到时也进入中断,这就可以获得时间t计算出频率,然后再清除t的值,具体看代码。再多使用一个通道捕获下降沿的时间t1,就可以计算出占空比,用高电平的时间t1 / 总的时间t。感兴趣的可以试试,多准备准备,以防下次会考。说完了,那就配置CubeMX吧。

CubeMX配置

时钟配置完了,需要按下回车(Enter)来保存。 

 根据原理图配置GPIO引脚,其中lcd和led的引脚都设置为output,按键设置为input,PB15设置为ADC2的15通道,PA1设置为定时器2的第2通道,PA7设置为定时器17的通道1,需要把PD2也设置为output用来作为led的锁存器。 

 在GPIO中选中按键的引脚,设置为上拉输入模式。 

在GPIO中,选中led的引脚,设置为初始状态为高电平,推挽输出模式,既不上拉也不下拉。其他引脚使用默认设置就是行。

设置定时器3每10ms中断一次。 

 

定时器2的通道2设置为PWM通道2,然后设置预分频器值和自动重装值以及占空比。

开启定时器中断,设置通道1为上升沿的输入捕获。

勾选ADC2的第15通道,其他设置默认就行。 

设置项目名字和保存路径(建议不要有中文),以及IDE的版本。  

 

 勾选这个主要是让.c和.h文件单独分开,之后就可以生成代码了,CubeMX配置就完成了,如果之后想要添加新的模块或者修改配置好了模块的值,可以直接在文件中打开CubeMX的工程进行修改,改完后再点击GENERATE CODE就行了。

代码演示 

main.c

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "main.h"
  22. #include "adc.h"
  23. #include "tim.h"
  24. #include "gpio.h"
  25. /* Private includes ----------------------------------------------------------*/
  26. /* USER CODE BEGIN Includes */
  27. #include "sys.h"
  28. #include "show.h"
  29. #include "lcd.h"
  30. #include "timer.h"
  31. /* USER CODE END Includes */
  32. /* Private typedef -----------------------------------------------------------*/
  33. /* USER CODE BEGIN PTD */
  34. /* USER CODE END PTD */
  35. /* Private define ------------------------------------------------------------*/
  36. /* USER CODE BEGIN PD */
  37. /* USER CODE END PD */
  38. /* Private macro -------------------------------------------------------------*/
  39. /* USER CODE BEGIN PM */
  40. /* USER CODE END PM */
  41. /* Private variables ---------------------------------------------------------*/
  42. /* USER CODE BEGIN PV */
  43. extern uint8_t btn,long_btn; //按键短按值,和key4的长按标志
  44. extern uint32_t f; //是捕获计算的频率
  45. bool choice = 0; //0是参数R,1是参数K
  46. bool fre_flag = 0; //切换高低频模式的锁,为1时不能切换
  47. bool lock = 0; //为1时占空比锁定
  48. char M='L'; //L是低频模式,H是高频模式
  49. uint8_t jm = 0; //0是数据界面,1是参数界面,2记录界面
  50. uint16_t P = 100; //占空比
  51. uint8_t N = 0;
  52. uint8_t R = 1,K = 1;
  53. uint8_t tempR = 1,tempK = 1;
  54. float V = 0.0f,MH = 0.0f,ML = 0.0f;
  55. float Volt = 0.0f;
  56. /* USER CODE END PV */
  57. /* Private function prototypes -----------------------------------------------*/
  58. void SystemClock_Config(void);
  59. /* USER CODE BEGIN PFP */
  60. /* USER CODE END PFP */
  61. /* Private user code ---------------------------------------------------------*/
  62. /* USER CODE BEGIN 0 */
  63. /* USER CODE END 0 */
  64. /**
  65. * @brief The application entry point.
  66. * @retval int
  67. */
  68. int main(void)
  69. {
  70. /* USER CODE BEGIN 1 */
  71. /* USER CODE END 1 */
  72. /* MCU Configuration--------------------------------------------------------*/
  73. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  74. HAL_Init();
  75. /* USER CODE BEGIN Init */
  76. /* USER CODE END Init */
  77. /* Configure the system clock */
  78. SystemClock_Config();
  79. /* USER CODE BEGIN SysInit */
  80. /* USER CODE END SysInit */
  81. /* Initialize all configured peripherals */
  82. MX_GPIO_Init();
  83. MX_ADC2_Init();
  84. MX_TIM2_Init();
  85. MX_TIM3_Init();
  86. MX_TIM17_Init();
  87. /* USER CODE BEGIN 2 */
  88. LCD_Init();
  89. LCD_Clear(Black);
  90. LCD_SetBackColor(Black);
  91. LCD_SetTextColor(White);
  92. HAL_TIM_Base_Start_IT(&htim3);
  93. HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_2);
  94. HAL_TIM_IC_Start_IT(&htim17,TIM_CHANNEL_1);
  95. /* USER CODE END 2 */
  96. /* Infinite loop */
  97. /* USER CODE BEGIN WHILE */
  98. while (1)
  99. {
  100. /* USER CODE END WHILE */
  101. /* USER CODE BEGIN 3 */
  102. Volt = getADC(&hadc2);
  103. V = (f*2*R*3.14f)/(100*K);
  104. switch(btn)
  105. {
  106. case 1:
  107. {
  108. Key1();
  109. btn = 0;
  110. }
  111. break;
  112. case 2:
  113. {
  114. Key2();
  115. btn = 0;
  116. }
  117. break;
  118. case 3:
  119. {
  120. Key3();
  121. btn = 0;
  122. }
  123. break;
  124. case 4:
  125. {
  126. Key4();
  127. btn = 0;
  128. }
  129. break;
  130. }
  131. if(long_btn && 0 == jm)
  132. {
  133. lock = 1;
  134. long_btn = 0;
  135. }
  136. if(0==jm)
  137. DATA();
  138. else if(1==jm)
  139. PARA();
  140. else
  141. RECD();
  142. LED_Hint(); //处理LED
  143. InferDuty(); //调整占空比
  144. InferFre(); //计算最大最小速度值
  145. }
  146. /* USER CODE END 3 */
  147. }
  148. /**
  149. * @brief System Clock Configuration
  150. * @retval None
  151. */
  152. void SystemClock_Config(void)
  153. {
  154. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  155. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  156. RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
  157. /** Configure the main internal regulator output voltage
  158. */
  159. HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
  160. /** Initializes the RCC Oscillators according to the specified parameters
  161. * in the RCC_OscInitTypeDef structure.
  162. */
  163. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  164. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  165. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  166. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  167. RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV3;
  168. RCC_OscInitStruct.PLL.PLLN = 20;
  169. RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  170. RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
  171. RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
  172. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  173. {
  174. Error_Handler();
  175. }
  176. /** Initializes the CPU, AHB and APB buses clocks
  177. */
  178. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  179. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  180. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  181. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  182. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  183. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  184. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  185. {
  186. Error_Handler();
  187. }
  188. /** Initializes the peripherals clocks
  189. */
  190. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC12;
  191. PeriphClkInit.Adc12ClockSelection = RCC_ADC12CLKSOURCE_SYSCLK;
  192. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  193. {
  194. Error_Handler();
  195. }
  196. }
  197. /* USER CODE BEGIN 4 */
  198. /* USER CODE END 4 */
  199. /**
  200. * @brief This function is executed in case of error occurrence.
  201. * @retval None
  202. */
  203. void Error_Handler(void)
  204. {
  205. /* USER CODE BEGIN Error_Handler_Debug */
  206. /* User can add his own implementation to report the HAL error return state */
  207. __disable_irq();
  208. while (1)
  209. {
  210. }
  211. /* USER CODE END Error_Handler_Debug */
  212. }
  213. #ifdef USE_FULL_ASSERT
  214. /**
  215. * @brief Reports the name of the source file and the source line number
  216. * where the assert_param error has occurred.
  217. * @param file: pointer to the source file name
  218. * @param line: assert_param error line source number
  219. * @retval None
  220. */
  221. void assert_failed(uint8_t *file, uint32_t line)
  222. {
  223. /* USER CODE BEGIN 6 */
  224. /* User can add his own implementation to report the file name and line number,
  225. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  226. /* USER CODE END 6 */
  227. }
  228. #endif /* USE_FULL_ASSERT */
  229. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

main.h

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.h
  5. * @brief : Header for main.c file.
  6. * This file contains the common defines of the application.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2023 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __MAIN_H
  22. #define __MAIN_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32g4xx_hal.h"
  28. /* Private includes ----------------------------------------------------------*/
  29. /* USER CODE BEGIN Includes */
  30. #include <stdio.h>
  31. #include <string.h>
  32. #include <stdbool.h>
  33. /* USER CODE END Includes */
  34. /* Exported types ------------------------------------------------------------*/
  35. /* USER CODE BEGIN ET */
  36. /* USER CODE END ET */
  37. /* Exported constants --------------------------------------------------------*/
  38. /* USER CODE BEGIN EC */
  39. /* USER CODE END EC */
  40. /* Exported macro ------------------------------------------------------------*/
  41. /* USER CODE BEGIN EM */
  42. /* USER CODE END EM */
  43. /* Exported functions prototypes ---------------------------------------------*/
  44. void Error_Handler(void);
  45. /* USER CODE BEGIN EFP */
  46. /* USER CODE END EFP */
  47. /* Private defines -----------------------------------------------------------*/
  48. /* USER CODE BEGIN Private defines */
  49. /* USER CODE END Private defines */
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif /* __MAIN_H */

main.h中添加了几个头文件和define。

sys.c

  1. #include "sys.h"
  2. Btn key[4] = {0};
  3. uint8_t btn = 0, long_btn = 0;
  4. uint16_t LED = 0xff00;
  5. extern uint8_t jm;
  6. extern bool L2_flag;
  7. extern bool fre_flag;
  8. extern bool lock, choice;
  9. extern uint8_t R ,K ,N;
  10. extern uint8_t tempR ,tempK;
  11. void LED_SET(void)
  12. {
  13. GPIOC->ODR = (uint32_t)LED;
  14. HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
  15. HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
  16. }
  17. void LED_Hint(void)
  18. {
  19. if(0 == jm)
  20. {
  21. LED &= ~(0x01ff);
  22. LED_SET();
  23. }
  24. else
  25. {
  26. LED |= 0x0100;
  27. LED_SET();
  28. }
  29. if(1 == L2_flag && 1 == fre_flag)
  30. {
  31. LED &= ~(0x02ff);
  32. LED_SET();
  33. }
  34. else
  35. {
  36. LED |= 0x0200;
  37. LED_SET();
  38. }
  39. if(1 == lock)
  40. {
  41. LED &= ~(0x04ff);
  42. LED_SET();
  43. }
  44. else
  45. {
  46. LED |= 0x0400;
  47. LED_SET();
  48. }
  49. }
  50. void KEY_Scan(void)
  51. {
  52. uint8_t i;
  53. key[0].press = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_0);
  54. key[1].press = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_1);
  55. key[2].press = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_2);
  56. key[3].press = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0);
  57. for(i=0;i<4;i++)
  58. {
  59. switch(key[i].state)
  60. {
  61. case 0:
  62. if(key[i].press == 0)
  63. key[i].state = 1;
  64. break;
  65. case 1:
  66. {
  67. if(key[i].press == 0)
  68. {
  69. key[i].state = 2;
  70. btn = i+1;
  71. if(3 == i)
  72. key[i].long_time = 1;
  73. }
  74. else
  75. key[i].state = 0;
  76. }
  77. break;
  78. case 2:
  79. {
  80. if(key[i].press == 1)
  81. {
  82. key[i].state = 0;
  83. if(key[3].long_time>=200)
  84. long_btn = i+1;
  85. else
  86. key[3].long_time++;
  87. }
  88. if(3 == i)
  89. key[3].long_time++;
  90. }
  91. break;
  92. }
  93. }
  94. }
  95. float getADC(ADC_HandleTypeDef *pin)
  96. {
  97. uint16_t adc;
  98. HAL_ADC_Start(pin);
  99. adc = HAL_ADC_GetValue(pin);
  100. return adc*3.3/4096;
  101. }
  102. void Key1(void) //按键1需要完成的功能
  103. {
  104. if(3 == ++jm)
  105. jm = 0;
  106. if(1 == jm)
  107. {
  108. tempR = R;
  109. tempK = K;
  110. }
  111. else // 从参数界面退出时,新的 R 参数和 K 参数生效。
  112. {
  113. R = tempR;
  114. K = tempK;
  115. }
  116. choice = 0;
  117. LCD_Clear(Black);
  118. }
  119. void Key2(void) //按键2需要完成的功能
  120. {
  121. if(0 == jm && 0 == fre_flag)
  122. {
  123. fre_flag = 1;
  124. N++;
  125. }
  126. if(1 == jm)
  127. {
  128. choice ^= 1;
  129. }
  130. }
  131. void Key3(void) //按键3需要完成的功能
  132. {
  133. if(1 == jm)
  134. {
  135. if(0 == choice)
  136. {
  137. if(++tempR>10)
  138. tempR = 1;
  139. }
  140. else
  141. {
  142. if(++tempK>10)
  143. tempK = 1;
  144. }
  145. }
  146. }
  147. void Key4(void) //按键4需要完成的功能
  148. {
  149. if(1 == jm)
  150. {
  151. if(0 == choice)
  152. {
  153. if(--tempR<1)
  154. tempR = 10;
  155. }
  156. else
  157. {
  158. if(--tempK<1)
  159. tempK = 10;
  160. }
  161. }
  162. if(0 == jm)
  163. lock = 0;
  164. }

sys.h

  1. #ifndef __SYS_H
  2. #define __SYS_H
  3. #include "main.h"
  4. #include "lcd.h"
  5. typedef struct{
  6. bool press;
  7. uint8_t state;
  8. uint16_t long_time;
  9. }Btn;
  10. void LED_SET(void);
  11. void LED_Hint(void);
  12. void KEY_Scan(void);
  13. float getADC(ADC_HandleTypeDef *pin);
  14. void Key1(void);
  15. void Key2(void);
  16. void Key3(void);
  17. void Key4(void);
  18. #endif

led使用寄存器,目的是单独控制一个LED灯时不干扰其他LED灯,使用HAL库函数,改变一个灯的值,会干扰到其他灯的显示,有没有好心人在评论区告知一下怎么使用HAL库才不会有这种情况,感谢。  

show.c

  1. #include "show.h"
  2. char text[21] = {0};
  3. extern uint8_t N,R,K;
  4. extern uint16_t P;
  5. extern uint16_t fre;
  6. extern float V,MH,ML;
  7. extern char M;
  8. extern float Volt;
  9. extern bool lock;
  10. extern uint8_t tempR,tempK;
  11. void LCD_SHOW(uint8_t line, char *text)
  12. {
  13. LCD_DisplayStringLine(line*24, (u8 *)text);
  14. }
  15. void DATA(void)
  16. {
  17. sprintf(text," DATA ");
  18. LCD_SHOW(1,text);
  19. sprintf(text," M=%c ",M);
  20. LCD_SHOW(3,text);
  21. sprintf(text," P=%d%% ",P);
  22. LCD_SHOW(4,text);
  23. sprintf(text," V=%.1f ",V);
  24. LCD_SHOW(5,text);
  25. }
  26. void PARA(void)
  27. {
  28. sprintf(text," PARA ");
  29. LCD_SHOW(1,text);
  30. sprintf(text," R=%d ",tempR);
  31. LCD_SHOW(3,text);
  32. sprintf(text," K=%d ",tempK);
  33. LCD_SHOW(4,text);
  34. }
  35. void RECD(void)
  36. {
  37. sprintf(text," RECD ");
  38. LCD_SHOW(1,text);
  39. sprintf(text," N=%d ",N);
  40. LCD_SHOW(3,text);
  41. sprintf(text," MH=%.1f ",MH);
  42. LCD_SHOW(4,text);
  43. sprintf(text," ML=%.1f ",ML);
  44. LCD_SHOW(5,text);
  45. }
  46. void InferDuty(void)//调整占空比
  47. {
  48. if(lock == 0)
  49. {
  50. if(Volt<=1.0f)
  51. {
  52. P = 10*(fre+1)/100;
  53. __HAL_TIM_SET_COMPARE(&htim2,TIM_CHANNEL_2,P);
  54. }
  55. else if(Volt>=3.0f)
  56. {
  57. P = 85*(fre+1)/100;
  58. __HAL_TIM_SET_COMPARE(&htim2,TIM_CHANNEL_2,P);
  59. }
  60. else
  61. {
  62. P = 37.5f*Volt-27.5f;
  63. __HAL_TIM_SET_COMPARE(&htim2,TIM_CHANNEL_2,P*(fre+1)/100);
  64. }
  65. }
  66. }
  67. void InferFre(void)//计算最大最小速度值
  68. {
  69. ML = (4000*2*R*3.14f)/(100*K);
  70. MH = (8000*2*R*3.14f)/(100*K);
  71. }

show.h

  1. #ifndef __SHOW_H
  2. #define __SHOW_H
  3. #include "main.h"
  4. #include "lcd.h"
  5. #include "tim.h"
  6. void LCD_SHOW(uint8_t line, char *text);
  7. void DATA(void);
  8. void PARA(void);
  9. void RECD(void);
  10. void InferDuty(void);
  11. void InferFre(void);
  12. #endif

timer.c

  1. #include "timer.h"
  2. uint16_t CCR1 = 0;
  3. uint32_t fre_CNT = 0;
  4. uint16_t fre = 999;
  5. uint32_t f = 0;
  6. uint8_t L2_CNT = 0;
  7. bool L2_flag = 0;
  8. extern bool fre_flag;
  9. extern char M;
  10. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  11. {
  12. if(htim->Instance == TIM3)
  13. {
  14. KEY_Scan();
  15. if(1 == fre_flag) //高低频模式切换,5秒钟内保证占空比不变,频率每10ms加减一
  16. { //500次刚好完成高低频模式切换需要改变的自动重装载值
  17. if(++fre_CNT>500)
  18. {
  19. fre_flag = 0;
  20. fre_CNT = 0;
  21. if('L' == M)
  22. M = 'H';
  23. else
  24. M = 'L';
  25. }
  26. else
  27. {
  28. if('L' == M)
  29. {
  30. fre--;
  31. __HAL_TIM_SET_AUTORELOAD(&htim2,fre);
  32. }
  33. else
  34. {
  35. fre++;
  36. __HAL_TIM_SET_AUTORELOAD(&htim2,fre);
  37. }
  38. }
  39. if(++L2_CNT>10)
  40. {
  41. L2_flag ^= 1;
  42. L2_CNT = 0;
  43. }
  44. }
  45. }
  46. }
  47. void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
  48. {
  49. /*PWM 信号上升沿时,会进入中断,IC1会捕获,对应的是周期宽度测量*/
  50. if(htim->Instance == TIM17)
  51. {
  52. if(htim->Channel==HAL_TIM_ACTIVE_CHANNEL_1)
  53. {
  54. CCR1 = HAL_TIM_ReadCapturedValue(htim,TIM_CHANNEL_1);
  55. __HAL_TIM_SetCounter(htim,0);
  56. f = (80000000/80)/(CCR1+1);
  57. HAL_TIM_IC_Start(htim,TIM_CHANNEL_1);
  58. }
  59. }
  60. }

timer.h

  1. #ifndef __TIMER_H
  2. #define __TIMER_H
  3. #include "main.h"
  4. #include "tim.h"
  5. #include "sys.h"
  6. #endif

以上就是我修改过的文件和新添加的文件。还有lcd模块,不过不需要我们自己写,官方有提供,直接复制过来就行,注意有三个文件,别只复制lcd.c和lcd.h。

好了,以上就是蓝桥杯嵌入式第十四届省赛的题目解析了,如果有什么问题和建议都欢迎在评论区提出来喔。 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/506493
推荐阅读
相关标签
  

闽ICP备14008679号