你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【经验分享】关于stm32g030c8t6使用过程钟踩过的坑

[复制链接]
STMCU小助手 发布时间:2021-11-10 18:02
最近使用STM32G030来做项目,使用的过程发现有太多的坑了,折腾自己快要崩溃,主要问题还是初始化的过程中初始化失败,导致程序不运行。

现在总结下遇到的问题:
1.ADC使用多通道扫描模式用DMA传输数据,HAL_ADC_Start(&hadc1);这个开始必须要放在DMA初始化相关函数的后面。
2.开启串口中断后导致程序异常不运行,最后把开启传偶中断函数放在main函数的最前面就可以正常运行
3.程序是按顺序上之下运行,初始化时候要考虑好顺序关系。

比如按下面的顺序进行初始化才可以正常的运行
  1. /* USER CODE BEGIN 1 /
  2. / STM32G0xx HAL library initialization:
  3. - Configure the Flash prefetch
  4. - Systick timer is configured by default as source of time base, but user
  5. can eventually implement his proper time base source (a general purpose
  6. timer for example or other time source), keeping in mind that Time base
  7. duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
  8. handled in milliseconds basis.
  9. - Low Level Initialization
  10. */

  11. /* USER CODE END 1 */

  12. /* MCU Configuration--------------------------------------------------------*/

  13. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  14. HAL_Init();
  15. Enable_IT_Uart_Fun();

  16. /* USER CODE BEGIN Init /
  17. / Configure the system clock to 56 MHz /
  18. / USER CODE END Init */

  19. /* Configure the system clock */
  20. SystemClock_Config();

  21. /* USER CODE BEGIN SysInit */

  22. /* USER CODE END SysInit */

  23. /* Initialize all configured peripherals /
  24. MX_GPIO_Init();
  25. MX_DMA_Init();
  26. MX_ADC1_Init();
  27. MX_USART2_UART_Init();
  28. MX_IWDG_Init();
  29. MX_USART1_UART_Init();
  30. / USER CODE BEGIN 2 */
  31. LED_Config();
  32. Lcd_Init();
  33. Clear_Screen();
  34. Show_Picture();/开机显示logo/
  35. Wireless_Mode_Config();

  36. Flash_Init();
  37. if (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
  38. {
  39. /* Calibration Error */
  40. while(1);
  41. }
  42. if (HAL_ADC_Start_DMA(&hadc1,(uint32_t )ADC_ConvertedValue,7) != HAL_OK)
  43. {
  44. / ADC conversion start error */
  45. while(1);
  46. }
  47. HAL_ADC_Start(&hadc1);

复制代码


收藏 评论0 发布时间:2021-11-10 18:02

举报

0个回答

所属标签

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版