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-RF2500 SPI

Other Parts Discussed in Thread: CC2500, MSP430F1121

Hi,

I want to use SPI on ez430-rf2500 in "end device software configuration". It seems that P3.0,P3.1,P3.2,P3.3 /UCB0/ are used for serial communication with CC2500. But UCA0 - P3.4 - UCA0SIMO, P3.5 - UCAOSOMI are free on the battery board - "end device" is not communicating with PC. Is it possible to emulate clock signal for SPI or UCA0CLK with other different digital pin without polling clock output on  P3.0 ant thus affecting CC2500 communication?

Regards.

N. Kolev  

  • I think the code below should be a help for ur requirement

     

     

     

    //******************************************************************************
    //   MSP430F22x4 Demo - USCI_A0, Ultra-Low Pwr UART 9600 String, 32kHz ACLK
    //
    //   Description: This program demonstrates a full-duplex 9600-baud UART using
    //   USCI_A0 and a 32kHz crystal.  The program will wait in LPM3, and will
    //   respond to a received 'u' character using 8N1 protocol. The response will
    //   be the string 'Hello World'.
    //   ACLK = BRCLK = LFXT1 = 32768Hz, MCLK = SMCLK = DCO ~1.2MHz
    //   Baud rate divider with 32768Hz XTAL @9600 = 32768Hz/9600 = 3.41
    //   //* An external watch crystal is required on XIN XOUT for ACLK *//
    //
    //                MSP430F22x4
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |     P3.4/UCA0TXD|------------> RX of USB emulator
    //            |                 | 9600 - 8N1
    //            |     P3.5/UCA0RXD|<------------ TX of USB emulator
    //
    //   A. Dannenberg
    //   Texas Instruments Inc.
    //   October 2006
    //   Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A
    //******************************************************************************
    #include  "msp430x22x4.h"

    const char string1[] = { "Hello World\r\n" };
    unsigned int i;

    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      BCSCTL1 = CALBC1_8MHZ;                    // Set DCO after random function
      DCOCTL = CALDCO_8MHZ;
     
                        // LFXT1 = VLO
     
      P1DIR = 0xFF;                             // All P1.x outputs
      P1OUT = 0;                                // All P1.x reset
      P2DIR = 0xFF;                             // All P2.x outputs
      P2OUT = 0;                                // All P2.x reset
      P3SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
      P3DIR = 0xFF;                             // All P3.x outputs
      P3OUT = 0;                                // All P3.x reset
      P4DIR = 0xFF;                             // All P4.x outputs
      P4OUT = 0;                                // All P4.x reset
      UCA0CTL1 |= UCSSEL_2;                     // CLK = SMCLK  if u want 32khz xtal then select UCSSEL_1 in UCA0CTL1 with br0=3, br1=0  decimal values
      UCA0BR0 = 0x41;                           // 32kHz/9600 = 3.41  //for 32khz    3;
      UCA0BR1 = 0x03;                           //                                      //    0;
      UCA0MCTL = UCBRS1 + UCBRS0;               // Modulation UCBRSx = 3
      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
      TACCTL0 = CCIE;                            // TACCR0 interrupt enabled
      IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
      BCSCTL3 |= LFXT1S_2;   
                             
      TACCR0=12000;
      TACTL = TASSEL_1 + MC_1; 
      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ int until Byte RXed
    }

    #pragma vector=USCIAB0TX_VECTOR
    __interrupt void USCI0TX_ISR(void)
    {
      UCA0TXBUF = string1[i++];                 // TX next character

      if (i == sizeof string1 - 1)              // TX over?
        IE2 &= ~UCA0TXIE;                       // Disable USCI_A0 TX interrupt
    }

    #pragma vector=USCIAB0RX_VECTOR
    __interrupt void USCI0RX_ISR(void)
    {
      if (UCA0RXBUF == 'u')                     // 'u' received?
      {
        i = 0;
        IE2 |= UCA0TXIE;                        // Enable USCI_A0 TX interrupt
        UCA0TXBUF = string1[i++];
      }
    }

  • Thanks SRIHK,

    This is mainly UART example. For SPI may be I can use in addition clock on P2.1 - SMCLK.

    Regards,

    Nick.

  • I am not shure if it is possible to substitute P3.0 UCA0 CLK with another digital pin for SPI on A channel?

    Nick

  • levkolai said:

    I am not shure if it is possible to substitute P3.0 UCA0 CLK with another digital pin for SPI on A channel?

     

    Unfortunately, you cannot replace the USCI's chanel A SPI clock line because it is a hardware peripheral. This pin is available on the actual target board (pin 17, see page 8 of the User's Guide).

    If you are unable to use the channel A clock pin you could implement a software SPI implementation. See the below code:

    //******************************************************************************
    //  MSP430x11x1 Demo - Software SPI Interface TLC549, Set P1.0 if > 0.5*Vcc
    //
    //  Description: Read a TLC549 ADC with reference to Vcc using software SPI and
    //  store the 8-bit digital code in ADCData.  The TLC549 is sampled in a
    //  continous loop. If ADCData > 0.5*Vcc, P1.0 set, else reset.
    //  ACLK = n/a. MCLK = SMCLK = default DCO ~800k
    //  //* VCC must be at least 3v for TLC549 *//
    //
    //                       MSP430F1121
    //                    -----------------
    //                /|\|              XIN|-
    //                 | |                 |
    //                 --|RST          XOUT|-
    //      TLC549       |                 |
    //    ----------     |                 |
    //   |        CS|<---|P2.0         P1.0|-->LED
    // ~>| AIN+  CLK|<---|P2.1             |
    //   |        DO|--->|P2.3             |
    //
    //
    //  M. Buccini
    //  Texas Instruments Inc.
    //  Feb 2005
    //  Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A
    //******************************************************************************

    #include <msp430x11x1.h>

    #define CS              0x01                // P2.0 - Chip Select
    #define CLK             0x02                // P2.1 - Clock
    #define DO              0x08                // P2.3 - Data Out

    void main (void)
    {
      unsigned char ADCData;
      unsigned char Counter;
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
      P2OUT = CS;                               // /CS set, - P2.x reset
      P2DIR |= CLK + CS;                        // /CS and CLK outputs
      P1DIR |= 0x01;                            // Set P1.0 to output direction

      for (;;)                                  // Infinite loop
      {
      P2OUT &= ~CS;                             // /CS reset, enable ADC
      for (Counter = 8; Counter > 0;)
        {
        ADCData = ADCData  << 1;
          if ((P2IN & DO) == DO)
          {
          ADCData |= 0x01;
          }
        Counter --;
        P2OUT |= CLK;                           // Clock high
        P2OUT &= ~CLK;                          // Clock low
        }
      P2OUT |= CS;                              // /CS set, disable ADC
        if (ADCData < 0x7F)
        {
        P1OUT &= ~0x01;                         // Clear P1.0 LED off
        }
        else
        {
        P1OUT |= 0x01;                          // Set P1.0 LED on
        }
      }
    }

     

**Attention** This is a public forum