This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好:
我参考的是官方的sci_ex2_loopback_interrupts.c例程进行串口收发的调试,经过测试发现无法进入接收中断服务函数,代码如下:
uint16_t sDataA[2]; uint16_t rDataA[2]; // // Function Prototypes // __interrupt void sciaTxISR(void); __interrupt void sciaRxISR(void); // // Main // void main(void) { uint16_t i; // // Configure PLL, disable WD, enable peripheral clocks. // Device_init(); // // Disable pin locks and enable internal pullups. // Device_initGPIO(); // // GPIO28 is the SCI Rx pin. // GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA); GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN); GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC); // // GPIO29 is the SCI Tx pin. // GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA); GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT); GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD); GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC); // // Disable global interrupts. // // DINT; // // Initialize interrupt controller and vector table. // Interrupt_initModule(); Interrupt_initVectorTable(); // // Map the ISR to the wake interrupt. // Interrupt_register(INT_SCIA_TX, sciaTxISR); Interrupt_register(INT_SCIA_RX, sciaRxISR); // // Initialize SCIA and its FIFO. // SCI_performSoftwareReset(SCIA_BASE); // // Configure SCIA for echoback. // SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 | SCI_CONFIG_STOP_ONE | SCI_CONFIG_PAR_NONE)); SCI_enableModule(SCIA_BASE); SCI_disableLoopback(SCIA_BASE); SCI_resetChannels(SCIA_BASE); SCI_enableFIFO(SCIA_BASE); SCI_enableInterrupt(SCIA_BASE, (SCI_INT_RXFF | SCI_INT_TXFF)); SCI_disableInterrupt(SCIA_BASE, SCI_INT_RXERR); SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX2, SCI_FIFO_RX2); SCI_performSoftwareReset(SCIA_BASE); SCI_resetTxFIFO(SCIA_BASE); SCI_resetRxFIFO(SCIA_BASE); for(i = 0; i < 2; i++) { sDataA[i] = i + 1; } #ifdef AUTOBAUD // // Perform an autobaud lock. // SCI expects an 'a' or 'A' to lock the baud rate. // SCI_lockAutobaud(SCIA_BASE); #endif // // Clear the SCI interrupts before enabling them. // SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF | SCI_INT_RXFF); // // Enable the interrupts in the PIE: Group 9 interrupts 1 & 2. // Interrupt_enable(INT_SCIA_RX); Interrupt_enable(INT_SCIA_TX); Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9); // // Enable global interrupts. // EINT; ERTM; for(;;) { } } // // sciaTxISR - Disable the TXRDY interrupt and print message asking // for a character. // __interrupt void sciaTxISR(void) { // // Disable the TXRDY interrupt. // SCI_disableInterrupt(SCIA_BASE, SCI_INT_TXFF); SCI_writeCharArray(SCIA_BASE, sDataA, 2); // // Ackowledge the PIE interrupt. // SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF); Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9); } // // sciaRxISR - Read the character from the RXBUF and echo it back. // __interrupt void sciaRxISR(void) { // // Read a character from the RXBUF. // SCI_readCharArray(SPIA_BASE,rDataA,2); // // Acknowledge the PIE interrupt. // SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF); Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9); }
我打断点发现,在完成SCI_enableFIFO(SCIA_BASE)后,SCIFFPE变成了1,并且后面的复位操作并没有消除该错误标志。
麻烦您帮忙看看我的程序是否存在问题,谢谢!
您好,现在问题解决了,出现无法进入接收中断的原因是因为我遗漏了485的使能接收引脚的操作。上文中的程序还有一个问题就是接受中断服务函数中,第154行,SCIA_BASE打成了SPIA_BASE。