关于stm32g030c8t6使用过程钟踩过的坑

最近使用STM32G030来做项目,使用的过程发现有太多的坑了,折腾自己快要崩溃,主要问题还是初始化的过程中初始化失败,导致程序不运行。

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

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

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

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

/* USER CODE BEGIN Init /
/
Configure the system clock to 56 MHz /
/
USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals /
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_USART2_UART_Init();
MX_IWDG_Init();
MX_USART1_UART_Init();
/
USER CODE BEGIN 2 */
LED_Config();
Lcd_Init();
Clear_Screen();
Show_Picture();/开机显示logo/
Wireless_Mode_Config();

Flash_Init();
if (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
{
/* Calibration Error */
while(1);
}
if (HAL_ADC_Start_DMA(&hadc1,(uint32_t )ADC_ConvertedValue,7) != HAL_OK)
{
/
ADC conversion start error */
while(1);
}
HAL_ADC_Start(&hadc1);

你可能感兴趣的:(C,stm32)