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.

[参考译文] MSP432E411Y:Code Composer 的 SPI 配置问题

Guru**** 657500 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1058239/msp432e411y-spi-config-problem-with-code-composer

器件型号:MSP432E411Y

你好

我在 Code Composer Studio 10.4中为 RFID RC522扫描器设置 SPI 时遇到一些问题、它说我所有与 UCB0相关的代码都未定义、 我尝试使用我发现的代码、尝试了解如何为 RFID 设置3引脚 SPI 通信。  我不确定它是否存在语法问题、我使用书籍作为参考、但它没有帮助、因为它使用相同的寄存器名称   

#include "msp.h"
#include "spi.h"

unsigned char RXData;

unsigned char TXData;

int main(void)

{

  volatile uint32_t i;

   WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // Stop watchdog timer

  P1->SEL0 |= BIT5 | BIT6 | BIT7; // set 3-SPI pin as second function

 __enable_interrupt();

  NVIC->ISER[0] = 1 << ((INT_EUSCIB0 - 16) & 31); // Enable eUSCIB0 interrupt in NVIC module

  UCB0CTLW0 |= UCSWRST; // **Put state machine in reset**

  UCB0CTLW0 |= UCMST|UCSYNC|UCCKPL|UCMSB; // 3-pin, 8-bit SPI master

  // Clock polarity high, MSB

  UCB0CTLW0 |= UCSSEL__ACLK;            // ACLK

  UCB0BR0 = 0x02; // /2,fBitClock = fBRCLK/(UCBRx+1).

  UCB0BR1 = 0; //

 UCB0IE |= UCRXIE;

  UCB0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**

  TXData = 0x01; // Holds TX data

  while(1)

  {

    UCB0IE |= UCTXIE; // Enable TX interrupt

   for (i = 2000; i > 0; i--); // Delay before next transmission

   TXData++; // Increment transmit data

   }

}

// SPI interrupt service routine

void eUSCIB0IsrHandler(void)

{

if (UCB0IFG & UCTXIFG)

UCB0TXBUF = TXData; // Transmit characters

UCB0IE &= ~UCTXIE;

while (!(UCB0IFG & UCRXIFG));

RXData = UCB0RXBUF;