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
Solved! Go to Solution.
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 Jin Pan for you help. It works me now.
I'm going to open another ticket because now I don't succeed to trigger the DMA channel with SPI Rx.
Thanks
Hi,
can you see it?
Regards
OK mozilla did me some issues. On Chrome all is OK.
Let me test this project.
Thanks
No I dont see it at all
Thanks
Hi Mikael,
Please use File->import to open the project.
Regards
Hi,
Again, wich project ? In wich SDK ? Where to download it ?
It is not clear for me.
Thanks
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
Jing Pan please attach your project ...
Thank you very much, but where is the project ? Need I to generate a new FRDM framework from MCUxpresso ?
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
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