如題,通過USB轉(zhuǎn)串口,發(fā)送數(shù)據(jù),INI腳一直處于高電平狀態(tài),不響應(yīng)中斷程序
熱門產(chǎn)品 :
CH397: 高集成度、低功耗USB網(wǎng)卡芯片
如題,通過USB轉(zhuǎn)串口,發(fā)送數(shù)據(jù),INI腳一直處于高電平狀態(tài),不響應(yīng)中斷程序
您好,您可以看一下你使用的串口的IER寄存器與MCR寄存器配置是否正確。如果想要發(fā)送報中斷的話,那么IER寄存器的IETHRE位必須設(shè)置為1,這樣才會允許發(fā)送保存寄存器空中斷。其次MCR寄存器的OUT2位要設(shè)置為1,這樣該串口的中斷才會有低電平的輸出。
串口的IER和MCR寄存器均參照51Demo移植,使能了IER中斷接收和MCR中斷輸出,發(fā)送數(shù)據(jù)還是產(chǎn)生不了中斷
以下為串口初始化配置:
void?CH438_Uart_Init(unsigned?char?num,unsigned?long?value) { ????CH438_Uart_SetBandrate(num,?value); ????CH438_Uart_TranConfig(num); ????CH438_Uart_INTConfig(num); } void?CH438_Uart_SetBandrate(unsigned?char?num,?unsigned?long?value) { ????uint16_t?div; ????uint8_t?DLL,?DLM; ???? ????div?=?Fpclk/16/value; ????DLM?=?div>>8; ????DLL?=?div&0xff; ???? ????CH438_WriteReg(offsetadd[num]|REG_LCR_ADDR,?BIT_LCR_DLAB); ????CH438_WriteReg(offsetadd[num]|REG_DLL_ADDR,?DLL); ????CH438_WriteReg(offsetadd[num]|REG_DLM_ADDR,?DLM); } void?CH438_Uart_TranConfig(unsigned?char?num) { ????CH438_WriteReg(offsetadd[num]|REG_FCR_ADDR,?BIT_FCR_RECVTG1?|?BIT_FCR_RECVTG0?|?BIT_FCR_FIFOEN); ???? ????CH438_WriteReg(offsetadd[num]|REG_LCR_ADDR,?BIT_LCR_WORDSZ1?|?BIT_LCR_WORDSZ0); } void?CH438_Uart_INTConfig(unsigned?char?num) { ????CH438_WriteReg(offsetadd[num]|REG_IER_ADDR,BIT_IER_IELINES?|?BIT_IER_IETHRE?|?BIT_IER_IERECV); ????CH438_WriteReg(offsetadd[num]|REG_MCR_ADDR,BIT_MCR_OUT2/*?|?BIT_MCR_RTS?|?BIT_MCR_DTR*/); ????CH438_WriteReg(offsetadd[num]|REG_FCR_ADDR,?CH438_ReadReg(offsetadd[num]|REG_FCR_ADDR)|?BIT_FCR_TFIFORST?|?BIT_FCR_RFIFORST); }
那您可以看一下您的接口時序是否正確,您可以發(fā)送數(shù)據(jù)到SCR寄存器,再讀取看是否為剛剛寫入的數(shù)據(jù),如果不一致,則表示時序有問題。