RT1050 FlexIO OV7670 with TFT LCDdisplay

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

RT1050 FlexIO OV7670 with TFT LCDdisplay

No ratings

RT1050 FlexIO OV7670 with TFT LCDdisplay

RT1050 FlexIO OV7670 with TFT LCDdisplay

1 Abstract

Regarding the RT10XX flexIO collecting OV7670 camera data and displaying it on TFT LCD, in fact, the NXP official website has a very good application note AN12686, but the test is based on RT1010 and not EVK. It may be difficult for actual customers to test directly. When the author was supporting customers, I encountered customers who wanted to implement flexIO on RT1050 EVK to collect parallel port OV7670 data and display it on TFT LCD, which is the LCD with SPI interface, so this article gives the specific test results of the finished product, RT1050 flexIO and There are some differences between RT1010 flexIO. RT1010 flexIO has 8 shifters, but RT1050 only has 4 shifters, so some code modifications need to be made and transplanted to RT1050. Since it is going to run on MIMXRT1050-EVKB, you also need to consider the flexIO pins that can be used, modify the EVKB, and manually weld the relevant pins to configure the corresponding camera signals and LCD display signals.

This article mainly comes from problems encountered by customers during testing, so it provides specific hardware connections, software code sharing, test finished product results, etc.

2. Software and hardware prepare

Since AN12686 has given the principle in great detail, this article aims to give the differences and the specific conditions of working on RT1050-EVKB.

2.1 Hardware configuration

The platform is based on MIMXRT1050-EVKB revA1, OV7670 module, 2.4-inch TFT LCD LCD SPI serial touch TFT color screen ILI9321, with a resolution of 240*320.

    For the OV7670 module status and pin status, please check the article:   

RT1050 CSI OV7670 camera eLCD display

The camera module pins are as follows:

1_1.jpg

Fig 1

   TFT LCD picture:

2.jpg

Fig 2

Pin No

Signal

Description

1

GND

Power ground

2

VCC

Power 3.3V

3

CLK

SPI clock

4

MOSI

SPI data

5

RES

LCD reset

6

DC

LCD data/commander select pin

7

BLK

Backlight control switch, backlight is turned on by default, low level turns off the backlight

8

MISO

Touch data reading

9

CS1

Display selection pin

10

CS2

Touch selection pin

11

PEN

Touch interrupt signal

For LCD, this article only uses the display part and does not use the rough mold part.

Considering the pin layout of MIMXRT1050-EVKB, the application note flexIO1 is not used here, but FlexIO2 is selected. The actual RT1050-EVKB and OV7670 module and LCD connection pins are given below.

The connection between the LCD signal pin and the MCU MIMXRT1050-EVKB RevA1 signal pin is as follows:

LCD signal and pin

MIMXRT1050-EVKB revA1 signal and pin

GND

P1

GND

J24_7

3.3V VCC

P2

3.3V

J24_8

CLK

P3

GPIO_AD_B1_15(SPI3_CLK)

R98

MOSI

P4

GPIO_AD_B1_14(SPI3_MOSI)

R99

RES

P5

GPIO_AD_B0_02(GPIO1_IO02)

J24_2

DC

P6

GPIO_AD_B1_10(GPIO01_IO26)

J23_1

CS1

P9

GPIO_AD_B1_12(GPIO01_IO28)

R100

 

OV7670 signal pin and MCU MIMXRT1050-EVKB RevA1 signal pin connection situation:

0V7670 signal and pin

MIMXRT1050-EVKB revA1 signal and pin

OV7670_D0

P3

GPIO_B0_05(FLEXIO2_D05)

SW5_1

OV7670_D1

P4

GPIO_B0_06(FLEXIO2_D06)

SW5.2

OV7670_D2

P5

GPIO_B0_07(FLEXIO2_D07)

SW5_3

OV7670_D3

P6

GPIO_B0_08(FLEXIO2_D08)

SW5_4

OV7670_D4

P7

GPIO_B0_09(FLEXIO2_D09)

SW6_1

OV7670_D5

P8

GPIO_B0_10(FLEXIO2_D10)

SW7_1

OV7670_D6

P9

GPIO_B0_11(FLEXIO2_D11)

SW6_2

OV7670_D7

P10

GPIO_B0_12(FLEXIO2_D12)

SW6_3

XCLK

P11

GPIO_B0_13(FLEXIO2_D13)

SW7_2

PCLK

P12

GPIO_B0_14(FLEXIO2_D14)

SW6_4

HREF(HS)

P13

GPIO_B0_15(FLEXIO2_D15)

R258/R324

VSYNC

P14

GPIO_AD_B0_03(GPIO01_03)

J24_1

I2C_SDA

P15

GPIO_AD_B1_01(I2C1_SDA)

J23_5

I2C_SCL

P16

GPIO_AD_B1_00(I2C1_SCLK)

J23_6

PWDN

