Other Parts Discussed in Thread: SN74AVC4T774, MSP430FR5969
Hi,
I'm currently trying to set up communication between a MSP430FR5969 (LaunchPad) and an Intel Edison through SPI. I've set up a SN74AVC4T774 bus transceiver so I can interface the different voltage levels in each device.
Test code was made with DriverLib's SPI functions. Intel Edison's test code sends a stream of bytes from 1 to 150.
Control signals from the Intel Edison (SPI master) seems to be working fine, but the MSP430 is transmitting on the MISO line with a high level of ~1.2 V, even though it supplies ~3.2 V. Sometimes I even get the bytes looped back, as if MISO and MOSI were shorted, although the MSP430 is programmed to always send 0xFF.
#include "driverlib.h"
#include "stdio.h"
void m_setupSPI(){
// Set SPI pins
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2, GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5, GPIO_SECONDARY_MODULE_FUNCTION);
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN6, GPIO_SECONDARY_MODULE_FUNCTION);
// Set SPI mode
EUSCI_A_SPI_initSlaveParam param = {0};
param.msbFirst = EUSCI_A_SPI_LSB_FIRST;
param.clockPhase = EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
param.clockPolarity = EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW;
param.spiMode = EUSCI_A_SPI_4PIN_UCxSTE_ACTIVE_LOW;
// Enable SPI
EUSCI_A_SPI_initSlave(EUSCI_A1_BASE, ¶m);
EUSCI_A_SPI_enable(EUSCI_A1_BASE);
// Clear and enable SPI receive interrupt flag
EUSCI_A_SPI_clearInterrupt(EUSCI_A1_BASE, EUSCI_A_SPI_RECEIVE_INTERRUPT);
EUSCI_A_SPI_enableInterrupt(EUSCI_A1_BASE, EUSCI_A_SPI_RECEIVE_INTERRUPT);
// Clear and enable SPI transmit interrupt flag
// EUSCI_A_SPI_clearInterrupt(EUSCI_A1_BASE, EUSCI_A_SPI_TRANSMIT_INTERRUPT);
// EUSCI_A_SPI_enableInterrupt(EUSCI_A1_BASE, EUSCI_A_SPI_TRANSMIT_INTERRUPT);
}
int main(void){
// m_setupSPI();
GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN6);
PMM_unlockLPM5();
while(1){
// GPIO_setOutputLowOnPin(GPIO_PORT_P2, GPIO_PIN6);
GPIO_setOutputHighOnPin(GPIO_PORT_P2, GPIO_PIN6);
// EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, 0xFF);
}
}
// This is the SPI serial communication vector of interrupt service routines
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4)){
case USCI_NONE:
break;
case 2:
// EUSCI_A_SPI_transmitData(EUSCI_A1_BASE, 0xFF);
break;
}
}
Commented out functions are some of the other tests I've made. The one implemented above gives me the correct output (255).
I'm pretty sure I'm missing something very simple here.