RT1015 - FlexIO Camera Demo

cancel
Showing results for 
Search instead for 
Did you mean: 

RT1015 - FlexIO Camera Demo

540 Views
variable_andrew
Senior Contributor I

I found mentions of a FlexIO Camera Demo for NXP's Kinetis processors, but from what I could find - there isn't any similar demo provided with the 2.5.0 SDK for the RT1015 / RT1020 parts. 

Has anyone ported this demo over to the RT series devices?

I'm looking for a similar reference to start from:

FlexIO w/ data coming in from pins in parallel, sampled on the positive edge of an external clock... signalled by another external pin for start/stop. 

Labels (2)
Tags (1)
11 Replies

242 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Please check attached RT1020 FlexIO camera demo, which use the FlexIO to emulate camera interface to capture video frames, and display the frames on a TFT LCD panel.

Wish it helps.

best regards,

Mike

242 Views
variable_andrew
Senior Contributor I

Hi Hui_Ma

Thanks again for this demo - I'm working on converting this to work for my setup (RT1015 to a camera a 12 pin data interface (+line valid / frame valid). 

Could you help me understand a few things?

1.

For the 12 bit data - can you confirm the only change there needed is the parallel data width?

Would I need to change anything w/r/t the number of shifters the demo uses (currently 4)?

In fsl_flexio_camera.h - I updated: 

/*! @brief Define the Camera CPI interface is constantly 12-bit width  <-- Andrew updated from 8 . */
#define FLEXIO_CAMERA_PARALLEL_DATA_WIDTH (12U)

2.

Can you give advice on how I can break / interrupt after just a single line instead of a full frame of all lines?  (it seems that just swapping LV and FV (what you call HSYNC & VSYNC) and manually starting streaming / flexio didn't work for me.

My goal with this question is merely to view a single line in memory before it's overwritten (our memory footprint is very small).  

3. 

In the demo code, I don't see where the code tells the Ov7670 to actually start streaming, does streaming start at the end of 

ov7670_status_t OV7670_Init(ov7670_handler_t *handleconst ov7670_config_t *config)

?

Thanks!

-Andrew

0 Kudos

242 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Sorry for the delay reply.

Please check the author's feedback:

1. Sorry. The FlexIO camera interface does not support 12-bit camera by default. To support a 12-bit camera, the driver and the project required several modifications, not just the macro FLEXIO_CAMERA_PARALLEL_DATA_WIDTH.

  • The macro should be changed to be 16, instead of 12.
  • Modify the driver code: fsl_flexio_camera.c -> FLEXIO_CAMERA_Init()

timerConfig.timerCompare = 8U * base->shifterCount - 1U;

to be:

timerConfig.timerCompare = (64 / FLEXIO_CAMERA_PARALLEL_DATA_WIDTH) * base->shifterCount - 1U;

  • Update the pin-mux configuration based on your hardware to provide successive 12 FlexIO pins for the data input.

I haven't used a 12-bit camera before. There may be other modifications needs to be done.

 

2. To break / interrupt after just a single line or several lines:

  • Use a ping-pong buffer, one for receiving from FlexIO with DMA, and the other for processing
  • Modify the macro DMA major loop size to transfer single/several lines, and generate a DMA interrupt after the transfer is done.
#define DMA_MAJOR_LOOP_SIZE (OV7670_FRAME_WIDTH * OV7670_BYTES_PER_PIXEL / DMA_MINOR_LOOP_SIZE)

Enable DMA interrupt in the flexio_ov7670.c -> configDMA() function: 

DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].CSR |=DMA_CSR_INTMAJOR_MASK;
  • In the DMA ISR, clear the flags and target the DMA destination address to the other buffer.

 

3. OV7670 automatically starts streaming once the XCLK is provided.

Wish it helps.

best regards,

Mike

242 Views
variable_andrew
Senior Contributor I

Aaaaand - I got the major loop IRQ working now - was missing this:

    //Enable Interrupt from DMA:
    /* Enable interrupt in NVIC. */
    EnableIRQ(DMA0_DMA16_IRQn);

So I'm good to go for now. Thanks again. 

0 Kudos

242 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Andrew,

Quite sorry for the delay reply.

I just back from my PTO.

Nice to hear the progress.

Please let us know if there with any issue about this application. Thanks.

best regards,

Mike

0 Kudos

242 Views
variable_andrew
Senior Contributor I

Hi Hui_Ma

So using an extra buffer to save "last capture" before it's overwritten by the DMA - it looks like I'm getting valid data in - so scratch my previous post about the 12 bit issue... 

(I see data at around 2500 (max 12 bits) when pointing the camera directly at lights, and then data values dropping to 100~200 when covering the lens). 

So I'm just back to trying to figure out how to get the DMA interrupt @ end of transfer. 

Will consider rewriting the FlexIO->DMA->buffer code w/ a similar flow as the DMA SDK demos if there aren't any other suggestions?

0 Kudos

242 Views
variable_andrew
Senior Contributor I

One further bit of follow-up. 

Looking at the RT1020 RM, it appears that I should revert the PWIDTH to:

#define FLEXIO_CAMERA_PARALLEL_DATA_WIDTH (12U)

as per the PWIDTH description that appears to indicate that the FlexIO module auto-handles configuring the correct # of pins, and then sets the shift accordingly:

Screen Shot 2019-10-03 at 12.16.37 PM.png

That said, setting PWIDTH to 12 (but leaving the TIMCMP correct via:

    timerConfig.timerCompare    = 2 * ((32 * base->shifterCount /*bits across 4 shifters*// 16 /*bits per pixel */- 1U;

still gives me data that's outside the 12 bit bounds.

Section 44.4.4.1 Parallel Interface states that PWIDTH < SHIFTSIZE should get prefixed with 0's by the FlexIO module, but I'm getting data like this:

Screen Shot 2019-10-03 at 12.22.39 PM.png

0 Kudos

242 Views
variable_andrew
Senior Contributor I

In order to try and get the DMA interrupt, I've also tried calling: 


    FLEXIO_CAMERA_EnableInterrupt(&s_FlexioCameraDevice);

from void FLEXIO_AS0330Init(void), which is my version of 

FLEXIO_Ov7670Init()

but this didn't help me get any interrupts...  

I also tried running this in main after the EDMA_Init call, but also no success (either directly calling the DMA0_DMA16_IRQHandler() or the EDMA_Callback()

   EDMA_CreateHandle(&g_EDMA_Handle, DMA0, 0);
   EDMA_SetCallback(&g_EDMA_Handle, EDMA_Callback, NULL);
   EDMA_ResetChannel(g_EDMA_Handle.baseg_EDMA_Handle.channel);

What might I be missing to trigger that DMA interrupt / or see it?

0 Kudos

242 Views
variable_andrew
Senior Contributor I

Hi Hui_Ma , 

Thanks for the detailed input!

I'm not seeing the DMA ISR get hit..., I'm using DMA0_DMA16_IRQHandler from the startup files.... is this not the correct ISR to "override"?

0 Kudos

242 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Andrew,

Quite sorry for the delay reply.

I need to check with related engineer for the detailed info.

I will let you know when there with any feedback.

Thanks for the patience.

best regards,

Mike

242 Views
variable_andrew
Senior Contributor I

Thanks Mike!

Going through it now

0 Kudos