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.

  • Resolved

MSP430F5506 SPI problem

Intellectual 260 points

Replies: 2

Views: 645

Greetings,

I am trying to configure the USCI B to use SPI so that I can talk with an RFID reader. Here is the code that I have so far; it is a modified version of the example code provided by TI. When I try to use a logic analyzer to see the data being sent out I can't see anyting. Clock is P4.0, MOSI is P4.4, and MISO is P4.5.

unsigned char MST_Data,SLV_Data;
volatile unsigned int i;

WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer

P4SEL |= BIT0+BIT4+BIT5; // P4.0,4,&5 for CLK, MOSI, MISO, respectively

PMAPPWD = 0x02D52;
P4MAP0 = PM_UCA1CLK;
P4MAP4 = PM_UCA1SIMO;
P4MAP5 = PM_UCA1SOMI;
PMAPPWD = 0;

UCA0CTL1 |= UCSWRST; // Software Reset (USCI_A)
UCA0CTL0 |= UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x02; // /2
UCA0BR1 = 0; //
UCA0MCTL = 0; // No modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

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

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

while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = MST_Data; // Transmit first character

Any help would be appreciated

  • Hi DWT,

    Looks like you are port-mapping for UCA1, but you are configuring UCA0.

    Other than that, it looks good to me!

    Jeff

  • In reply to Jeff Tenney:

    Wow. dumb mistake. Thanks for catching that. Works fine now!

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.