Other Parts Discussed in Thread: MSP430F5528
I'm writing an SPI driver for MSP430F5528 chip.
I'm using the driverlib from TI for working with the SPI.
I need to send 3 bytes.
When I'm sending the 3 bytes one after the other, only the third byte is actually sent, like the first two were overriden.
I tried waiting until the SPI bus won't be busy. but than I get gaps between the bytes, the CLK stops between them and the perihpheral doesn't work.
I tried also turning the SPI's TX interrupt, and wait until the interrupt occurr, but aperently, the bytes are overriden like before.
Here's some code for reference:
GPIO_setAsOutputPin( GPIO_PORT_P6, GPIO_PIN6 );
GPIO_setOutputHighOnPin(GPIO_PORT_P6, GPIO_PIN6 ); // Set CS UP
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P4,
GPIO_PIN2
);
GPIO_setAsPeripheralModuleFunctionOutputPin(
GPIO_PORT_P4,
GPIO_PIN1 + GPIO_PIN3
);
retval = USCI_B_SPI_masterInit(USCI_B1_BASE,
USCI_B_SPI_CLOCKSOURCE_ACLK,
UCS_getACLK(__MSP430_BASEADDRESS_UCS__),
SPICLK,
USCI_B_SPI_MSB_FIRST,
USCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, /* CPHA=0 */
USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW /* CPOL=0 */
);
//Enable SPI module
USCI_B_SPI_enable(USCI_B1_BASE);
/* Send few bytes with interrupt waiting.
USCI_B_SPI_clearInterruptFlag ( USCI_B0_BASE, USCI_B_SPI_TRANSMIT_INTERRUPT );
USCI_B_SPI_enableInterrupt ( USCI_B0_BASE, USCI_B_SPI_TRANSMIT_INTERRUPT );
GPIO_setOutputLowOnPin(GPIO_PORT_P6, GPIO_PIN6 ); // Set CS DOWN
USCI_B_SPI_transmitData(USCI_B1_BASE, 0x1);
while ( !USCI_B_SPI_getInterruptStatus ( USCI_B0_BASE, USCI_B_SPI_TRANSMIT_INTERRUPT ) ) ;
USCI_B_SPI_transmitData(USCI_B1_BASE, 0x2);
while ( !USCI_B_SPI_getInterruptStatus ( USCI_B0_BASE, USCI_B_SPI_TRANSMIT_INTERRUPT ) ) ;
USCI_B_SPI_transmitData(USCI_B1_BASE, 0x3);
while ( !USCI_B_SPI_getInterruptStatus ( USCI_B0_BASE, USCI_B_SPI_TRANSMIT_INTERRUPT ) ) ;
GPIO_setOutputHighOnPin(GPIO_PORT_P6, GPIO_PIN6 ); // Set CS UP
USCI_B_SPI_disableInterrupt ( USCI_B0_BASE, USCI_B_SPI_TRANSMIT_INTERRUPT );