新手上路
- 积分
- 20
- 金钱
- 20
- 注册时间
- 2026-3-17
- 在线时间
- 4 小时
|
1金钱
我按照网上找到的方法设置串口中断,FreeRTOS任务可以执行,但中断不能执行,请高手指点......
extern XScuGic xInterruptController; //中断控制器驱动程序实例
XUartPs Uart_Ps1; //串口驱动程序实例
int main()
{
...
}
static void prvUartIntTestTask( void *pvParameters )
{
const TickType_t x1second = pdMS_TO_TICKS(DELAY_1_SECOND);
uart_int_init(&Uart_Ps1,&xInterruptController); //串口及中断初始化
for(;;)
{
vTaskDelay( x1second );
}
}
//UART及中断初始化函数
int uart_int_init(XUartPs* uart_ps,XScuGic *intc)
{
int status;
XUartPs_Config *uart_cfg;
uart_cfg = XUartPs_LookupConfig(UART_DEVICE_ID);
if (NULL == uart_cfg)
return XST_FAILURE;
status = XUartPs_CfgInitialize(uart_ps, uart_cfg, uart_cfg->BaseAddress);
if (status != XST_SUCCESS)
return XST_FAILURE;
//UART设备自检
status = XUartPs_SelfTest(uart_ps);
if (status != XST_SUCCESS)
return XST_FAILURE;
//设置工作模式:正常模式
XUartPs_SetOperMode(uart_ps, XUARTPS_OPER_MODE_NORMAL);
//设置波特率:115200
XUartPs_SetBaudRate(uart_ps,115200);
//设置RxFIFO的中断触发等级
XUartPs_SetFifoThreshold(uart_ps, 1);
//为中断设置中断处理函数
XScuGic_Connect(intc, UART_INT_IRQ_ID,
(Xil_ExceptionHandler) uart_intr_handler,(void *) uart_ps);
//设置UART的中断触发方式
XUartPs_SetInterruptMask(uart_ps, XUARTPS_IXR_RXOVR);
//设置中断优先级:0x00代表最高优先级;0x1代表电平触发;0x3代表上升沿触发
XScuGic_SetPriorityTriggerType(intc,UART_INT_IRQ_ID,8,0x1);
//使能GIC中的串口中断
XScuGic_Enable(intc, UART_INT_IRQ_ID);
XUartPs_EnableUart(uart_ps);
return XST_SUCCESS;
}
|
|