I'm currently having issues with getting my project off the ground. I'm working with the MSP430FR5739 to act as an SPI Slave, and I'm discovering that the code I've written never enters the SPI Receive Interrupt I've set up. I've verified that everything is connected in the right place, and I've verified (with an oscilloscope) that the SCLK, SS, and MOSI pins are being properly sent to the MSP430 FRAM chip.
I suspect that the problem is being caused by some concept in the MSP430's SPI that I'm missing. I'll go over the concepts now, and if needed, I'll post my code upon request.
To start, this is how I initialize the SPI. This is done after the Watchdog timer has been stopped, when the clock has been initialized, when the Temperature Sensor has been turned off, and when the GPIO pins have been initialized.
- Stop Watchdog Timer
- Set UCSWRST
- Initialize clock (to 24 MHz in my case)
- Turn off Temperature sensors
- Initialize GPIO pins for 4-pin SPI
- Initialize SPI
- UCCKPH = 0; Data is changed on the first UCLK edge and captured on the following edge.
- UCCKPL = 1; Clock polarity high
- UCMSB = 1; Set for MSB first select.
- UC7BIT = 0; Set for 8-bit character length
- UCMST = 0; SPI slave mode
- UCMODEx = 10b; 4-Pin SPI, w/ UCxSTE Active Low (UCMODE1 = 1)
- UCSELx = 00b: Reserved (Since UCxCLK is always used in slave mode).
- UCSYNC = 1; Synchronous mode enable (was 1 in some places)
- UCA0BR0 = 0x02; Bit clock prescaler setting set for a divisor of 2
- UCA0MCTLW = 0; No modulation
- Clear UCSWRST
- Enable USCI_A0 RX interrupt
- MPUCTL0 = MPUPW; Write PWD to access MPU registers
- MPUCTL0 = MPUPW+MPUENA; Enable MPU protection
- Enable GIE Interrupt
Once all of the system is initialized, I've load the TXBUF before the master even asserts STE (aka SS or CS). After that, I set up my SPI Receive ISR so that it just echos the received data in the UCA0RXBUF register back into the UCA0TXBUF. However, when looking through the oscilloscope, I can tell that the ISR is never started. Below is the setup of my ISR
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
STROBE1_TOGGLE;
while (!(UCA0IFG&UCTXIFG)); //USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; //Echo received data
UCA0IFG &= ~UCRXIFG;
__bic_SR_register_on_exit(CPUOFF);// Wake up to setup next TX
}
*/
// trap isr assignation - put all unused ISR vector here
#pragma vector = ADC10_VECTOR, PORT2_VECTOR,PORT1_VECTOR,\
TIMER0_A0_VECTOR, TIMER0_A1_VECTOR, WDT_VECTOR, COMP_D_VECTOR, \
DMA_VECTOR, PORT3_VECTOR, PORT4_VECTOR, RTC_VECTOR, \
SYSNMI_VECTOR, TIMER0_B0_VECTOR, TIMER0_B1_VECTOR, \
TIMER1_A0_VECTOR, TIMER1_A1_VECTOR, TIMER1_B0_VECTOR, \
TIMER1_B1_VECTOR, TIMER2_B0_VECTOR, TIMER2_B1_VECTOR, \
UNMI_VECTOR, USCI_A1_VECTOR, USCI_B0_VECTOR
__interrupt void TrapIsr(void)
{
// this is a trap ISR - check for the interrupt cause here by
// checking the interrupt flags, if necessary also clear the interrupt
// flag
}
So far, I've tried with different SPI settings to make sure that it isn't what I've set. I've also used a Strobe Bit and the oscilloscope to test how far the program actually goes. All these attempts have come to no avail, and I'm stumped on what else to try. Any suggestions would be appreciated. Thank you