OV7670, Generic STM32F103RC and ILI9341 display

What are you developing?
Post Reply
aster
Posts: 79
Joined: Thu Mar 30, 2017 2:41 pm
Location: bella italy
Contact:

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by aster » Sun Jun 18, 2017 10:05 pm

+1
(+∞ if you make it very simple to use :roll: )

User avatar
RogerClark
Posts: 6362
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by RogerClark » Mon Jun 19, 2017 1:06 am

If I can get it to work with Blue Pill and ILI9341 display, I will probably get some PCB's made

I'm also thinking of generally making a PCB which is has connections for Blue Pill and touch screen ILI9341 display + SD

User avatar
RogerClark
Posts: 6362
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by RogerClark » Tue Jun 20, 2017 12:31 pm

Just a quick update

I wired up my unbuffered OV7670 to a Blue Pill (lots of wires) and also connected an ILI9341 (even more wires)

I have compiled the LiveOV7670stm32 sources, without changing the optimisation settings (yet), and changed the code so that I'm using the Adafruit ILI9341 lib instead of the ST7735 library

I've also started to change the code so that the scan lines are sent to the ILI9341 in a different way to the ST7735, and I'm starting to see what look like images on the display, albeit the scan line length does not match the ILI9341 and I'm not setting the line position, and also I'm only sending the raw 8 bit data from the camera, when I think the display expects 16 bits per pixel hence the image of 2 lights in my ceiling looks like this ;-)
ov7670_ili9341.jpg
ov7670_ili9341.jpg (66.14 KiB) Viewed 218 times
But. I'm actually quite pleased with this, becuase the camera is obviously working, and the data is getting sent to the display.
The next thing I need to do, is to look in the ILI9341 library and find out how you send the Set Line Start command.
Then I need to work out how to process the 8 bit data from the camera into 16 bits to send to the display.
Well, I presume that the display is currently expecting 16 bits per pixel, but perhaps I'm wrong
If it does need 16 bit, I guess the best way to do this is via a LUT, and build a display buffer

I started to look at this, but it just made things worse , but as its now 22:30 its time to stop, as I'm sure things will work better tomorrow ;-)

User avatar
RogerClark
Posts: 6362
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by RogerClark » Wed Jun 21, 2017 8:28 am

I've done some more messing around with this, but there are strange things happening.

The display code seems to have NOPs in it, which I find really strange.

And when I try to just use SPI.dmaSend() to put the line buffer from the camera to the LCD, adding code to the function before it calls dmaSend() causes the image to get displayed differently

This is possibly why the compile option -O2 may be needed, but probably doesnt help me to get it working with the ILI9341

As the camera is set to run as QQVGA, and the display is QVGA, I tried changing the camera code to do QVGA 320x240, by duplicating the BufferedCameraOV7670_QQVGA class to make BufferedCameraOV7670_QVGA (and changed the values)

But if I try to send the pixel buffer to the display it seem to crash the code.

Looking at the maths of the data rates. The code is reading in data at 8 M bytes per sec (from the 8Mhz pixel clock as its 8 bits wide)

But it can only get sent to the display at 36Mhz, plus the overhead of the SPI setup.

So the only way I can see this working is using different lines from each frame.

i.e camera frame 1 use line 1 and send to the display, then wait for the next camera frame, and read only line 2 and send that to the display

But this results in a really low frame rate.

So perhaps some more complex scheme would work, e.g. read every 4th camera line and send it to the display and then offset by 1 line each frame % 4

User avatar
Pito
Posts: 1371
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by Pito » Wed Jun 21, 2017 9:05 am

An idea only - long time back I messed with a Ramdisk module - 8MB one, with only 11 signals lines - 8data and 3controls (plus 3.3V and Gnd).
It was used with retrobsd as swap and ramdisk. The max rd/wr speeds around 10MB/sec. Maybe useful as a frame buffer??
Attachments
fub and ramdisk.JPG
fub and ramdisk.JPG (71.59 KiB) Viewed 202 times
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 6362
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by RogerClark » Wed Jun 21, 2017 10:06 am

@pito

I also have the type of OV7670 which has the FIFO buffer chip on the back. Averlogic AL422B-PBF
http://www.frc.ri.cmu.edu/projects/buzz ... Sheets.pdf

As far as I can tell, it should be possible to write one frame from the camera, at 8Mhz, but then switch the clock down to 1Mhz to read the data from the FIFO

Or if that does not work, then just read the frame out line by line, i.e 1 line per frame, though this would be a lot slower

User avatar
Pito
Posts: 1371
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by Pito » Wed Jun 21, 2017 10:50 am

Could you stream the video from the module w/ FIFO to an sdcard, for example with an lower resolution?
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 6362
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by RogerClark » Wed Jun 21, 2017 11:13 am

I was thinking I could possible sub-sample the data already.

But I hoped to be able to get a full QVGA 320x 240 image onto the ILI9341
However at the moment the colours are all wrong, and I don't know if the camera is being initialised correctly or not.

The code seems to init the camera and report that its OK, its possible that its not really initialised completely correctly

I think the only way I can test this correctly is to order a ST7735 module from eBay
perhaps this module

http://www.ebay.com.au/itm/1-8-inch-1-8 ... 2456943464

And then compile and run the code using this display and confirm its all working OK.

And then try to get the ILI9341 display working
PS. Debugging is a pain. it calls "no interrupts" so USB stops. And also debugging realtime stuff like this is tricky if it relies on bizarre timings.

I will probably have to debug by sending data to Serial port

I may take a look at using daniel's STM32Generic and the STM DMA library, to perhaps try DMA'ing the GPIO into RAM rather than using the code full of NOPs

User avatar
Pito
Posts: 1371
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by Pito » Wed Jun 21, 2017 11:16 am

FYI - there are several modifications of the 7735 tft - green, black, red, ..etc. They differ in how they interpret colors, for example..
Pukao Hats Cleaning Services Ltd.

konczakp
Posts: 180
Joined: Thu Jul 14, 2016 4:17 pm

Re: OV7670, Generic STM32F103RC and ILI9341 display

Post by konczakp » Wed Jun 21, 2017 11:51 am

That's right, they differ but it is easy to change in the code how the screen is being initialized. There is something like init screen with blacktab greentab etc.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest