使用 W806 的 UART2, 修改 main. c 更改 UART1 修改 UART2, 然后在 wm_hal_msp. c 修改管脚与与中断如下:
void HAL_UART_MspInit (UART_HandleTypeDef* huart)
{
if (huart-" Instance == UART2)
{
__HAL_RCC_UART2_CLK_ENABLE () ;
__HAL_RCC_GPIO_CLK_ENABLE () ;
// PB6: UART2_TX
// PB7: UART2_RX
__HAL_AFIO_REMAP_UART2_TX (GPIOB, **GPIO_PIN_2**) ;
__HAL_AFIO_REMAP_UART2_RX (GPIOB, **GPIO_PIN_3**) ;
HAL_NVIC_SetPriority (**UART2_5_IRQn**, 0) ;
HAL_NVIC_EnableIRQ (UART2_5_IRQn) ;
}
}
void HAL_UART_MspDeInit (UART_HandleTypeDef* huart)
{
if (huart-" Instance == UART2)
{
__HAL_RCC_UART2_CLK_DISABLE () ;
HAL_GPIO_DeInit (**GPIOB, GPIO_PIN_2|GPIO_PIN_3**) ;
}
}
从 uart2 发送, 然后出现错误, 在 UART0 出现错误信息.
UART0 打印的信息 CPU
Exception : 51
r0: 00000000 r1: 00000213 r2: 40010a00 r3: 00000000 r4: 200020c0
r5: 00000000 r6: 00000000 r7: 200101ac r8: 18ff41b7 r9: 0e7e06af
r10: c89d0b11 r11: 2315a0cc r12: 00000003 r13: ffff00ff r14: 200010ec
已经修改过了是这样吗?
__attribute__ ( (isr) ) void CORET_IRQHandler (void)
{
readl (0xE000E010) ;
HAL_IncTick () ;
}
extern UART_HandleTypeDef huart2;
__attribute__ ( (isr) ) void UART2_4_IRQHandler (void)
{
HAL_UART_IRQHandler (&huart2) ;
}
wm_it. c 已经修改过了是这样吗?
include "wm_hal. h"
define readl (addr) ({unsigned int __v = ( (volatile unsigned int ) (addr) ) ; __v; })
__attribute__ ( (isr) ) void CORET_IRQHandler (void)
{
readl (0xE000E010) ;
HAL_IncTick () ;
}
extern UART_HandleTypeDef huart2;
__attribute__ ( (isr) ) void UART2_IRQHandler (void)
{
HAL_UART_IRQHandler (&huart2) ;