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.

MSP430F6779: eUSCI_A1 SPI not working.

Part Number: MSP430F6779
Other Parts Discussed in Thread: EVM430-F6779,

Hi,

    We are facing issue in MSP430F6779 when using source code of TIDA - 00222 power measurement reference. Here we have configured MSP430 eUSCI_A1 for 4 pin spi slave. When a byte of data is sent from master, MSP430 doesn't entering into the ISR function. Here pin2 of port3 is mapped as STE pin. STE pin (I assume it is chip select for 4pin slave mode) is pulled down when SPI data transfer. but no activity observed from slave side.

Kindly check any configuration is missing here.

//SPI_Configured while initialization
int SPI_Configure()
{

WDTCTL = WDTPW | WDTHOLD;           //stop watchdog timer
__bis_SR_register(GIE);
P3SEL0 |= BIT3 | BIT4 | BIT5;                  // Set P3.0,P3.1,P3.2 to non-IO & also P3.2 
PMAPPWD = PMAPPW;
P3SEL0 |= BIT2;
P3MAP2 = PM_UCA1STE;                       // STE port mapped to port 3.2
UCA1CTLW0 |= UCSWRST;                    // **Put state machine in reset**
UCA1CTLW0 |= UCSYNC | UCCKPH | UCMSB |UCMODE_2;             // 4-pin, 8-bit SPI slave,
UCA1CTLW0 |= UCSSEL_0;                                             // UCxCLK in slave mode
UCA1BRW_L = 0x02; 
UCA1BRW_H = 0; 
UCA1MCTLW = 0;                                                 // No modulation
UCA1CTLW0 &= ~UCSWRST;                          // **Initialize USCI state machine**
UCA1IE |= UCRXIE;                                         // Enable RX interrupt
return 0;
}



#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
P5OUT ^= (~BIT0);                //LED toggle when entered into this function
delay(20000);                        //20ms delay
switch (__even_in_range(UCA1IV, 4))
{
case USCI_NONE: break;           // No interrupt
case USCI_SPI_UCRXIFG:         // RXIFG
while(!(UCA1IFG & UCTXIFG)); 
UCA1TXBUF = 0x12;                  //Send 0x12 spi_data when RX interrupt occured
break;
case USCI_SPI_UCTXIFG: 
break;                                             // TXIFG
default: break;
}
}

  • > P5OUT ^= (~BIT0); //LED toggle when entered into this function
    Is P5.0 what you're using to measure activity? This toggles every P5 pin except P5.0. Try:
    > P5OUT ^= (BIT0); //LED toggle when entered into this function
  • Hey Udhayakumer,

    Please use the code insertion tool by clicking the </> button when posting software to keep it easy to read for the community to help you.  I've edited your post to use the tool.  

    In addition to Bruce's feedback, have you tried placing a breakpoint in the ISR to see if you are making it in?  

    There is a SPI Slave example for the msp430F6779 in TI Resource Explorer (TIRex).  Please take a look at MSP430F677x_USCIA0_SPI_10.c.  

    Regards,

    JD

  • Hi, Thank you for the comments.

    Bruce,

     There are LEDs connected to P5.0 & P5.1 , for  > P5OUT ^= (~BIT0);  then P5.1 LED state should change when entered into isr.  Anyway I will make the change you suggested and also will check with breakpoint. 

    Hi JD,

    I couldn't find any sample for 4pin spi slave or master. I have gone through sample code MSP430F677x_USCIA0_SPI_10.c . line87 >UCA0CTLW0 |= UCSSEL_2;                  // SMCLK   , here clock source is selected as SMCLK.  But what I found in MSP430x6xx family user guide is  UCxCLK should be used for slave mode and not SMCLK. Can you please enlighten it? 

    Thanks & Regards ,

    Udhayakumar.M

  • Per the schematics for the EVM430-F6779 (SLAA577G Fig 31) P3.2 (STE) is not connected to anything. Is this the board you're using?
    --------------------
    Per User Guide (SLAU208P) section 40.3.6 UCSSEL=0 is the (only) correct choice for slave mode. I don't know what's up with SPI_10.c. I think there are some devices where UCSSEL is ignored in slave mode. Maybe the F6779 is actually one of them , but your choice is always correct.

    [Edit: Removed LED comment. I wasn't paying attention.]

  • Hey Udhayakumar,

    I think the code example that will actually be the most useful for you is MSP430F677x_USCI_SPI_STANDARD_SLAVE.  Take a look at that example as well.  

    A few other points.

    Clocking/UCSSELx:

    I would always recommend following the datasheet over the code examples.  I would use UCxCLK like you pointed out.  Both of the code examples I've pointed you to use SMCLK even in Slave mode.  I'll create an internal ticket for this to be looked at.  '

    4 Wire SPI/ STE vs SS:

    The STE pin on the MSP430 devices does not offer the same behavior as a tradition SS pin would. This E2E post discusses this topic.  Because of this, to support true 4 wire SPI, the SS functionality has to be manually added via a GPIO.  Basically, you would just use a GPIO to reset/enable the USCI module with a GPIO interrupt. 

    Unfortunately, I don't have a code example like this to point you towards. 

    MSP430F6779 vs MSP430F6779A:

    If you are using the F6779, there is a pin-to-pin compatible updated device that I would recommend you use instead.  The devices function the same, but there were several errada and ESD improvements to the newer MSP430F6779A variant.  This App note explains the differences and shows no changes in metering performance:  "Differences between MSP430F67xx and MSP430F67xxA Devices"  

    Regards,

    JD

  • Hi JD,

    I will try to use a GPIO as Chipselect as given in the example you mentioned "MSP430F677x_USCI_SPI_STANDARD_SLAVE" . I think this will work.
  • No, we are using TIDA-00222 , and trying to use SPI interface with an external master.

  • Thanks Udhayakumar,

    I'm going to mark this post as "TI Think resolved". If you get it working you can come click resolved. If not, just continue the discussion down below.

    Thanks,
    JD

**Attention** This is a public forum