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.

EZ430-F2013: Example code

Part Number: EZ430-F2013

Hi Team,

This inquiry is a continuation of the other thread. According to our customer,

Thank you for your assistance, I am searching for an example code for transferring data from SD16MEMO to USI on MSP430F2XX but I am not successful enough till so can you please point me towards an example here.

Here is my code which I was able to piece together while searching some examples and from other members' query requests

First.c
#include <msp430.h>

/* Arrays to store SD16 conversion results */
/* NOTE: arrays need to be global to       */
/*       prevent removal by compiler       */
static volatile unsigned int ChA0results = 0x00;
static volatile unsigned int ChA1results = 0x00;
static volatile unsigned int ChA2results = 0x00;
static unsigned int ch_counter=0;

int main(void)
{

  volatile unsigned int i;                  // Use volatile to prevent removal
                                            // by compiler optimization


  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
  BCSCTL1 = CALBC1_16MHZ;
  DCOCTL=CALDCO_16MHZ;


  P1OUT |= BIT5;
  P1DIR |= BIT5;
  P1DIR |= 0x10;   //P1.4 as output
  P1SEL = 0x10;    //SMCLK to P1.4
  P1DIR |= BIT7; //set P1.7 to output direction - as signal for data are ready to us

  SD16CTL = SD16REFON + SD16SSEL_1;         // 1.2V ref, SMCLK
  SD16INCTL0 = SD16INCH1;                   // Set channel A0+/-
  SD16CCTL0 |= SD16SNGL + SD16UNI + SD16IE;
                                            // Single conv, 256OSR, unipolar,
                                            // enable interrupt
  SD16INCTL0 |= SD16INTDLY_0;               // Interrupt on 4th sample
  SD16AE = SD16AE1;                         // P1.0 A0+, A0- = VSS

  USICTL0 &= ~USISWRST; //USI released for operation
  USICTL1 &= ~USII2C; //switch USI to SPI-Mode
  USICTL0 &= USIMST; //set to SPI-Slave-Mode
  USICTL0 |= USIPE5; //SCLK as input (from Warrior56)
  USICTL0 |= USIPE6; //SDO-Port enabled; Pin8
  USICTL0 &= ~USIPE7; //SDI-Port disabled; Pin9 can be used for normal in/out
  USICTL0 |= USIOE; //activate output (data goes from MSP to Warrior56)
  USICNT |= USI16B; //init load counter for 16-bit-data
  //inactive state is low
  //data is changed on the first SCLK edge and captured on the following edge



  for (i = 0; i < 0x3600; i++);             // Delay for 1.2V ref startup

  while(1)
  {
    SD16CCTL0 |= SD16SC;                    // Set bit to start conversion

    __bis_SR_register(LPM0_bits + GIE);     // Enter LPM0

  }
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = SD16_VECTOR
__interrupt void SD16ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(SD16_VECTOR))) SD16ISR (void)
#else
#error Compiler not supported!
#endif
{

        ChA0results = SD16MEM0;             // Save CH0 results (clears IFG)
        SD16AE &= ~SD16AE1;                 // Disable external input A0+, A0
        SD16INCTL0 &= ~SD16INCH_1;          // Disable channel A0+/-
        ch_counter++;
        USISR = SD16MEM0;
        SD16INCTL0 |= SD16INCH_1;           // Enable channel A1+/-
        SD16AE |= SD16AE2;                  // Enable external input on A1+



}

Regards,

Danilo

**Attention** This is a public forum