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.

MSP430F5528: Problems with the SPI conif from the SLAA281B App Report (SPI communication with a SD Card)

Part Number: MSP430F5528


Hi all,

I am trying to migrate the Code from the SLAA281B Application Report in my current project with the MSP430f5528.

But he config of the SPI connection doesn`t work. I connectet an oszi but there are no edges....

Thank you for your help!

//----------------------------hal_MMC_hardware_board.h-------------------------------------------------------

#include "msp430f5528.h"              // Adjust this according to the
                                     // MSP430 device being used.
// SPI port definitions              // Adjust the values for the chosen
#define SPI_PxSEL         P4SEL      // interfaces, according to the pin
#define SPI_PxDIR         P4DIR      // assignments indicated in the
#define SPI_PxIN          P4IN       // chosen MSP430 device datasheet. 
#define SPI_PxOUT         P4OUT
#define SPI_SIMO          0x04
#define SPI_SOMI          0x05
#define SPI_UCLK          0x00


//----------------------------------------------------------------------------
// SPI/UART port selections.  Select which port will be used for the interface 
//----------------------------------------------------------------------------

// SPI port definitions              // Adjust the values for the chosen
#define MMC_PxSEL         SPI_PxSEL      // interfaces, according to the pin
#define MMC_PxDIR         SPI_PxDIR      // assignments indicated in the
#define MMC_PxIN          SPI_PxIN       // chosen MSP430 device datasheet.
#define MMC_PxOUT         SPI_PxOUT      
#define MMC_SIMO          SPI_SIMO
#define MMC_SOMI          SPI_SOMI
#define MMC_UCLK          SPI_UCLK

// Chip Select CS 4.3
#define MMC_CS_PxOUT      P4OUT
#define MMC_CS_PxDIR      P4DIR
#define MMC_CS            0x03

// Card Detect CD 2.7
#define MMC_CD_PxIN       P2IN
#define MMC_CD_PxDIR      P2DIR
#define MMC_CD            0x07

#define CS_HIGH()   while(halSPITXDONE); MMC_CS_PxOUT |= MMC_CS        // Card Deselect
#define CS_LOW()            (P4OUT &= ~BIT3) //modified

#define DUMMY_CHAR 0xFF



//---------------------------------hal_SPI.h--------------------------------------------------
 #define halSPIRXBUF          UCA1RXBUF
 #define halSPI_SEND(x)       UCA1TXBUF = x
 #define halSPITXREADY        (UCA1IFG & UCTXIFG)         /* Wait for TX to be ready */
 #define halSPITXDONE         (UCA1STAT & UCBUSY)       /* Wait for TX to finish */
 #define halSPIRXREADY        (UCA1IFG & UCRXIFG)          /* Wait for TX to be ready */
 #define halSPIRXFG_CLR       UCAxIFG &= ~UCRXIFG
 #define halSPI_PxIN          SPI_USART0_PxIN
 #define halSPI_SOMI          SPI_USART0_SOMI


//---------------------------------hal_SPI.c--------------------------------------------------
// SPI port functions
void halSPISetup(void)
{               
 
  UCA1CTL0 = UCMST+UCCKPL+UCMSB+UCSYNC+UCMST;     // 3-pin, 8-bit SPI master
  UCA1CTL1 = UCSSEL_2 + UCSWRST;            // SMCLK
  UCA1BR0 |= 0x02;                          // UCLK/2
  UCA1BR1 = 0;
  UCA1MCTL = 0;
  UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
}

  • Hi Christian,

    SLAA281 specifically details using an MSP430 device with a USART peripheral whereas the F5528 contains USCIs, I'm not sure how you were able to migrate this code without completely reworking the SPI HAL files or getting several errors from the IDE. My recommendation is to reference the User Experience Demo Software for the MSP-EXP430F5529 as this contains resources for communication between an SD card and MSP430F552x device using USCI SPI.

    Regards,
    Ryan
  • Hi Ryan,

    thank you for the hint! It initialization seems to work. The other functionality i have to check in the next days.

    Thank you for your fast support!

    Regards, Christian

**Attention** This is a public forum