Hi ,
Is there an API in MCUxPresso which allows us to configure DMA for SPI with GPIO interrupt as trigger ?
I'm using K64 with SDK 2.1 .
Thanks
已解决! 转到解答。
Hi Mikael,
Unfortunately, There is no an example which can exactly meet you requirement. But I think its not a hard work. You can do it base on \SDK_2.2_MK64FX512xxx12\boards\frdmk64f\driver_examples\edma\memory_to_memory.
1. Enable the gpio dma request, such as
void BOARD_InitPins(void) {
CLOCK_EnableClock(kCLOCK_PortB); /* Port B Clock Gate Control: Clock enabled */
CLOCK_EnableClock(kCLOCK_PortC);
PORT_SetPinMux(PORTB, PIN16_IDX, kPORT_MuxAlt3); /* PORTB16 (pin 62) is configured as UART0_RX */
PORT_SetPinMux(PORTB, PIN17_IDX, kPORT_MuxAlt3); /* PORTB17 (pin 63) is configured as UART0_TX */
PORT_SetPinInterruptConfig(PORTC,6,kPORT_DMAFallingEdge);
SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_UART0TXSRC_MASK))) /* Mask bits to zero which are setting */
| SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX) /* UART 0 transmit data source select: UART0_TX pin */
);
}
2. Config the pin, just like:
PORTC->PCR[6] = (PORTC->PCR[6]&0xffff0000)+(1<<8)+(3);
GPIO_PinInit(PORTC,6,&dmatrig_config);
3. Set the SPI
4. Modify EDMA_PrepareTransfer(......, kEDMA_MemoryToPeripheral);
5. some work else...
Regards
Hi,
I made a example for you. It is base on FRDM-K64F.
If you trace into this project, you'll find that each time you push the sw2 button, DMA will move a data from srcAddr to destAddr[0].
Push the button 4 times, then the program will finish.
Hope this will give you some help.
Regards
Hi Mikael,
Unfortunately, There is no an example which can exactly meet you requirement. But I think its not a hard work. You can do it base on \SDK_2.2_MK64FX512xxx12\boards\frdmk64f\driver_examples\edma\memory_to_memory.
1. Enable the gpio dma request, such as
void BOARD_InitPins(void) {
CLOCK_EnableClock(kCLOCK_PortB); /* Port B Clock Gate Control: Clock enabled */
CLOCK_EnableClock(kCLOCK_PortC);
PORT_SetPinMux(PORTB, PIN16_IDX, kPORT_MuxAlt3); /* PORTB16 (pin 62) is configured as UART0_RX */
PORT_SetPinMux(PORTB, PIN17_IDX, kPORT_MuxAlt3); /* PORTB17 (pin 63) is configured as UART0_TX */
PORT_SetPinInterruptConfig(PORTC,6,kPORT_DMAFallingEdge);
SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_UART0TXSRC_MASK))) /* Mask bits to zero which are setting */
| SIM_SOPT5_UART0TXSRC(SOPT5_UART0TXSRC_UART_TX) /* UART 0 transmit data source select: UART0_TX pin */
);
}
2. Config the pin, just like:
PORTC->PCR[6] = (PORTC->PCR[6]&0xffff0000)+(1<<8)+(3);
GPIO_PinInit(PORTC,6,&dmatrig_config);
3. Set the SPI
4. Modify EDMA_PrepareTransfer(......, kEDMA_MemoryToPeripheral);
5. some work else...
Regards
Thanks for your reply but it doesnt work me.
I write a minimalist example, with a very simple memory to memory DMA transfer.
When I start it explicitly with EDMA_StartTransfer(&g_EDMA_Handle) so all is OK and I get the interrupt notification at the end of the transfer.
But when I configured my GPIO to be a trigger ( like that):
PORT_SetPinInterruptConfig(ADS_PORT, N_DRDY_PIN, kPORT_DMAFallingEdge /*kPORT_InterruptFallingEdge*/);
PORT_SetPinMux(ADS_PORT, N_DRDY_PIN, kPORT_MuxAsGpio);
GPIO_PinInit(ADC_GPIO, N_DRDY_PIN, &config);
and the DMAMUX0 like:
DMAMUX_Init(DMAMUX0);
DMAMUX_SetSource(DMAMUX0, 0, kDmaRequestMux0PortD);
DMAMUX_EnableChannel(DMAMUX0, 0);
EDMA_GetDefaultConfig(&userConfig);
EDMA_Init(DMA0, &userConfig);
EDMA_CreateHandle(&g_EDMA_Handle, DMA0, 0);
EDMA_SetCallback(&g_EDMA_Handle, _edma_cb, NULL);
EDMA_PrepareTransfer(&transferConfig, srcAddr, sizeof(srcAddr[0]), destAddr, sizeof(destAddr[0]),
sizeof(srcAddr[0]), sizeof(srcAddr), kEDMA_MemoryToMemory);
EDMA_SubmitTransfer(&g_EDMA_Handle, &transferConfig);
It doesnt work me at all ....
Please help.
Thanks