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.

MSP432 CS-Pin

Other Parts Discussed in Thread: ENERGIA, MSP430G2553

Hi guys,

I want to connect a sd card breakout board with the msp432. For the configuration i have to define the CS-Pin. I 've already searched in the pin.h from Energi, but i couldn't find the adress for the CS-Pin.

Does anybody know where I could find the adress or which adress is used for the CS-Pin?

Thankx,
Chris

  • Christoph,

    the CS select pin of your SD-card is a simple input. The SD card is active when CS is low and inactive when it is high. So any GPIO pin of the MSP432 configured as output can act as the driving pin for CS of the SD-card. You won't find a dedicated pin that is exclusively used as CS. No microprocessor has that - it is always a free pin of your choice.

    There is a STE pin of the USCI module that can be used as an automatically driven CS, but this will often cost you one special function of another USCI module. But I'm not sure if it is the same for the MSP432 at the moment.

    Normally you use a normal GPIO. Before sending your data you enable the slave by PxOUT &= ~BIT; and disable it by PxOUT |= BIT; after transmission is finished.

    Dennis

  • Hi Dennis,

    Thank you for fast answer. For my project I used the SD Card from Adafruit (www.exp-tech.de/.../adafruit-microsd-card-breakout-board) in combination with the Code from 43oh ( 43oh.com/.../). After a short modification of the code I was able to compile the code and to transmit the code on the msp432.

    But the project didn't work well because no file was created on the SD Card. So i suggest that the cs-pin wasn't well configured.

    Greetings,
    Chris
  • Then upload a schematic and your source code and we will see.
  • I wired the board with the msp432 as described on the Quick Start Guide from TI (www.ti.com/.../slau596.pdf). The source code :

    #include <pfatfs.h>
    #include <pffconf.h>

    /*----------------------------------------------------------------------*/
    /* Petit FatFs sample project for generic uC (C)ChaN, 2010 */
    /*----------------------------------------------------------------------*/
    /*-----------------------------------------------------------------------
    Ported to Energia by calinp
    Copy the file LOG.txt from this file's location to the root of the
    SD-Card.

    12/21/2013
    Modified by bluehash(43oh) to log temperature data from the MSP430G2553
    internal temperature sensor and log it to a file on the SD-Card
    References:
    forum.43oh.com/.../
    */


    #include "SPI.h"
    #include "pfatfs.h"

    #define cs_pin 8 // chip select pin
    #define read_buffer 128 // size (in bytes) of read buffer
    #define LOG_DELAY 5000 // 5000ms -> 5sec

    unsigned short int bw, br;//, i;
    char buffer[read_buffer];
    int rc;
    DIR dir; /* Directory object */
    FILINFO fno; /* File information object */

    uint32_t ui32_ReadTemp = 0;
    uint8_t StringLength = 0;
    char buf[30];
    uint32_t counter = 0;
    uint32_t AccStringLength = 0;

    void setup()
    {
    pinMode(PUSH2, INPUT_PULLUP);
    Serial.begin(9600); // initialize the serial terminal
    analogReference(INTERNAL1V5);
    analogRead(TEMPSENSOR); // first reading usually wrong
    FatFs.begin(cs_pin); // initialize FatFS library calls
    Serial.print("\n\n\n MSP430 Temperature Logger \n\r");
    Serial.println("Press S2 button to start...");
    while(digitalRead(PUSH2)==1){}
    delay(100);
    while(digitalRead(PUSH2)==0){}
    }

    /* Stop with dying message */
    void die ( int pff_err )
    {
    Serial.println();
    Serial.print("Failed with rc=");
    Serial.print(pff_err,DEC);
    for (;;) ;
    }

    void printDec(uint32_t ui)
    {
    Serial.print(ui/10, DEC);
    Serial.print(".");
    Serial.print(ui%10, DEC);
    }

    /*-----------------------------------------------------------------------*/
    /* Program Main */
    /*-----------------------------------------------------------------------*/
    void loop()
    {
    #if 0
    Serial.println();
    Serial.println("Press button to start...");
    while(digitalRead(PUSH2)==1){}
    delay(100);
    while(digitalRead(PUSH2)==0){}
    #endif

    ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)*27069 - 18169625) *10 >> 16;

    #if DEBUG
    Serial.println();
    Serial.println("Opening log file to write temperature(LOG.txt).");
    delay(100);
    #endif

    rc = FatFs.open("LOG.TXT");
    if (rc) die(rc);

    delay(100);
    bw=0;
    ui32_ReadTemp = ((uint32_t)analogRead(TEMPSENSOR)*27069 - 18169625) *10 >> 16;
    sprintf( buf, "%lu Current temperature is %lu.%lu\r\n", counter, ui32_ReadTemp/10, ui32_ReadTemp%10 );
    counter++;
    StringLength = strlen(buf);
    Serial.println(buf);

    #if DEBUG
    Serial.print(StringLength, DEC);
    Serial.println();
    Serial.print(AccStringLength, DEC);
    #endif

    rc = FatFs.lseek( AccStringLength );
    if (rc) die(rc);
    AccStringLength = AccStringLength + 512;
    rc = FatFs.write(buf, StringLength,&bw);
    if (rc) die(rc);
    rc = FatFs.write(0, 0, &bw); //Finalize write
    if (rc) die(rc);
    rc = FatFs.close(); //Close file
    if (rc) die(rc);


    #if READ
    delay(100);
    Serial.println();
    Serial.println("Read Temp data from the log file (LOG.txt).");
    delay(100);
    rc = FatFs.open("LOG.TXT");
    if (rc) die(rc);

    delay(100);
    for (;;) {
    rc = FatFs.read(buffer, sizeof(buffer), &br); /* Read a chunk of file */
    if (rc || !br) break; /* Error or end of file */
    for (uint16_t i = 0; i < br; i++) /* Type the data */
    Serial.print(buffer[i]);
    delay(100);
    }
    if (rc) die(rc);
    #endif

    // Log delay
    delay(LOG_DELAY);
    }
  • The link does not work. Can you draw a connection diagram er explain in detail which contact is connected to which terminal?

  • SPI MOSI --> P1.6 (MSP432)
    SPI MISO --> P1.7 (MSP432)
    SPI CS --> P5.2 (MSP432)
    5 V --> 5V (MSP432)
    GND -->GND (MSP432)

    I think I have to change the CS_pin from 8 to the P 5.2.
    Or am I wrong?

**Attention** This is a public forum