DMA/SPI Triggered by GPIO interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DMA/SPI Triggered by GPIO interrupt

Jump to solution
2,450 Views
mikaelelharrar
Contributor III

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

1 Solution
2,124 Views
jingpan
NXP TechSupport
NXP TechSupport

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

View solution in original post

12 Replies
2,124 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

I send it again...

2,124 Views
mikaelelharrar
Contributor III

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

0 Kudos
2,124 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

can you see it?

RegardsUntitledx.png

0 Kudos
2,124 Views
mikaelelharrar
Contributor III

OK mozilla did me some issues. On Chrome all is OK.

Let me test this project.

Thanks

0 Kudos
2,124 Views
mikaelelharrar
Contributor III

No I dont see it at all

Thanks

0 Kudos
2,124 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Mikael,

Please use File->import to open the project.

Regards

0 Kudos
2,124 Views
mikaelelharrar
Contributor III

Hi,

Again, wich project ? In wich SDK ? Where to download it ? 

It is not clear for me.

Thanks

0 Kudos
2,124 Views
jingpan
NXP TechSupport
NXP TechSupport

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

2,124 Views
mikaelelharrar
Contributor III

Jing Pan please attach your project ...

0 Kudos
2,124 Views
mikaelelharrar
Contributor III

Thank you very much, but where is the project ? Need I to generate a new FRDM framework from MCUxpresso ?

Thanks

0 Kudos
2,125 Views
jingpan
NXP TechSupport
NXP TechSupport

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

2,124 Views
mikaelelharrar
Contributor III

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

0 Kudos