P1

GPIO_AD_B1_02(GPIO1_IO18)

J22_7

RESET

P2

GPIO_AD_B1_03(GPIO1_IO19)

J22_8

3.3V

P18

3.3V

J22_7

GND

P17

GND

J22_8

In order to reduce the impact of the signal, MIMXRT1050-EVKB removes R323, R316, R309, and D6 on the board.

The physical connection situation is as follows:

3.jpg

Fig 3

2.2 Software configuration

Since the flexIO of RT1050 is different from the 8 shifters of RT1010, the DMA configuration needs to be modified. The difference code of flexio_ov7670 is as follows:  

static FLEXIO_CAMERA_Type s_FlexioCameraDevice = {
    .flexioBase = BOARD_CAMERA_FLEXIO_INST,
    .datPinStartIdx = BOARD_CAMERA_FLEXIO_DATA_PIN_START_INDEX,
    .pclkPinIdx = BOARD_CAMERA_FLEXIO_PCLK_PIN_INDEX,
    .hrefPinIdx = BOARD_CAMERA_FLEXIO_HREF_PIN_INDEX,
    .shifterStartIdx = 0U,
    .shifterCount = 4,
    .timerIdx = 0U,
};

static void configDMA(void)
{
    uint32_t soff, smod = 0u, size=0u;
    while(1u << size < DMA_TRSF_SIZE) /* size = log2(DMA_TRSF_SIZE) */
    {
        size++;
    }

    if(DMA_TRSF_SIZE == DMA_MINOR_LOOP_SIZE)
    {
        soff = 0u;
    }
    else
    {
        soff = DMA_TRSF_SIZE;
        while(1u << smod < DMA_MINOR_LOOP_SIZE) /* smod = log2(DMA_MINOR_LOOP_SIZE) */
        {
            smod++;
        }
    }
    
    /* Configure DMA TCD */
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].SADDR = FLEXIO_CAMERA_GetRxBufferAddress(&s_FlexioCameraDevice);
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].SOFF = soff;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].ATTR = DMA_ATTR_SMOD(smod) |
                                            DMA_ATTR_SSIZE(size) |
                                            DMA_ATTR_DMOD(0u) |
                                            DMA_ATTR_DSIZE(size);
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].NBYTES_MLNO = 16;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].SLAST = 0u;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].DADDR = (uint32_t)(*pFlexioCameraFrameBuffer);
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].DOFF = 8;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].CITER_ELINKNO = DMA_MAJOR_LOOP_SIZE;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].DLAST_SGA = -OV7670_FRAME_BYTES;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].CSR = 0u;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].CSR |= DMA_CSR_DREQ_MASK;
    DMA0->TCD[FLEXIO_CAMERA_DMA_CHN].BITER_ELINKNO = DMA_MAJOR_LOOP_SIZE;

    /* Configure DMA MUX Source */
    DMAMUX->CHCFG[FLEXIO_CAMERA_DMA_CHN] = DMAMUX->CHCFG[FLEXIO_CAMERA_DMA_CHN] & (~DMAMUX_CHCFG_SOURCE_MASK) |                                     DMAMUX_CHCFG_SOURCE(FLEXIO_CAMERA_DMA_MUX_SRC);
    /* Enable DMA channel. */
    DMAMUX->CHCFG[FLEXIO_CAMERA_DMA_CHN] |= DMAMUX_CHCFG_ENBL_MASK;
}

The code structure adopts: the camera uses flexIO mode to collect DMA transfer. After collecting one frame, DMA stores the data into the buffer, and then displays one frame of data uniformly on the LCD.

Since there are many configuration codes for flexIO OV7670 and LCD SPI, we will not explain them one by one here. Please check the attached code source code for details.

There is a header file of horsepic.h in the code. This file is a 320*240 RGB565 picture of a horse. It is used to test the LCD display separately. Usually after connecting the LCD, you need to test the LCD display separately. You can use a fixed picture to get the display. , here is the method of converting the picture into a C array: First adjust the picture to the LCD resolution size, and then convert it through the LVGL online conversion tool, select CF_RGB565A8, but the RGB565 generated by this format will have 1 more byte each, you can do it yourself After deletion, it can be called by code:

https://lvgl.io/tools/imageconverter

Display horse picture code:

convert8to16();
ILI9341_FillPic(0, 0, OV7670_FRAME_WIDTH-1u, OV7670_FRAME_HEIGHT-1u, (uint16_t *)(horse16));

Display result:

4.jpg

Fig 4

3 Test result and summarize

   About RT1050-EVKB, use flexIO to collect OV7670 data and display the situation through TFT LCD. Please check the video for the specific code situation. Check the attached source code. You can see from the video results that the flexIO OV7670 camera data can be successfully displayed and the code can successfully run the function.

Labels (1)
Attachments
Version history
Last update:
‎11-04-2023 04:01 AM
Updated by: