FR8018H 芯片的串口1中断数据接收问题
-
打开了
system_set_port_pull (GPIO_PA2, true) :
system_set_port_mux(GPIO_PORT_A, GPIO_BIT_2, PORTA2_FUNC_UARTI_RXD) ;
system_set_port_mux(GPIO_PORT_A,GPIO_BIT 3,PORTA3_FUNC_UARTI_TXD) ;
uart_init(UART1,BAUD_RATE_57600):NVIC_EnableIRQ(UART1_IROn):
-
void uart1_init(void)
{
system_set_port_pull(GPIO_PA2, true);
system_set_port_mux(GPIO_PORT_A, GPIO_BIT_2, PORTA2_FUNC_UART1_RXD);
system_set_port_mux(GPIO_PORT_A, GPIO_BIT_3, PORTA3_FUNC_UART1_TXD);
uart_param_t param =
{
.baud_rate = 115200,
.data_bit_num = 8,
.pari = 0,
.stop_bit = 1,
};
uart_init1(UART1,param);
NVIC_EnableIRQ(UART1_IRQn);
NVIC_SetPriority(UART1_IRQn, 3);
}
-
@mars 改了还是一样。中断函数有问题吗。
attribute((section("ram_code"))) void uart1_isr_ram(void)
{
uint8_t int_id;
uint8_t c;
volatile struct uart_reg_t * const uart_reg_ram = (volatile struct uart_reg_t )UART1_BASE;
int_id = uart_reg_ram->u3.iir.int_id;
if(int_id == 0x04 || int_id == 0x0c ) / Receiver data available or Character time-out indication */
{
c = uart_reg_ram->u1.data;
}
else if(int_id == 0x06)
{
volatile uint32_t line_status = uart_reg_ram->lsr;
}
}
-
不进中断还是什么
attribute((section("ram_code"))) void uart1_isr_ram(void)
{
uint8_t int_id;
volatile uint8_t c;
volatile struct uart_reg_t *uart_reg = (volatile struct uart_reg_t *)UART1_BASE;int_id = uart_reg->u3.iir.int_id; if(int_id == 0x04 || int_id == 0x0c ) /* Receiver data available or Character time-out indication */ { c = uart_reg->u1.data; uart_putc_noint(UART1,c); // 串口输出 接收的数据 } else if(int_id == 0x06) { volatile uint32_t line_status = uart_reg->lsr; }
}
-
@mars 上电时PC发数据,会有回,但当我调接口发送数据后,感觉就没有进中断了。PC端发数据都没有回。
-
串口1的PA2和PA3打印可以改成串口0 的PD0和PD1打印吗?
-
@rain 可以,把之前的串口引脚配置会io口,然后重新初始化PD口为串口
-
@mars 改了PD口串口初始化,但是打印没有任何反应。这几个参数需要改吗?
#define SYSTEM_OPTION_PRINT_UART0 0x00//
#define SYSTEM_OPTION_PRINT_UART1 CO_BIT(6)
#define SYSTEM_OPTION_PRINT_SWO CO_BIT(7)
#define SYSTEM_OPTION_PRINT_MASK (CO_BIT(6)|CO_BIT(7))
-
@Rain 用我这个改成你的PD口就好了
-
@rain 你怎么判断没有进中断呢