Tool/software: TI C/C++ Compiler
Hey everyone.
I`m trying to put the SPI to work in MSP430FR5969 with Driverlib but I detect some problems.
I can transmit the data using polling mode but when I try send the sequence between 0 and 255 the SPI transmit a lot of data wrongly.
My codes are:
Main Loop:
//I2C_ADDR_DATA_BUFFER_TX(0x53, buffer_test, 6);
for(ia=0; ia<=255; ia++)
{
//I2C_M24LR_WRITE_PAGE(buffer_test, 4*ia);
buffer_test[0]= ia;
SPITXRX (buffer_test[0]);
__delay_cycles(500);
}
SPI INITIALIZATION
void SPI_INIT(void)
{
/* USER CODE START (section: EUSCI_A1_graceInit_prologue) */
/* User initialization code */
/* USER CODE END (section: EUSCI_A1_graceInit_prologue) */
//Initialize Master
EUSCI_A_SPI_initMasterParam param = {0};
param.selectClockSource = EUSCI_A_SPI_CLOCKSOURCE_SMCLK;
param.clockSourceFrequency = CS_getSMCLK();
param.desiredSpiClock = 100000;
param.msbFirst = EUSCI_A_SPI_MSB_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_3PIN;
EUSCI_A_SPI_initMaster(EUSCI_A1_BASE, ¶m);
/* enable eUSCI SPI */
EUSCI_A_SPI_enable(EUSCI_A1_BASE);
/* disable eUSCI SPI transmit interrupt */
EUSCI_A_SPI_disableInterrupt(EUSCI_A1_BASE, EUSCI_A_SPI_TRANSMIT_INTERRUPT);
/* disable eUSCI SPI receive interrupt */
EUSCI_A_SPI_disableInterrupt(EUSCI_A1_BASE, EUSCI_A_SPI_RECEIVE_INTERRUPT);
/* USER CODE START (section: EUSCI_A1_graceInit_epilogue) */
/* User code */
/* USER CODE END (section: EUSCI_A1_graceInit_epilogue) */
__delay_cycles(100);
Init_SPICS();
}
SPI TRASMIT
unsigned char SPITXRX (unsigned char datatx )
{
CS_LOW();
//
EUSCI_A_SPI_transmitData(EUSCI_A1_BASE,datatx);
while(EUSCI_A_SPI_isBusy(EUSCI_A1_BASE));
CS_HIGH();
return 0;
}
MY HARDWARE AND MY LAUNCHPAD WITH XTAL 14.7656MHZ SHOW THE SAME BIT ERROR. hOW CAN I SOLVE IT?
THANK YOU AND BEST REGARDS.