Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

spi loopback using interrupts on msp430f5438a

$
0
0

I am trying a loopback test for msp430f5438a using interrupts. I have initialized the master and slave modules and have written their respective functions as interrupt service routines. The aim I to turn the LED off when the slave receives a character.However, the code is not working. Please tell me how to make it work

 

 

---------------------------------------------------------------------------------------------------------------------------------

// To use interrupts to transmit and recieve text character(s)

#include <msp430.h>

/*
* main.c
*/

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

P1DIR |= BIT0;
P1OUT |=BIT0;
// setting up master

P3SEL = BIT1|BIT2|BIT3; // B0 PINS
UCB2CTL1 |= UCSWRST;
UCB2CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC; //3 - PIN, 8 bit, spi master
UCB2CTL1 |= UCSSEL_2 ; // SMCLK
UCB2CTL1 &= ~(UCSWRST) ;

UCB2IE = UCTXIE ;

// master setup done

// Configuring the Slave

P3SEL= BIT0|BIT4|BIT5;
UCA0CTL1 |= UCSWRST; //put the SPI bti
UCA0CTL0 |= UCCKPH + UCMSB + UCSYNC ; // 3- pin , 8 bit , SPI slave
UCA0CTL1 &= ~(UCSWRST) ; //release the pin for sending hte SPI signal

UCA0IE = UCRXIE; //Enable RX interrupt

// Slave setup done

 
__bis_SR_register(GIE); // enable interrupts

while(1);
}

#pragma vector = USCI_B2_VECTOR
__interrupt void USCI_B2_ISR (void )
{
UCB2TXBUF = 0X0A ;
}

 
#pragma vector = USCI_A0_VECTOR
__interrupt void USCI_A0_ISR ( void )
{
if (UCA0RXBUF == 0X0A)
{
P1OUT &= ~BIT0;

}

 
}

-----------------------------------------------------------------------------------------------------------------------------------------

 

 

I am using CCS for IDE


Viewing all articles
Browse latest Browse all 2077

Trending Articles