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.

MSP430G2553 SPI communication with Energia

Other Parts Discussed in Thread: MSP430G2553, ENERGIA

Sensor_Board_Test.zip

I am writing a series of very simple application using the MSP430G2553 launch pad to drive the signal channels of some of our latest PCB and to gather information from them. This way, we can avoid to build complicated testers using switches, et.

I have already done three of them and they are being used successfully in our production facilities.

I decided to use the Energia feature of CCS6.0 and see how practical it would be for this kind of application. All went very well until I decided to use the SPI library. The task is to communicate with an AD7798. However, even when I see the AD7798 responding back to the launch pad, the return from the SPI.transfer() routine call is always 0xFF.

I can write the same program using a more conventional C program but it bothers me that I cannot get this one to run.

Maybe it is something I am overlooking, so any suggestions would be helpful please.

Thank you...-ANDY

  • Hi Andy,

    I took a bit of a look through your code. I'm not familiar with the AD7798, but it sounds like you do at least see something different than 0xFF coming back on the slave out/ master in line on the scope, but the result returned by SPI.transfer is 0xFF?

    You might want to provide a scope or logic analyzer shot so we can see the data going from the MSP and the data coming back from the AD7798 - it would be best if you had a scope shot showing the failing communication when using your energia code, and then a scope shot for the working C code doing the exact same command/transaction, for comparison to see if anything looks different on the lines.
    One more thought - Could it be that the SPI Mode is not matching up (have you tried all 4 different SPI_MODEx settings?)

    Regards,
    Katie
  • Seems like in your code you have the function of CS reversed.  Isn't the AD7798 spi active when the CS(SBG1) is pulled low? You seem to start with it pulled low and then  then pull it high before you try to use SPI.

    ...
    
    void pinInit(void) {
    	digitalWrite(SBG1, 0); 		// Disables the decoder which generates each CS
    }
    
    ...
    
    void readTest(void)
    {
      while(true)
      {
        enableChannel(TADCS);
        Serial.println("Testing Ambient Temperature channel");
        digitalWrite(SBG1, 1); // <<< shouldn't this be digitalWrite(SBG1,0)
        resetAD7798();
        ...
        digitalWrite(SBG1, 0); // <<< and this ... ,1 ?
        delay(1000);
        }
    }
    
    
    
    

**Attention** This is a public forum