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.

TMS320F280049C: SCI持续发送时导致程序跑死

Part Number: TMS320F280049C

串口调试时,我利用串口助手自动发送获得响应

但随时间运行一段时间后我发现程序不再响应了,我的主程序的运行灯也不再工作,但用示波器测得硬件PWM是正常输出的

我的串口初始化函数为:

void HAL_setupSCI(void)
{
    //
    // 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);

    //
    // 配置中断服务函数
    //
    Interrupt_register(INT_SCIA_RX, &sciaRxISR);

    //
    // 初始化SCIA和它的FIFO
    //
    SCI_performSoftwareReset(SCIA_BASE);

    //
    // 50000000 is the LSPCLK or the Clock used for the SCI Module
    // 57600 is the Baudrate desired of the SCI module
    // 1 stop bit,  No parity, 8 char bits,
    //
    SCI_setConfig(SCIA_BASE, LSPCLK_FREQ_H, 38400,
            (SCI_CONFIG_WLEN_8 |
                    SCI_CONFIG_STOP_ONE |
                    SCI_CONFIG_PAR_NONE));


    //
    //No loopback
    //
    SCI_disableLoopback(SCIA_BASE);

    SCI_resetChannels(SCIA_BASE);
    SCI_resetRxFIFO(SCIA_BASE);
    SCI_clearInterruptStatus(SCIA_BASE,SCI_INT_RXFF);
    SCI_enableFIFO(SCIA_BASE);
    SCI_enableModule(SCIA_BASE);
    SCI_performSoftwareReset(SCIA_BASE);

    //
    // Set the transmit FIFO level to 0 and the receive FIFO level to 2.
    // Enable the TXFF and RXFF interrupts.
    //
    SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX0, SCI_FIFO_RX1);
    SCI_enableInterrupt(SCIA_BASE,SCI_INT_RXFF);

    //
    // Clear the SCI interrupts before enabling them.
    //
    SCI_clearInterruptStatus(SCIA_BASE,SCI_INT_RXFF);

    //
    // Enable the interrupts in the PIE: Group 9 interrupts 1 & 2.
    //
    Interrupt_enable(INT_SCIA_RX);
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}

接收中断函数为:

interrupt void sciaRxISR(void)
{
    //
    // Read characters from the FIFO.
    //
//    SciRxBuf[SciRxPointHead] = SCI_readCharBlockingFIFO(SCIA_BASE);
    SciRxBuf[SciRxPointHead] = SCI_readCharNonBlocking(SCIA_BASE);

    SciRxPointHead ++;
    if (SciRxPointHead == RxLen)
        SciRxPointHead = 0;
    GPIO_togglePin(TTPLPFC_GPIO_LED1);
    //
    // Clear the SCI RXFF interrupt and acknowledge the PIE interrupt.
    //
    SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF);
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);

}

发送函数为:

void SendMessageToSCI(uint32_t base, unsigned char *msg)
{
    uint16_t msg_len = 0;
    while (msg[msg_len] != 0) {
        SciTxBuf[SciTxPointHead] = msg[msg_len];
        SciTxPointHead ++;
        if (SciTxPointHead == TxLen)
            SciTxPointHead = 0;
        msg_len ++;
    }

    SCI_writeCharArray(base,(const uint16_t *)SciTxBuf,SciTxPointHead);

    SciTxPointEnd = SciTxPointHead = 0;
    memset(SciTxBuf,0,TxLen);
}

不使用自动发送,缓慢调试时不会出问题,但是换成自动发送程序就会出错,请问是什么原因?