SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By rulla
#196633
The OV7670 module with FIFO gives me bad color data. In particular, I use it in RGB565 mode, the green is the channel where I get what looks like an error: it seems that the 4th bit of the 6-bit green color data is stuck in "1" position; it never changes throughout the image, even if I put a lens cap to have a dark image. I have tried many many registers settings, and even tried the YUV colorspace instead of RGB565. Here you are G,R,B channels separately. It is clear that the green channel is wrong; using ImageJ to plot the pixels, I can count a mere 4 shades of green (they should be 64).
Green channel:
ImageSfereG.jpg
Red channel:
ImageSfereR.jpg
Blue Channel:
ImageSfereB.jpg
Do you have an idea of what' s going wrong? It should be EVERYTHING ok, registers, timing, color data conversion. The camera configuration code is at: https://os.mbed.com/users/rulla/code/OV ... f5d7c979cf , while the piece of code I use to convert data bytes to color is:

bank0 = cam.ReadOneByte();
bank1 = cam.ReadOneByte();
r=((bank1 & 0x1f)) ;
g= ((bank1 & 0xe0)>>5 ) |((bank0 & 0x7)<<3);
b=((bank0 & 0xf8)>>3 );

Thank you all for your time!
You do not have the required permissions to view the files attached to this post.