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.
Hi,
I am trying to work out the SPI communication between two evaluation boards , MSP432P401R (Master) and MSP430F5529 (Slave)
the code used is directly from the examples provided by TI .
The value received is only FF . Would like to know where I am going wrong.
CODE is as follows :
1) for SPI 3-Wire Master Incremented Data (on msp432p401r)
#include "msp.h"
unsigned char RXData;
unsigned char TXData;
int main(void)
{
volatile uint32_t i;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1SEL0 |= BIT5 | BIT6 | BIT7; // set 3-SPI pin as second function
__enable_interrupt();
NVIC_ISER0 = 1 << ((INT_EUSCIB0 - 16) & 31); // Enable eUSCIB0 interrupt in NVIC module
UCB0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCB0CTLW0 |= UCMST|UCSYNC|UCCKPL|UCMSB; // 3-pin, 8-bit SPI master
// Clock polarity high, MSB
UCB0CTLW0 |= UCSSEL__ACLK; // ACLK
UCB0BR0 = 0x02; // /2,fBitClock = fBRCLK/(UCBRx+1).
UCB0BR1 = 0; //
UCB0IE |= UCRXIE;
UCB0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
TXData = 0x01; // Holds TX data
while(1)
{
UCB0IE |= UCTXIE; // Enable TX interrupt
for (i = 2000; i > 0; i--); // Delay before next transmission
TXData++; // Increment transmit data
}
}
// SPI interrupt service routine
void eUSCIB0IsrHandler(void)
{
if (UCB0IFG & UCTXIFG)
UCB0TXBUF = TXData; // Transmit characters
UCB0IE &= ~UCTXIE;
while (!(UCB0IFG & UCRXIFG));
RXData = UCB0RXBUF;
}
2) SPI 3-Wire Slave Data Echo (msp430f5529)
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P4SEL |= BIT4+BIT5; // P3.3,4 option select
P4SEL |= BIT0; // P2.7 option select
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL0 |= UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI slave,
// Clock polarity high, MSB
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
__enable_interrupt();
}
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
if (UCA1IFG & UCRXIFG)
while (!(UCA1IFG & UCTXIFG));
UCA1TXBUF = UCA1RXBUF;
}
Thanks
Hi,
As I had mentioned I am using two evaluation boards as follows ,
1) MSP432P401R (configured as master):
- Using the B0 module
- Pins used are: P1.6 (SIMO)
P1.7 (SOMI)
P1.5 (CLK)
2) MSP430F5529 (configured as slave):
- Using the A1 module
- Pins used are: P4.4 (SIMO)
P4.5 (SOMI)
P4.0 (CLK)
respective pins are connected
Thanks,
respective pins are connected
You mean, SIMO to SIMO, SOMI to SOMI, and CLK to CLK?
Hi Maisie, Even I am stuck with a similar issue. I wanted to start a new thread, however I found your post quite relevant so i am posting it as reply.
I am trying 3-wire SPI Communication between the experimenter boards MSP-EXP432P401R & MSP-EXP430F5438. I am trying to use B0 as master on 432 side and B0 as slave on 430 side. I am new to MSP432P401R.
Hardware connections are as follows.
MSP432(Master) (B0) MSP430(slave) (B0)
P1.5(CLK), P1.6(SIMO), P1.7(SOMI) P3.3(CLK), P3.1(SIMO), P3.2(SOMI)
I am using 8-bit SPI on MSP430 side, however i am not sure whether MSP432 is 8/16/32 bit i could not find the setting in the SPI Example of MSP432.
Thanks in advance.
Maisie,
I notice the code you attach does not appear to be CMSIS compliant. Do you have our newest SDK V1.30.00.40 (Released only a few days before your original post.)
Can you refer me to the specific code examples you are using for this so I can try to replicate your issue on my side?
Aditya,
When you say "8-bit", I assume you mean the character length (data length). This is defined by the CTLW0 register (see TRM Table 23-12).
Are you saying you have also set up this similar setup and also receive only FF as Maisie describes or is your issue different? Can you supply me with links to the specific examples you use also?
Hi,
By '8 bit data' it means the character length. By default it is 8 bit on both the platforms, incase u need to change to 7 Bit , need to set the UC7BIT.
To establish communication make sure the clock phase, clock polarity Bits are set correct (Whatever is set on the master side to be set on the slave) except that on the master side, first configure it as master and provide a clock source.
Regards,
Maisie
Maisie,
Are you still experiencing difficulty getting these two devices to work together?
Hi John ,
No the issue was resolved , I happened to use a higher frequency clock for the SPI communication.
Thanks ,
Maisie
**Attention** This is a public forum