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
Hi.
I'm trying to work with the SPI-B2 with DMA transfer but the DMA does not start the transfers to the SPI TX buffer. i also connected a logic analyzer to the CLK and TX, RX pins, and there was nothing there.
here is the code i'm using:
// Init SPIB2 (P3.5-7) in master mode 3-wire, and DMA CH6 (Tx) DMA CH7 (Rx) and DMA's interrupts.
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P3, GPIO_PIN5 | GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION);
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
// use P3.4 as CSN for slaves
MAP_GPIO_setAsOutputPin(GPIO_PORT_P3, GPIO_PIN4);
MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P3, GPIO_PIN4);
P3OUT |= GPIO_PIN4; // set all CSNs to high (inactive)
// Configure SPIB2
//-------------------
MAP_SPI_enableModule(EUSCI_B2_BASE);
EUSCI_B2->CTLW0 |= EUSCI_B_CTLW0_SWRST; // Put eUSCI state machine in reset
EUSCI_B2->CTLW0 = EUSCI_B_CTLW0_SWRST | // Remain eUSCI state machine in reset
EUSCI_B_CTLW0_CKPL | // Set clock polarity high, CKPH=0. data sampled on the rising edge of the clock.
EUSCI_B_CTLW0_MSB | // MSB first, 8bit
EUSCI_B_CTLW0_MST | // Set as SPI master
EUSCI_B_CTLW0_MODE_0 | // 3-wire mode 00
EUSCI_B_CTLW0_SYNC | // Set as synchronous mode
EUSCI_B_CTLW0_SSEL__SMCLK | // use SMCLK
EUSCI_B_CTLW0_STEM ; // ignored in 3-wire mode, in 4 wire mode activates Slave enable signal.
EUSCI_B2->BRW = (US)(SMClock / SpiB2BaudRate); // fBitClock = fBRCLK/(UCBRx+1).
EUSCI_B2->CTLW0 &= ~EUSCI_B_CTLW0_SWRST;// Initialize USCI state machine - enable module
MAP_SPI_enableModule(EUSCI_B2_BASE);
/* Configuring DMA module */
MAP_DMA_enableModule();
MAP_DMA_setControlBase(DMAcontrolTable);
MAP_DMA_assignChannel(DMA_CH6_EUSCIB2TX1);
MAP_DMA_assignChannel(DMA_CH7_EUSCIB2RX1);
/* Setting up Buffer for TX primary */
MAP_DMA_setChannelControl(DMA_CH6_EUSCIB2TX1 | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1);
MAP_DMA_setChannelTransfer(DMA_CH6_EUSCIB2TX1 | UDMA_PRI_SELECT, UDMA_MODE_BASIC, &SpiB2_OutBuf[0],
(void*) MAP_UART_getTransmitBufferAddressForDMA(EUSCI_B2_BASE), 8);
/* Setting up Buffer for RX */
MAP_DMA_setChannelControl(DMA_CH7_EUSCIB2RX1 | UDMA_PRI_SELECT,
UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_1);
MAP_DMA_setChannelTransfer(DMA_CH7_EUSCIB2RX1 | UDMA_PRI_SELECT, UDMA_MODE_BASIC,
(void*) MAP_SPI_getReceiveBufferAddressForDMA(EUSCI_B2_BASE), &SpiB2_InBuf[0], 8); // Rx Data buffer
/* Enable DMA interrupt */
MAP_DMA_assignInterrupt(INT_DMA_INT1, DMA_CHANNEL_7);
MAP_DMA_clearInterruptFlag(DMA_CH7_EUSCIB2RX1 & 0x0F);
/* Assigning/Enabling Interrupts */
MAP_Interrupt_enableInterrupt(INT_DMA_INT1);
MAP_DMA_enableInterrupt(INT_DMA_INT1);
MAP_DMA_enableChannel(DMA_CHANNEL_7);
MAP_DMA_enableChannel(DMA_CHANNEL_6);
Thank you for any advice.
Hi,
Can you enter the DMA interrupt?
The problem can be that: 1. SPI doesn't work; 2. DMA don't work. If the data in SpiB2_OutBuf[] doesn't transmit to SPI TX register. I think it lies on DMA model configuration.
I advice you to use change the DMA channel to eUSCI_B2 TX0 and eUSCI_B2 RX0 for try.
Eason
Hi.
Thank you.
I changed the DMA channels to DMA_CH4_EUSCIB2TX0 and DMA_CH5_EUSCIB2RX0 and everything is working, but since channel 4, 5 are already in use with the UART i need to use
DMA_CH6_EUSCIB2TX2 and DMA_CH7_EUSCIB2TX2, but when i use this channels it simply doesn't work.
since using TX0, RX0 channels is working it means that the port initialization and setting are correct, and only the DMA does not function.
How do i operate the RX2 and TX2 channels?
thank you.
As I know, RX2 and TX2 is for SPI slave. As SPI master, you can only use RX0 and TX0.
My advice is that: use PMAP function to change another UART port or SPI port.
Eason
Thank you.
actually i need to use it as a slave, i was using it as a master to develop the communication protocol with loopback.
the PMAP function is very handy.
Hi again.
i implemented SPI SLAVE mode on TX0 channel and it works fine. but when i move it to TX1 or TX2 it does not work.
where can i find the documentation regarding the TX0,1,2 options?
thank you again.
Thank you.
That is what i suspected.
The question is: Can I move the B2 SPI port to B3 SPI port so I can use DMA 6 and 7 with B3_TX0 / B3RX0 ? (without changing the HW of course).
Shai.
Yes, for this you need to use port mapping function. If you want to use its default configuration, you need to change your hardware disign.
Eason
Yes.
Except that i don't see how i can map B2-SPI (P3.4-7 that i'm using in the HW) to B3-SPI so i can use the DMA.
shai.
Hi,
Please refer to the port mapping example code:
ti\simplelink_msp432p4_sdk_3_40_01_02\examples\nortos\MSP_EXP432P401R\driverlib\pmap_timera_redirection
Eason
**Attention** This is a public forum