I am introducing my new video player made using an atmega32 microcontroller and nokia color LCD. I got a 65K color LCD from an old nokia 6030 mobile phone. I directly soldered 10 thin enamelled coper wire from the 0.5 cm square area of the thin flexible pcb of the LCD to a berg strip fixed on another board. For me it was the most difficult part of this project because I don't have any tiny tip soldering iron and an lcd connector (5x2) socket with me.

After that I interfaced the lcd with atmega32 via SPI. Then initialized the lcd and displayed some color patterns and confirmed the LCD is working.

Now my next step is to display a still image on the LCD. I used python image library to extract pixel information from any image file (jpeg, png etc) and I streamed it to avr via uart using pyserial and displayed the image successfully on the LCD with 16bit color depth.

After that I used an SD card to store the converted pixel information (132x132*2) bytes/picture. Then I interfaced the SD card with same SPI of atmega32 and displayed the image stored on it. I used FAT16 filesystem. The sd card part is not a problem for me because I have already done more projects on SD/MMC cards and I copied my previous code for that.

So after displaying the still image, I thought of making a slide show on the lcd. For that I wrote a python script to convert all images in a folder (on my pc) to a 132x132x2 byte files which is nothing but the uncompressed pixel information stored as new files. Then I copied all these converted files to SD card (file.lcd) and displayed them as an image slide show with 1 second time gap between each image.

Since I successfully did the image slide show, then suddenly the idea of making a video player came to my mind. Because video is nothing but a slide show at high frame rate.

Then I used ffmpeg to convert a sample video to frames at 15 frames/second & 132x65 resolution. Then I used my python script to convert each still images to pixel information at 16 bit/pixel. Here instead of making small small files, I just collected all the picture information of adjacent frames into a single file and named as my_video.lcd.Then I copied that file to memory card and modified the avr program to display it on the LCD. It access the FAT16 file system, then search for *.lcd files and if found, it returns the starting cluster address of that file and then stream that cluster to the LCD very fast. NOW VIDEO IS PLAYED (without audio)!!!!! ....Almost half of the project is finished....Next half: (audio mixing)

I played 15 fps 16bit/pixel on the lcd. Now comes the next headache. Video should have audio. :-(.... Then I started thinking how to include audio. I used ffmpeg(in pc) to extract audio from the video file to 8 bit mono wav. Since wav is uncompressed audio, it is easy to handle it using a microcontroller with hardware PWM. Then I modified my python script. I just opened the wav file and discarded the first 44 bytes (wav header) and then after that, I read the audio sample byte by byte and injected it in between the video information after some calculations(see the math below) related to the bit rate of both audio and video to decide the mixing ratio.
For the perfect audio video synchronization, I implemented an error correction code in the converter, which monitors the synchronization error while mixing the audio-video bytes and when the error reaches a threshold value equivalent, it writes a dummy audio sample instead of real audio sample and thus prevents the accumulation of error and thus perfect audio video synchronization is achieved for hours of continuous video playback..

Now in avr, i need to extract the audio and video and need to send the audio to an audio circular buffer which will be send to PWM using a timer interrupt and video directly to LCD. If any single byte mismatch occurred between the video and audio byte, every thing will get collapsed. I then modified the avr code to do as above and finallyI played video with audio! :-)

Math: (about audio video mixing)Video byte rate = 9 frames/second = 9*132*65*2 = 154440 bytes/secondAudio byte rate = 11000 bytes/secondVideo sample/ audio sample rate = 154440/11000 = 14.04It means, after every 14 bytes of video, I need to put a byte of audio sample in the final video file.So, It is fine, but there is a small problem... 14.04 means this .04 error which will accumulate on the way and will affect the audio video synchronization badly, it will be worst in long videos. To prevent this, I need to skip adding a real audio sample after every (1/.04) * 14 = 350 video bytes, when it reaches this value, I need to put a dummy audio sample, may be the previous sample itself. Thus the audio will not overtake the video due to the .04 error and thus audio video synchronization is achieved...

LCD controller:
I believe the LCD which I got from the original nokia phone have Philips PCF8833 controller. Because I did the coding according to that controller specifications. In some example codes, I found we need display invertion command, but in my case don't know why, no need to use display inversion.

If you are a beginner to microcontroller, you have to practice some basic programs and need to get familiarized with few modules like SPI, UART, PWM etc. After that you can try this type of projects. That is what I do....

Mr vinod could we have a hand some lcd backlight circiut for the lcd or would an external dc supply + 7v adjustable by a diodebank in series(drops .7v each) coud do the job ,is there a bit of sophistication out there like using PWM routines ,or is it only in case of contrast controll . (joseandjust@gmail.com)

u hav'nt mentioned the chipselect connection in your diagram,would this mean you made some other pin to routine the SPI signals.....for the mmc and lcd,also please mention in your schematic the role of PB3,PC4,the second MOSI and SCK linking the LCD

Sir I am Confused why you use "PYTHON" Scripting Language for ATMEGA32 Microcontroller I mean if I am not wrong then to program "Microcontroller " we need .asm or .c code and not the phython..............please help