stm32的HAL库中存在的BUG
1.STM32Cube FW_F1 V1.8.0 的stm32f1xx_hal_tim.h 中1744行的宏定义
#define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP))):\
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P)) :\
((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P)))
红色部分多了一个括号
2.stm32f103c8t6串口在使用时,8位数据位+偶校验 是无法正常输出数据的,必须设置为9位数据位+偶校验
1 static void MX_USART3_UART_Init(void) 2 { 3 4 /* USER CODE BEGIN USART3_Init 0 */ 5 6 /* USER CODE END USART3_Init 0 */ 7 8 /* USER CODE BEGIN USART3_Init 1 */ 9 10 /* USER CODE END USART3_Init 1 */ 11 huart3.Instance = USART3; 12 huart3.Init.BaudRate = 9600; 13 huart3.Init.WordLength = UART_WORDLENGTH_9B; 14 huart3.Init.StopBits = UART_STOPBITS_1; 15 huart3.Init.Parity = UART_PARITY_EVEN; 16 huart3.Init.Mode = UART_MODE_TX_RX; 17 huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; 18 huart3.Init.OverSampling = UART_OVERSAMPLING_16; 19 if (HAL_UART_Init(&huart3) != HAL_OK) 20 { 21 Error_Handler(); 22 } 23 /* USER CODE BEGIN USART3_Init 2 */ 24 25 /* USER CODE END USART3_Init 2 */ 26 27 }
static void MX_USART3_UART_Init(void){
/* USER CODE BEGIN USART3_Init 0 */
/* USER CODE END USART3_Init 0 */
/* USER CODE BEGIN USART3_Init 1 */
/* USER CODE END USART3_Init 1 */ huart3.Instance = USART3; huart3.Init.BaudRate = 9600; huart3.Init.WordLength = UART_WORDLENGTH_9B; huart3.Init.StopBits = UART_STOPBITS_1; huart3.Init.Parity = UART_PARITY_EVEN; huart3.Init.Mode = UART_MODE_TX_RX; huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart3.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&huart3) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART3_Init 2 */
/* USER CODE END USART3_Init 2 */
}