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.

msp430 spi uart

MSP430  我想问下如果 spi 或uart正在发送数据,被其他中断打断,中断完成后,和设备通信还能是正常的吗?需不需要在和设备通讯前关闭中断,完成后再打开中断?

  • msp430默认的是没有中断嵌套的。只要您不在中断服务程序里使能总中断,中断服务程序是不会被打断的。
  • 我是说比如SPI正在写TF卡的过程中 ,突然来个定时中断,定时中断处理完后,再去写TF卡 ,TF卡会不会响应.会不超时

  • 这个不会影响的啊,SPI是独立与内核工作的,内核给他指令去发送或接受,它就独立于内核工作了。定时器产生中断,内核去响应,不会影响SPI的工作的啊
  • void SDCard_sendFrame(uint8_t *pBuffer, uint16_t size)
    {
    uint16_t gie = __get_SR_register() & GIE; // Store current GIE state

    __disable_interrupt(); // Make this operation atomic

    // Clock the actual data transfer and send the bytes. Note that we
    // intentionally not read out the receive buffer during frame transmission
    // in order to optimize transfer speed, however we need to take care of the
    // resulting overrun condition.
    while (size--){
    while (!(UCB1IFG & UCTXIFG)) ; // Wait while not ready for TX
    UCB1TXBUF = *pBuffer++; // Write byte
    }
    while (UCB1STAT & UCBUSY) ; // Wait for all TX/RX to finish

    UCB1RXBUF; // Dummy read to empty RX buffer
    // and clear any overrun conditions

    __bis_SR_register(gie); // Restore original GIE state
    }
    这是TI官方 SPI写数据时关闭了中断
x 出现错误。请重试或与管理员联系。