Request data transfer on falling edge of GPIO using eDMA in MK24FN256V

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

Request data transfer on falling edge of GPIO using eDMA in MK24FN256V

1,291 Views
narendrasuthar
Contributor I

Hi,

 

I want to interface OV2642 camera module with Kinetis MK24FN256V device.

I have connected camera data lines D0 - D7 with GPIO PORTC0 - C7, and other camera signals to other GPIO pins.

I have configured the eDMA for single byte data transfer on every falling edge of PCLK which is connected to PORTA pin # 12. I have configured interrupt for this pin for DMA request on falling edge (PORTA_PCR12 |= PORT_PCR_IRQC(0x02)).

The camera PCLK frequency is 1.6 MHz. Every DMA request I am transfering 1 Byte from peripheral to memory.

I am starting eDMA channel on rising edge of HREF and stop on falling edge of HREF. I am doing this for one frame.

I have configured the camera for JPEG image output. I am getting the JPEG image header and footer, but getting the image currupted or not clear. I think this is due to missing data during DMA transfer.

I need your help to capture image without missing data. Will you help me to cofigure the eDMA such that it will not miss the data? or suggest me example for eDMA transfer for Peripheral to memory on DMA request by GPIO pin.

 

I have attached my firmware bellow. This is in keil MDK5, Using SDK 1.3 and TWR-K24F120M development board.

 

Regards,

 

Narendra.

Original Attachment has been moved to: main.c.zip

Labels (1)
0 Kudos
10 Replies

971 Views
narendrasuthar
Contributor I

Hi Hui_Ma,

There was mistake in my function configuration.

I have set the number, the last parameter of Loop transfer function to 5, I am receiving the image header and footer.

But the image is still currupt. There is no change in image output.

Is there still any mistake to cofigure the eDMA?

If you will provide the example for the same, then it will be much helpfull.

Thanks,

Narendra.

0 Kudos

971 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

First of all,  sorry for the  so later reply.

Please check attached demo code, which call EDMA_DRV_ConfigLoopTransfer() function to finish read SIM_UIDL register four times with each time SW1 button pressed at TWR-K24F120M board.

Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

971 Views
narendrasuthar
Contributor I

adishieber​, YanVainter

Hi,

Thanks for you example.

I have configured the EDMA for loop transfer same as per your example.

I have to set the EDAM_CHAIN_LENGTH to 5. As this will calculate the major loop count.

majorLoopCount = totalLength / (bytesOnEachRequest * number);

As Major loop count = BUFFER_SIZE / (EDMA_TRANSFER_SIZE * EDAM_CHAIN_LENGTH);

Here destination buffer size is (80*1024) and major loop count define as uint16_t.

By this setting I can able to get the JPEG image header and footer. By setting EDAM_CHAIN_LENGTH to 1,I am not getting header footer also.

I need to transfer one byte on every falling edge of PCLK from camera IO(PORTC0 - C7) to buffer.  because I will get the valid data on camera IO on every falling edge of PCLK. And PCLK frequency is 1.6MHz. I have configured DMA request on the falling edge of PCLK.

PORTA_PCR12 |= PORT_PCR_IRQC(0x02); // Port A Pin # 12, PCLK, Flag and DMA request on falling-edge.

Is the DMA request rate high? Or is there any speed issue in data transfer?

0 Kudos

971 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Sorry for the later reply.

I do a test using a 2MHz square signal to trigger eDMA, there without any with DMA transfer.

In the test, each time I transfer only one byte from SRAM 0x1FFF001C address to SRAM 0x1FFF041C address with offset 1 byte, when the 2MHz square signal falling edge coming. The total transfer data size is 1K.

I could find the transfer result without any problem.

The eDMA request speed should match with your request.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

971 Views
narendrasuthar
Contributor I

Hi

Thanks for you reply.

As I had already performed the same test as you have done.

And got the success to transfer data.

As in this case, data will only transfer when MCU detect the falling edge of 2MHz square wave pulse.

Data will not transfer if pulse is not detected.

I think you should perform the same test by generating limited number of square pulse at 2MHz and check the result.

For Example, If you want to transfer 1K bytes at falling edge of pulse, than generate only 1K pulse only and check result.

In case of camera, data will change on every falling edge of PCLK, so, if MCU will miss that interrupt, than data will also lost.

Regards,

Narendra

0 Kudos

971 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Sorry for the later reply.

I do another test with TWR-K24F120M board.

During the test, I using 1.6MHz square signal with 1024 falling edge(pulses), then using these signal as trigger source will trigger eDMA response 1024 times as expected. And I could find there with 1024 bytes transferred.

I don't think there with eDMA response time limitation.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

971 Views
narendrasuthar
Contributor I

Hi,

Thanks for the reply.

Will you please share your code for the same?

Is there any other peripheral that affect the speed of DMA?

I am using UART for debug. I2C to configure the camera.

Regards,

Narendra

0 Kudos

971 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Please check attached eDMA code and GPIO toggle code (based on TWR-K60D100M).

I don't think peripheral could affect the eDMA trigger. After finish the eDMA configuration, the eDMA transfer is automatically without core intervene.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

971 Views
narendrasuthar
Contributor I

Hi Hui_Ma,

Thanks for you reply.

I have done as you suggested to configure eDMA for Loop transfer in place of Scatter/Gather. Below is the function I have used,

EDMA_DRV_ConfigLoopTransfer(&chnState, stcd, kEDMAPeripheralToMemory,

                                                 DMA_SOURCE_ADDR, (uint32_t)destAddr, 1, 1, sizeof(destAddr), 1);

But this is not working. By doing this now I am missing Image header and footer also.

Regards,

Narendra

0 Kudos

971 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Sorry for the later reply.

Could you try to use  EDMA_DRV_ConfigLoopTransfer () function instead for DMA transfer?

Scatter/gather mode need load new TCD into a channel, the loop mode will using major loop and minor loop, there doesn't need to load TCD during DMA transfer.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos