Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
You can't generate a color PAL signal in a 16F877, it isn't fast enough to generate the amplitude and phase changes needed at 4.433MHz rate.
It IS possible to generate simple graphics like color bars or a test card if you clock it at 4*Fsc and divide the clock by 4 to generate the color subcarrier but tis needs additional digital and analog circuitry.
That project doesn't use PAL, it just fiollows the timings of the PAL TV system. PAL (Phase Alternation Line) is a method of encoding color information in a way that makes it relatively immune to phase distortion. The link doesn;'t use color at all, it produces a monochrome picture.
To generate true PAL color you need to generate a signal from two AM modulators working from an I & Q subcarrier at 4.433619MHz and reverse the phase on alternate lines, there is nothing in the schematic to do this and the PICs are far too slow to do it in software.
It depends very much on what you want to display, you might be able to produce a PAL modulator using something like a dsPIC but it would be restricted in what else it could do at the same time. This is why dedicated PAL modulator ICs exist and why most PAL encoders use analog components. The timing of PAL signals has to be very precise and to produce different colors it is necessary to alter their amplitude and phase while keeping the frequency stable. It is possible to mathematically produce the correct waveforms but it's quite complicated and needs 'full time' processing so it can't be disrupted by other tasks. Consider for example that to generate one cycle at 4.433619MHz, a PIC like the 16F877 would have to be clocked at 35.47 MHz and that's just to output a subcarrier frequency without any syncs, color or other information.
You haven't got the syncs quite right. there are two fields, the 'odd; field and the 'even' field. Lines 1 to 312.5 are slightly different to lines 313.5 to 625. The half line is there to delay the second field so the lines interlace with each other. In true PAL, there are four fields because as well as the syncs, the color burst advances 90 degrees phase on each field but you probably don't want to worry too much about that.
Also don't forget that each picture line also has a blanking period consisting of a front and back porch, 11 cycles of color burst alternating in phase on each line and a sync pulse.
The higher resolution picture part is toggling one of the port pins, high = bright, low = dark. Normal PAL pictures have a video resolution reaching about 5MHz per pixel but as you only have a 20MHz clock and you need two instructions to raise and lower the pin signal and each instruction takes four clock cycles, the best you can achieve with a 20MHz clock is 2.5MHz.
I have not tried it myself but I hear that some people have managed to generate video using the UART in synchronous mode. When synchronous mode is selected, you have to provide an external UART clock which becomes the 'dot clock' to produce one pixel. Unlike async mode it doesn't add start and stop bits so you can use it as a video shift register and take the video from the TX pin.