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.

CCS/MSP430F5507: Hi , I need some help with my MSP430F5507 using SPI comunication protocol.

Part Number: MSP430F5507

Tool/software: Code Composer Studio

HI, I am new user with micro controller MSP430. I am trying to communicate with a flash memory M25P40 using SPI protocol. I am sending data through the UCB1TXBUF register, but i don´t receive any data.

#include <msp430.h>

unsigned char MST_Data, SLV_Data;

int main(void)
{
volatile unsigned int i;

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
if (CALBC1_1MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
for(i=2100;i>0;i--); // Wait for DCO to stabilize.

P1OUT = 0x00; // P1 setup for LED
P1DIR |= 0x01; //
P3OUT = 0x20; // Set slave reset - P3.5
P3DIR |= 0x20; //
P5SEL |= 0x0E; // P5.1,2,3 USCI_B1 option select

UCB1CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC; // 3-pin, 8-bit SPI master
UCB1CTL1 |= UCSSEL_2; // SMCLK
UCB1BR0 |= 0x02; // BRCLK = SMCLK/2
UCB1BR1 = 0; //
UCB1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UC1IE |= UCB1RXIE; // Enable USCI1 RX interrupt

P3OUT &= ~0x20; // reset slave - RST - active low
P3OUT |= 0x20; // Now with SPI signals initialized,

for (i = 50; i > 0; i--); // Wait for slave to initialize

MST_Data = 0x01; // Initialize data values
SLV_Data = 0x00;

UCB1TXBUF = MST_Data; // Tx(01) and Rx (00) - first char

__bis_SR_register(LPM0_bits + GIE); // CPU off, enable interrupts
}

// Test for valid RX and TX character
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCIAB1RX_VECTOR
__interrupt void USCIB1RX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB1RX_VECTOR))) USCIB1RX_ISR (void)
#else
#error Compiler not supported!
#endif
{
volatile unsigned int i;

while (!(UC1IFG & UCB1TXIFG)); // USCI_B1 TX buffer ready?

if (UCB1RXBUF == SLV_Data) // Test for correct character RX'd
P1OUT |= 0x01; // If correct, light LED
else
P1OUT &= ~0x01; // If incorrect, clear LED

MST_Data++; // Increment master value
SLV_Data++; // Increment expected slave value
UCB1TXBUF = MST_Data; // Send next value (Tx and Rx)

for (i = 10000; i; i--); // Add time between transmissions to
} // make sure slave can keep up

 

**Attention** This is a public forum