Dear All,
I try to use the P3.4~P3.6 as SPI2 interface and the code is in the following. But it doesn't work as I expected. Does anyone know what I have missing in the configuration? Thank you.
Xview.
=======================================
// Pins from MSP432 connected to the SD Card
#define SD_SOMI BIT7
#define SD_SIMO BIT6
#define SD_CLK BIT5
#define SD_CS BIT4
// Ports
#define SD_SPI_SEL P3->SEL0
#define SD_SPI_DIR P3->DIR
#define SD_SPI_OUT P3->OUT
#define SD_CS_OUT P3->OUT
#define SD_CS_DIR P3->DIR
#define SD_EUSCI EUSCI_B2
void SDCard_init(void)
{
SD_SPI_SEL |= SD_CLK + SD_SOMI + SD_SIMO;
SD_SPI_DIR |= SD_CLK + SD_SIMO;
SD_SPI_OUT |= SD_SOMI; // Certain SD Card Brands need pull-ups
SD_CS_DIR |= SD_CS;
SD_CS_OUT |= SD_CS;
SD_EUSCI->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put eUSCI state machine in reset
SD_EUSCI->CTLW0 = EUSCI_B_CTLW0_SWRST | // Remain eUSCI state machine in reset
EUSCI_B_CTLW0_MST | // Set as SPI master
EUSCI_B_CTLW0_SYNC | // Set as synchronous mode
EUSCI_B_CTLW0_CKPH | // Set clock polarity high
EUSCI_B_CTLW0_MSB; // MSB first
SD_EUSCI->CTLW0 |= EUSCI_B_CTLW0_SSEL__SMCLK;
SD_EUSCI->BRW = 48; // /2,fBitClock = fBRCLK/(UCBRx+1).
SD_EUSCI->CTLW0 &= ~EUSCI_B_CTLW0_SWRST; // Initialize USCI state machine
}
=================================================