Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 21927

MSP430FR4133 SPI

$
0
0

We are using MSP430FR4133 Evaluation boards for SPI communication.

we are transmitting and receiving the data in one board.

but we are unable to receive the in another board.

this is code we are using. 

#include <msp430.h>

unsigned char RXData[255];
unsigned char TXData;
unsigned int i;

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

P1SEL0 |= BIT0 | BIT1 | BIT2; // set 3-SPI pin as second function
// P1REN =0xff;
UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCA0CTLW0 |= UCMST|UCSYNC|UCCKPL|UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCA0CTLW0 |= UCSSEL__MODCLK; // MODCLK
UCA0BR0 = 0x0F; // /2,fBitClock = fBRCLK/(UCBRx+1).
UCA0BR1 = 0; //
UCA0MCTLW = 0; // No modulation
UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
TXData = 0xAA; // Holds TX data

PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
while(1)
{
UCA0IE |= UCTXIE; // Enable TX interrupt
__bis_SR_register(LPM0_bits | GIE); // enable global interrupts, enter LPM0
__no_operation(); // For debug,Remain in LPM0
__delay_cycles(2000); // Delay before next transmission
// TXData++; // Increment transmit data
if(i>=255)
{
i=0;
//TXData=0x01;
}
}
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA0IV,USCI_SPI_UCTXIFG))
{
case USCI_NONE: break; // Vector 0 - no interrupt
case USCI_SPI_UCRXIFG:
RXData[i++] = UCA0RXBUF;
UCA0IFG &= ~UCRXIFG;
__bic_SR_register_on_exit(LPM0_bits);// Wake up to setup next TX
break;
case USCI_SPI_UCTXIFG:
UCA0TXBUF = TXData; // Transmit characters
UCA0IE &= ~UCTXIE;
break;
default: break;
}
}


Viewing all articles
Browse latest Browse all 21927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>