Part Number:AM5728
我想要通过串口接收数据,使用UART_read()接收数据,则必须实时调用UART_read()才能收到数据,故想到使用Hwi_create()接口创建硬件中断,但是如何关联到串口的接收中断呢?
Shine:
请参考下面帖子里的文档。https://e2e.ti.com/support/processors-group/processors/f/processors-forum/940874/faq-tms320c6678-how-to-configure-interrupts-on-ti-keystone-devices
,
zy zhao:
void hwiFunc(UArg arg) {unsigned charrxData= 0;//在中断服务程序中清中断//Hwi_clearInterrupt(7);/* Checking ths source of UART interrupt. */int32_t intId = UARTIntIdentityGet(SOC_UART1_BASE);Log_print1(Diags_ENTRY, "UARTIsr: %d", intId);switch (intId){case UART_INTID_TX_THRES_REACH:Log_print0(Diags_ENTRY, "UART_INTID_TX_THRES_REACH");break;case UART_INTID_RX_THRES_REACH:rxData = UARTCharGetNonBlocking(SOC_UART1_BASE);//UARTCharPutNonBlocking(uartBaseAddr, rxByte);Log_print1(Diags_ENTRY, "Rx: %02x", rxData);break;case UART_INTID_RX_LINE_STAT_ERROR:case UART_INTID_CHAR_TIMEOUT:rxData = UARTCharGetNonBlocking(SOC_UART1_BASE);if(intId == UART_INTID_CHAR_TIMEOUT)Log_print1(Diags_ENTRY, "UART_INTID_CHAR_TIMEOUT: %02x", rxData);elseLog_print1(Diags_ENTRY, "UART_INTID_RX_LINE_STAT_ERROR: %02x", rxData);break;default:break;} }void Hwi_Init(void) {Log_print0(Diags_ENTRY, "Hwi_Init");//创建中断Hwi_Handle hwi_uart1;//句柄Hwi_Params hwi_params;//传入参数Error_Block eb;//错误块Error_init(&eb);//错误块初始化,注意必须初始化,否则易进入System_abortHwi_Params_init(&hwi_params); //初始化传入参数hwi_params.eventId = 43;hwi_params.enableInt = TRUE;//hwi_params.maskSetting = Hwi_MaskingOption_SELF;// don't allow this interrupt to nest itselfhwi_uart1 = Hwi_create(7, hwiFunc, &hwi_params, &eb); //注意此处id是中断等级编号,如中断5,则id为5if(hwi_uart1 == NULL){System_abort("hwi_uart1 create failed");}Hwi_enableInterrupt(7);//使能中断 }我创建中断后,一直不能进入中断服务函数,串口这边的配置应该如何设置呢?是调用 PDK_INSTALL_PATH\packages\ti\csl\src\ip\uart\V1\uart.h 还是使用
PDK_INSTALL_PATH\packages\ti\drv\uart\UART.h 的库函数配置串口?
,
Shine:
请查看一下寄存器,看中断标志位有没有置起来?中断使能位有没有使能?