如题,通过USB转串口,发送数据,INI脚一直处于高电平状态,不响应中断程序
热门产品 :
CH397: 高集成度、低功耗USB网卡芯片
如题,通过USB转串口,发送数据,INI脚一直处于高电平状态,不响应中断程序
您好,您可以看一下你使用的串口的IER寄存器与MCR寄存器配置是否正确。如果想要发送报中断的话,那么IER寄存器的IETHRE位必须设置为1,这样才会允许发送保存寄存器空中断。其次MCR寄存器的OUT2位要设置为1,这样该串口的中断才会有低电平的输出。
串口的IER和MCR寄存器均参照51Demo移植,使能了IER中断接收和MCR中断输出,发送数据还是产生不了中断
以下为串口初始化配置:
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); }
那您可以看一下您的接口时序是否正确,您可以发送数据到SCR寄存器,再读取看是否为刚刚写入的数据,如果不一致,则表示时序有问题。