This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP432P401R
Tool/software: Code Composer Studio
Hi All
I want to use a MSP432P401R to control two SPI slave devices in one SPI bus with separate chip select pins (other SPI buses on my 432 are occupied).
Question/Problem
I have no trouble to control these two devices when deploying my debug code from a launch pad to my final target (MSP432 on my PCB).
However, when I stop debug in CCS, reboot the target MSP432 and my PCB, only one SPI slave device work.
Trouble shooting steps
1. At the first, I wonder if the failed slave device takes long time after reset, I add some delay before calling the failed slave device, my problem still exists.
2. I swap the SPI calling order; the problem still exists.
3. I wonder if the code burning process does complete successfully; while all other devices controlled by the 432 on my PCB work.
Part of My code
const eUSCI_SPI_MasterConfig spiMasterConfigADF4351 = { EUSCI_A_SPI_CLOCKSOURCE_SMCLK, // SMCLK Clock Source 3000000, // SMCLK = DCO = 3MHZ 500000, // SPICLK = 500khz EUSCI_A_SPI_MSB_FIRST, // MSB First EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW, // CLK low when SPI not enabled for ADF4351 EUSCI_A_SPI_3PIN // 3Wire SPI Mode }; const eUSCI_SPI_MasterConfig spiMasterConfigAD8366 = { EUSCI_A_SPI_CLOCKSOURCE_SMCLK, // SMCLK Clock Source 3000000, // SMCLK = DCO = 3MHZ 500000, // SPICLK = 500khz EUSCI_A_SPI_MSB_FIRST, // MSB First EUSCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT, // Phase //EUSCI_A_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT, EUSCI_A_SPI_CLOCKPOLARITY_INACTIVITY_LOW, // High polarity EUSCI_A_SPI_3PIN // 3Wire SPI Mode }; // Typical 3 pin SPI initialization GPIO_setAsPeripheralModuleFunctionInputPin(ADF4351_SPIPort, ADF4351_SPICLK | ADF4351_SPISIMO | ADF4351_SPISOMI, GPIO_PRIMARY_MODULE_FUNCTION); SPI_initMaster(ADF4351_SPI, &spiMasterConfigADF4351); SPI_enableModule(ADF4351_SPI); GPIO_setAsOutputPin(ADF4351_CSPort, ADF4351_CSPin); // set chip select high as default value GPIO_setOutputHighOnPin(ADF4351_CSPort, ADF4351_CSPin); GPIO_setAsOutputPin(AD8366_CSPort, AD8366_CSPin); adf4351_initialization (ADF4351_SPI, ADF4351_CSPort, ADF4351_CSPin); SPI_disableModule(ADF4351_SPI); // re-config SPI since SPI master configurations of the two devices are different GPIO_setAsPeripheralModuleFunctionInputPin(AD8366_SPIPort, AD8366_SPICLK | AD8366_SPISIMO | AD8366_SPISOMI, GPIO_PRIMARY_MODULE_FUNCTION); SPI_initMaster(AD8366_SPI, &spiMasterConfigAD8366); SPI_enableModule(AD8366_SPI); AD8366_Set_Gain (4500, 4500, AD8366_SPI, AD8366_CSPort, AD8366_CSPin);
PS.
Software platform CCS 8.3.0.0009
Hardware: MSP432P401R launch pad -> JATG -> target MSP432P401R
Can you see any difference in the actual SPI waveform with and without debugger?
What is the actual SPI port you are using? AD8366_SPI?
Thank you,
Chris
Hi Chris
Yes. I did check the SPI waveform with an oscilloscope both with and without a launchpad.
The SPI waveform is correct. Now I suspect there could be something wrong in hardware.
While if you have any idea, please share your insight with me.
BTW, The SPI port I use is UCA2 (P3.1/3.2/3.3)
Thank you
Vincent
> GPIO_setAsOutputPin(AD8366_CSPort, AD8366_CSPin);
I don't see where you set the AD8366 CS pin initially low (inactive). The contents of the OUT register are undefined after Reset.
-------------------
When something succeeds in the debugger, but not without, the (first) Usual Suspect is timing. Are you making sure your transactions are complete (UCBUSY==0) before calling disableModule?
Hi Bruce
>> I don't see where you set the AD8366 CS pin initially low (inactive). The contents of the OUT register are undefined after Reset.
Thank you for pointing out. I set default value for AD8366 CS pin but the problem still exists.
Regards
Vincent
Hi Bruce
>> I don't see where you set the AD8366 CS pin initially low (inactive). The contents of the OUT register are undefined after Reset.
Thank you for pointing out. I set default value for AD8366 CS pin but the problem still exists.
Regards
Vincent
Be cautious on how the chip select is activated and deactivated relative to the spi communication. If you set it low after sending the last byte, it is possible that the CS is deselected before the actual last byte is transmitted. The TX IFG indicates that the TX buffer is empty and not that the byte was transmitted. Use the receive IFG to determine when the last byte is actually sent.
Regards,
Chris
Hi Chris
Thank you for the explanation. My problem is due to PCB design power supply circuit. When rebooting, its power sequence cause some unexpected long delay that leads to some chips not ready before MCU able.
I add some delay in my code as a workaround.
**Attention** This is a public forum