使用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);