1. Después de usar HAL para generar código, si se usa el puerto serie, el programa no puede ejecutarse normalmente
**Solución: **Abra la configuración de Keil, verifique MicroLIB y luego vuelva a compilar.
2. Cuando la interrupción del temporizador de tictac se usa en HAL, debe agregarse void SysTick_Handler(void)
a stm32f4xx_it.c HAL_SYSTICK_IRQHandler();
para que sea HAL_SYSTICK_Callback(void)
efectiva.
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
HAL_SYSTICK_IRQHandler();
/* USER CODE END SysTick_IRQn 1 */
}
void HAL_SYSTICK_Callback(void)//系统时钟回调函数
{
}
3. Definición de valor absoluto en Keil
#define ABS(x) ((x)>=0?(x):-(x))
4. Bucle simple de microsegundos en keil
/*
for循环实现延时us
*/
void for_delay_us(uint32_t nus)
{
uint32_t Delay = nus * 168/4;
do
{
__NOP();
}
while (Delay --);
}