I have an issue with SPI communication with MFRC522, so I am trying to use SPI listen mode to test my configuration, however when I do, SPI stucks on waiting for UCRXIFG which is never set. Should it be set in the listen mode?
My code for initialization:
//Initialize Master EUSCI_B_SPI_initMasterParam param = {0}; param.selectClockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK; param.clockSourceFrequency = CS_getSMCLK(); param.desiredSpiClock = 4000000; param.msbFirst = EUSCI_B_SPI_MSB_FIRST; param.clockPhase = EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT; param.clockPolarity = EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW; param.spiMode = EUSCI_B_SPI_3PIN; EUSCI_B_SPI_initMaster(EUSCI_B1_BASE, ¶m); UCB1STATW |= UCLISTEN; //Enable SPI module EUSCI_B_SPI_enable(EUSCI_B1_BASE);
My code for testing:
unsigned char ByteCount= 0, dummy= 0, workingaddr= addr; P9OUT &= ~enpin; //CS //__delay_cycles(10); UCB1IFG &= ~UCRXIFG; EUSCI_B_SPI_transmitData(EUSCI_B1_BASE, addr); while (!(UCB1IFG & UCRXIFG)); dummy= EUSCI_B_SPI_receiveData(EUSCI_B1_BASE); while ( ByteCount < len ) { workingaddr += inc; UCB1IFG &= ~UCRXIFG; EUSCI_B_SPI_transmitData(EUSCI_B1_BASE, workingaddr); while (!(UCB1IFG & UCRXIFG)); data[ByteCount]= EUSCI_B_SPI_receiveData(EUSCI_B1_BASE); ByteCount++; } //__delay_cycles(10); P9OUT |= enpin; //CS