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.

Can't generate clock signal without interrupt in SPI master mode.

Other Parts Discussed in Thread: MSP430G2553

I'm working with MSP430G2553 launch pad. When i use SPI master mode example code, it work fine. But when i try another code without interrupt, i can't generate the serial clock in pin1.5 (UCB0CLK) it's just noise signal. Is there any relative between clock signal and interrupt ? This is code:

volatile char received_ch = 0;

WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
                                       
P1SEL = BIT6 | BIT7 | BIT5;
P1SEL2 = BIT6 | BIT7 | BIT5;
 
UCB0CTL1 = UCSWRST
UCB0CTL0 |= UCMSB + UCMST + UCSYNC;  // 3-pin, 8-bit SPI master
UCB0CTL1 |= UCSSEL_2;                     // SMCLK
UCB0BR0 |= 0x02;                          // /2
UCB0BR1 = 0;                              //
UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
 
while (!(IFG2 & UCB0TXIFG));   // USCI_A0 TX buffer ready?
UCB0TXBUF = 0xAA;              // Send 0xAA over SPI to Slave
while (!(IFG2 & UCB0RXIFG));   // USCI_A0 RX Received?
received_ch = UCB0RXBUF;       // Store received data
 

One more question. When i want to set the clock polarity or clock phase, do i need to following these instructions:

UCB0CTL1 |=  UCSWRST

// CKPL =1 or CKPH =1

UCB0CTL1 &= ~UCSWRST;

**Attention** This is a public forum