SLAA281C November   2005  – August 2018 MSP430F1610 , MSP430F1610 , MSP430F1611 , MSP430F1611 , MSP430F1612 , MSP430F1612 , MSP430G2001 , MSP430G2001 , MSP430G2101 , MSP430G2101 , MSP430G2111 , MSP430G2111 , MSP430G2121 , MSP430G2121 , MSP430G2131 , MSP430G2131 , MSP430G2201 , MSP430G2201 , MSP430G2201-Q1 , MSP430G2201-Q1 , MSP430G2211 , MSP430G2211 , MSP430G2221 , MSP430G2221 , MSP430G2231 , MSP430G2231 , MSP430G2231-Q1 , MSP430G2231-Q1

 

  1.   Interfacing MSP430™ MCUs With MMC or SD Flash Memory Cards
    1.     Trademarks
    2. 1 Hardware Description
    3. 2 Software Description
    4. 3 Function Description
      1. 3.1 char mmcInit (void);
      2. 3.2 char mmcping(void);
      3. 3.3 void mmcSendCmd (const char cmd, unsigned long data, const char crc);
      4. 3.4 char mmcGoIdle();
      5. 3.5 char mmcSetBlockLength (const unsigned long);
      6. 3.6 char mmcReadBlock(const unsigned long address, const unsigned long count, unsigned char *pBuffer);
      7. 3.7 char mmcWriteBlock (const unsigned long address, const unsigned long count, unsigned char *pBuffer);
      8. 3.8 char mmcReadRegister (const char cmd_register, const unsigned char length, unsigned char *pBuffer);
      9. 3.9 unsigned long mmcReadCardSize(void);
    5. 4 References
  2.   Revision History

Software Description

The code associated with this application report is designed as a driver set for communication between an MSP430 MCU and an MMC card or an SD card through the SPI bus as described in Section 1. The code is written modularly and can be reused easily. Only a subset of the available card commands is used, based on the limitations of the SPI interface and the secure functions of the SD card. This sample code can be downloaded from http://www.ti.com/lit/zip/slaa281.

An example main() function shows the proper use of the driver functions.

  1. This function initializes the MSP430F1612 in the 3-pin SPI mode with the function mmcInit().
  2. The MCU polls until an MMC card is detected and then tries to read the device memory size.
  3. The MCU prepares a buffer with 512 bytes of data and writes it to two different sectors of the card.
  4. The MCU reads the data that was written to each memory segment.

Uncomment the following line of code to use the MSP430F1612 DMA module for data transmission between the MCU and the MMC card, which results in higher communication speed and less CPU load.

//#define withDMA

If you adapt the software to a different USART or a different device in which the USART is connected to other port pins, modify the following functions for the correct settings:

  • void initSPI (void)
  • char mmcInit (void)
  • mmc.h file