Content originally posted in LPCWare by Superfred on Sun Sep 21 08:21:17 MST 2014
Hi Parsa,
how did you capture the image, maybe a loop-style program?
The read timing is very critical (if you read too late you capture the next byte), I think this is your problem.
If the processor is handling an interrupt (for example Systick, Uart, ..) loop-style programs are halted and then read too late and the picture is garbled.
The best solution is DMA, here the read timing is independent from the processor. Im my case read at 30FPS at 160x120 resolution is no problem.
The other solution is the use of interrupts, here the PCLK interrupt must be set to high priority, otherwise you will loose bytes again.
I don't think that loop-style programs will ever succed to read camera data!
The next thing: For 160*120(QQVGA) colour resolution you need 38400 Bytes per frame, too much for the 32KB RamAHB32 block starting from 0x2007C000.
I avoid this problem by using only a Black&White images, here I can discard every second Byte in YUYV Format.
I do this by a nice trick: PCLK is connected to CAP1.1, I set LPC_TIM1->MR0 to 2 (instead of 1), so the Timer will drop every second PCLK cycle, so I only read the YY Bytes.
Other solutions: reduce resolution, do not read the whole frame or also use parts of the main RAM.
Conclusion: If you use interrupts or DMA, I can help you with example programs. The requirements to your hardware:
Connect PCLK to a CAP Pin (if possible P1.19=CAP1.1) and VSYNC to any of P0.x or P2.X (if possible P0.8) for Interrupt mode.
Additionally, connect the camera data to P2.0 - P2.7 for DMA.
For loop style programs I don't have examples, and I don't even want to think about any because I doubt they will ever work.
Fred