Part Number: MSP432P4111
Hi,
I'm using an MSP432P4111 to Tx SPI data using the DMA. I'm attempting to send data out at 12.5MHz CLK speed for the SPI clock (time for each bit), but at seeminly random times in the send, there is a bit or two of stretching or missed bit stepping out. I've walked my code back to a pretty simple setup, and I'll share the few sets of code I have.
My DMA code:
/* Configuring DMA module */ DMA_enableModule(); DMA_setControlBase(controlTable); int b; for(b = 0; b < 64; b++) data_array[b] = b; /* Setting Control Indexes. In this case we will set the source of the * DMA transfer to our random data array and the destination to the * CRC32 data in register address*/ DMA_setChannelControl(UDMA_PRI_SELECT, UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1024); DMA_setChannelTransfer(UDMA_PRI_SELECT, UDMA_MODE_BASIC, data_array, (void*) SPI_getTransmitBufferAddressForDMA(EUSCI_B2_BASE), 1024); /* Assigning/Enabling Interrupts */ DMA_assignInterrupt(DMA_INT1, 0); Interrupt_enableInterrupt(INT_DMA_INT1); Interrupt_enableMaster(); /* Enabling DMA Channel 0 */ DMA_enableChannel(0); FRAM1_CS_OUT |= FRAM1_CS_BIT; FRAM1_CS_OUT &= ~FRAM1_CS_BIT; /* Forcing a software transfer on DMA Channel 0 */ DMA_requestSoftwareTransfer(0);
My SPI setup code:
void init_SPI( void ) { // set up SPI port pins SPI_SEL0 |= (SPI_MISO | SPI_MOSI | SPI_CLK); // enable the special function on MISO, MOSI, CLK pins SPI_SEL1 &= ~(SPI_MISO | SPI_MOSI | SPI_CLK); // enable the special function on MISO, MOSI, CLK pins // SPI_DIR |= (SPI_MOSI | SPI_CLK); // set MOSI, SLK as outputs // SPI_DIR &= ~(SPI_MISO); // set MISO as input // set up SPI control registers SPI_CTLW0 = (EUSCI_A_CTLW0_UCSSEL_2 | UCSWRST); // hold port in reset, BRCLK = SMCLK SPI_CTLW0 |= (UCMST | UCSYNC | EUSCI_A_CTLW0_MODE_0 | UCCKPH | UCCKPL/*| UCMSB*/ ); // Master Mode, Synchronous Mode, 3-Pin SPI, CPH = 1, CPL = 0, LSB first // SPI_BRW = (Uint16)( /*SMCLK_HZ somethings not working right on this macro call...*/ / SPI_BAUD_DEF); // load baud default rate SPI_BRW = 1; SPI_CTLW0 &= ~UCSWRST; // initialize eUSCI SPI State Machine // set up SPI interrupt registers SPI_IFG &= ~(UCTXIFG | UCRXIFG); // clear rx/tx interrupt flags SPI_IE &= ~(UCTXIE | UCRXIE); // set rx/tx interrupt enable }
And my clock setup:
/* Configuring pins for peripheral/crystal usage and LED for output */ GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION); /* Setting the external clock frequency. This API is optional, but will * come in handy if the user ever wants to use the getMCLK/getACLK/etc * functions */ CS_setExternalClockSourceFrequency(32768,48000000); /* Starting HFXT in non-bypass mode without a timeout. Before we start * we have to change VCORE to 1 to support the 48MHz frequency */ PCM_setCoreVoltageLevel(PCM_VCORE1); FlashCtl_A_setWaitState(FLASH_A_BANK0, 2); FlashCtl_A_setWaitState(FLASH_A_BANK1, 2); CS_startHFXT(false); CS_startLFXT(false); // Assert the frequencies of MCLK, ACLK, HSMCLK, and SMCLK CS_initClockSignal(CS_MCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); // MCLK - 48MHz crystal CS_initClockSignal(CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); // ACLK - 32.768 kHz watch crystal CS_initClockSignal(CS_HSMCLK, CS_HFXTCLK_SELECT , CS_CLOCK_DIVIDER_1); // HSMCLK - 48MHz CS_initClockSignal(CS_SMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_4); // SMCLK - 48/2 = 24 MHz - datasheet says max 24MHz for UART/SPI/I2C input clock
I'm using this on the MSP-EXP432P4111 Launchpad, and I"ve tried two boards (one was brand new) and the same phenomenon is happening there too. I'm using the standard 48MHz crystal for my clocks, while dividing the SMCLK down to <24MHz (I saw another post that said to stay below 16MHz, so this should still be ok I think).
My Logic Analyzer is also showing me that the gap between bits is consistently at 1us apart - the box on the right shows the time between the two Vertical lines. I've attached that as well.
Let me know if there's any info I can provide that would help understand my problem. Thanks for the help on this,