How to connect to a grayscale camera?

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

How to connect to a grayscale camera?

Jump to solution
2,178 Views
15219661324
Contributor III

Hi,

    I want to use RT1064 to connect MT9V022 and transfer image data using dma, but I don't know how to write the driver. 

Labels (2)
0 Kudos
1 Solution
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.
To provide the fastest possible support, I'd like to suggest that you can refer to the sci demo in the SDK library, in addition, the application note: AN12110 that describes how to develop an HD camera application, it's also worth for referring to.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

13 Replies
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Please contact with the camera vendor, they should provide the driver actually. And in general, they have a configuration tool to makes it easy to get the basic parameters for a specific set of video characteristics, just as the below shows.

pastedImage_1.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,830 Views
15219661324
Contributor III

Hi jeremyzhou‌,

   Thank you for your answer, which let me know a convenient tool for camera configuration. But I'm afraid that it didn’t answer my question. I realized that my question might be a little vague. Please allow me to reframe my question:

   When using K66, I connected the camera to a set of GPIO directly and transfer image data form port data input register using DMA. When using the RT1064, I find that GPIO doesn't seem to be included in DMA hardware request. I know I can use the CSI or the FlexIO to connect the camera, but I don’t know how to do that.

   So my question is how to initialize CSI or FlexIO to connect a camera and transfer image data.

   Hoping that you can answer me again.

   Thanks!

0 Kudos
1,831 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.
To provide the fastest possible support, I'd like to suggest that you can refer to the sci demo in the SDK library, in addition, the application note: AN12110 that describes how to develop an HD camera application, it's also worth for referring to.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,830 Views
15219661324
Contributor III

Hi jeremyzhou

Thanks for your reply. I have successfully received the image data through csi, but I have some new questions:

  1. I use the following code to initialize the CSI module by referring to fsl_csi_camera_adapter.c in the SDK library.

   csi_handle_t handle;

   CLOCK_SetMux(kCLOCK_CsiMux, 0);

   CLOCK_SetDiv(kCLOCK_CsiDiv, 0);

   csi_config_t csiConfig;

   CSI_GetDefaultConfig(&csiConfig);

   csiConfig.width = 188;

   csiConfig.height = 120;

   csiConfig.polarityFlags = (uint32_t)kCSI_HsyncActiveHigh | (uint32_t)kCSI_VsyncActiveHigh | (uint32_t)kCSI_DataLatchOnRisingEdge;

   csiConfig.bytesPerPixel = 2U;

   csiConfig.linePitch_Bytes = 188 * 2;

   csiConfig.workMode = kCSI_GatedClockMode;

   csiConfig.dataBus = kCSI_DataBus8Bit;

   csiConfig.useExtVsync = true;

   CSI_Init(CSI, &csiConfig);

   CSI_TransferCreateHandle(CSI, &handle, callback, NULL);

When I checked the data buffer(uint16_t), I found that two adjacent pixels of data was stored in the same word(16 bits). To separate them, I had to use the following code:

    LPUART_PutChar(LPUART1, (uint8_t)g_CSI_frameBuffer[count][i][j]);

    LPUART_PutChar(LPUART1, (g_CSI_frameBuffer[count][i][j]>>8));

So I wonder if there is a way to set it up for 1 byte per pixel when using 8 bit parallel mode.

I tried the following changes,

   csiConfig.bytesPerPixel = 1U;

   csiConfig.linePitch_Bytes = 188 * 1;

but failed(return at the following code in the CSI_Init function)

   if ((imgWidth_Bytes & 0x07) | ((uint32_t)config->linePitch_Bytes & 0x07))

   {

       return kStatus_InvalidArgument;

    }

 

  1. I wonder if there is a way to enter an interrupt after receiving a line of data.
  2. Where can I find the flexio camera demo in the SDK library?批注 2020-03-07 165209.png

   Hoping for your reply.

   Thanks!

0 Kudos
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.

1) 8-bit/pixel is supported.
2) I wonder if there is a way to enter an interrupt after receiving a line of data.
-- Please refer to the csi_fragment_gray demo to learn the interrupt handler.
3) Where can I find the flexio camera demo in the SDK library?
-- Please check the attachment.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,830 Views
15219661324
Contributor III

Hi, jeremyzhou

Thanks for your reply.

Where can I find the csi_fragment_gray demo in the SDK library?

Thanks!

0 Kudos
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.
1) Where can I find the csi_fragment_gray demo in the SDK library?
-- After checking, I find that there's no  csi_fragment_gray demo in the SDK library for the i.MX RT1064, however, I find the SDK library for the i.MX RT1050 has it.

pastedImage_1.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,830 Views
15219661324
Contributor III

Dear jeremyzhou,

Is the rom_api demo project  invisible now? I merge rt1060_rom_api project(downloaded from Littlefs on RT1064 internal flash) to the flexspi_nor_polling_transfer demo project. But I found it only runs successfully in debug target. Once I select the release target or flexspi_nor_debug target, it will not work properly(If I reset the MCU, it seems that the program will disappear). Can you help to test it ? The attachment is the project. 

批注 2020-03-22 205044.jpg批注 2020-03-22 211446.jpg

Thanks.

0 Kudos
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.
I was wondering if you can describe the steps of testing in detail, in addition, list the issues you encountered, as it will help me to figure it out.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,830 Views
15219661324
Contributor III

Hi jeremyzhou,

Thanks for your reply. Here are the steps of testing in detail: 

(1) I removed three files in the the original project and added four files f orm rt1060_rom_api project to the flexspi_nor_polling_transfer demo project.

0.jpg  1.jpg

(2) I commented all the Clock driver in bl_api.c since they had already been defined in fsl_clock.h.

pastedImage_11.png

    2.jpg

(3) I commented an enumeration member in flexspi_nor_flash.h since they had declared in fsl_flexspi.h.

pastedImage_13.png

pastedImage_15.png

(4) I add some codes in main.c.

pastedImage_29.pngpastedImage_26.pngpastedImage_27.png

(5) I hit the download and debug button.

The issues I encountered:

(1) It runs well in the debug  project configuration, but when I select the flexspi_nor_debug project configuration, it will show some warnings and errors, but I can receive some correct information from uart when debugging.

pastedImage_30.pngpastedImage_31.png

saaa.jpg

(2) In the flexspi_nor_debug project configuration, I can't receive any information if I press the restart key, just like the application is not downloaded in the internal flash or the application is gone. (I can receive ''hello word'' from uart if I press the restart key when I download hello_word demo project in the flexspi_nor_debug project configuration.)

In addition, the picture below is the development board I used, it doesn't has external flash or external sdram, so I wonder if there is a way to write and read user data in the on-chip flash. 

pastedImage_42.png

I'm sorry that it's a little wordy. Hoping for your reply.

Thanks!

0 Kudos
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.
I also encounter similar issues as you introduced, so I suspect that it's related to the porting work.
So I'd like to port the rt1060_rom_api project to the flexspi_nor_polling_transfer demo as you did before.
However, I don't encounter the issues this time, it works well actually.
I've attached the demo and please refer to it for details

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
1,830 Views
15219661324
Contributor III

Hi, jeremyzhou

Thank you all the time. I still encounter the same problem even if I use your project. Someone say I have to install an external sdram if I want the project works well. So I wonder if the external sdram is necessary?

Thanks!

0 Kudos
1,830 Views
jeremyzhou
NXP Employee
NXP Employee

Hi 陈 文龙,

Thanks for your reply.
1) So I wonder if the external SDRAM is necessary?
-- No, the SDRAM is unnecessary.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos