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.

语句阻塞运行



请问TI工程师:

         下面这3个函数,读SPI数据  ,是不是阻塞其他中断的执行的,必须整体运行完才可以 接收其他中断函数处理?

         SPI_transmitData(EUSCI_B2_BASE, 0XAA);
        while (!(SPI_getInterruptStatus(EUSCI_B2_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
        inBuffers[i] = SPI_receiveData(EUSCI_B2_BASE);

  • 请问您现在使用的是哪款芯片?MSP432?

    The UCRXIFG interrupt flag is set each time a character is received and loaded into UCxRXBUF. An interrupt request is generated if UCRXIE is set. UCRXIFG and UCRXIE are reset by a Hard Reset or when UCSWRST = 1. UCRXIFG is automatically reset when UCxRXBUF is read.

    理论上是可以被打断的,但最好是不要打断SPI中断。所以之前都是在通讯过程中关闭全程中断,然后再打开。

    例程内的中断服务程序如下

    //******************************************************************************
    //
    //This is the EUSCI_B0 interrupt vector service routine.
    //
    //******************************************************************************
    void EUSCIB0_IRQHandler(void)
    {
        uint32_t status;
    
        status = SPI_getEnabledInterruptStatus(EUSCI_B0_BASE);
        SPI_clearInterruptFlag(EUSCI_B0_BASE, status);
    
        if(status & EUSCI_B_SPI_RECEIVE_INTERRUPT)
        {
            /* USCI_B0 TX buffer ready? */
            while (!(SPI_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_SPI_TRANSMIT_INTERRUPT)));
    
            /* Transmit data to master */
            SPI_transmitData(EUSCI_B0_BASE, transmitData++);
    
            //Receive data from master
            receiveData = SPI_receiveData(EUSCI_B0_BASE);
        }
    }

  • 是的·  我使用MSP432P4011 处理器  

    因为在处理上面SPI数据是   我有个最高优先级的定时器 采样  ,如果定时到  需要准确触发内置 AD   所以 这个函数 必须需要打断才行。

    同时 我的程序是 SPI是接的外置AD芯片

    所以  当外置AD有数据可读  就在IO口下降沿中断中 执行  读SPI 的外置AD数据。即这个SPI读数据函数 是在IO口下降沿中断中

    请教Susan Yang  这种应用有没有问题~

  • 理论上是没有问题的

    设置中断优先级:
    Interrupt_setPriority(uint32_t interruptNumber, uint8_t priority)
    interruptNumber:中断号
    priority:优先级别