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.

MSP430F2013 SPI master problem

Other Parts Discussed in Thread: MSP430F2013

Hey there, I have a communication Problem with my MSP430F2013 in Master mode. The µC just doesnt shift the Data out. In fact, it doesnt even provide a clk Signal at the pin. Do you have an idea what`s the matter?

I am using IAR Kickstart 6.20 by the way..

Here is my code for the SPI communication:

 WDTCTL = WDTPW + WDTHOLD;            // Stop watchdog timer in order to prevent timeout reset

 USICTL0 |= USISWRST;                                  // USI stopped
 USICTL0 |= USIPE7 + USIPE6 + USIPE5 + USIMST + USIOE; // Configure USI: Port and Master

 USICTL1 |= USIIE;                                     // Counter interrupt enabled, flag remains set
 USICKCTL = USIDIV_5 + USISSEL_2 + USICKPL;            // Configure USI Clock

  USICTL0 &= ~USISWRST;                                 // USI released for Operatio

while(1)

{

  USISR = 0xDEA3;                                               // write any data to shift Register

  USICNT = USI16B;                                              // 16bit communicaton

  USICNT |= 16;                                                      // set bit Counter to 16

 //   while (!(USIIFG & USICTL1));                         //Counter clear?

}

I set the while in the end to  comment line, because otherwise the code stops in this line (what means, that no data is clocked out)

 

  • Hi Niko!

    void main( void )
    {
      WDTCTL    = WDTPW | WDTHOLD;                            // Stop watchdog timer
    
      USICTL0   =  USISWRST;                                  // USI stopped
      USICTL0  |=  USIPE7 | USIPE6 | USIPE5 | USIMST | USIOE; // P1.5,6,7 USI function, master, output enable
      USICKCTL  =  USIDIV_5 + USISSEL_2 + USICKPL;            // Divider 32, SMCLK, clock idles high
      USICTL0  &= ~USISWRST;                                  // USI released for operation
      USICNT    = USI16B;                                     // USI transmits 16 bits
    
      while( 1 )                                              // Endless loop
      {
        if( USICTL1 & USIIFG )                                // Interrupt flag is set - ready to transmit
        {
          USISR   = 0xDEA3;                                   // Write any data to shift Register
          USICNT |= 16;                                       // USI starts outputting 16 bits of data
        }
      }
    }

    Try if this works, haven't tested it.

    Dennis

  • You are settings USIIE. Is there an interrupt handler?
  • GIE is not set so this should not make any difference.

**Attention** This is a public forum