Jump to content
Sign in to follow this  
amsks

spi loopback using interrupts on msp430f5438a

Recommended Posts

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

Edited by bluehash
[ADMIN] Please use code tags next time, for easy readability.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...