PIC micro drives VGA monitor

Thread Starter

THE_RB

Joined Feb 11, 2008
5,438
I used a 10MHz xtal and HSPLL mode. That's very common and I have never seen a timing issue on the PIC output port.

Because the PIC only changes the port pins on a specific cycle out of the 4 cycles (I think it's the 3rd cycle?) that cycle always occurs at the same time period after the xtal cycle so the output port events at 10MHz are synchronous to the actual xtal at 10MHz.
 

peter_morley

Joined Mar 12, 2011
179
RB, I think that makes a significant difference. You are using a XTAL and the OP is not.
MrChips, can you explain how the two are different? In theory I should get the same output by setting the HFINTOSC to 16MHz then multiplying it by 4 with the HSPLL, as well as using a xtal at 16MHz then multiplying it by 4 with the same HSPLL. Is the xtal more stable than using the HFINTOSC?
 

MrChips

Joined Oct 2, 2009
30,824
RB is using a 10MHz xtal followed by the HSPLL to multiply the frequency by 4 to give 40MHz.

You are using the internal 16MHz RC oscillator to generate the 64MHz clock.
Xtal oscillators are extremely stable, to the order of 1 part per million, 1:1000000.
The internal RC oscillator would exhibit about 1% to 2% instability, that's 1:100.
That is 10,000 worse than a xtal.
 

Thread Starter

THE_RB

Joined Feb 11, 2008
5,438
RB, I think that makes a significant difference. You are using a XTAL and the OP is not.
Wow thanks for that MrChips, I completely missed that he is not using a xtal! Party because I never would have expected anyone to try to do such a timing sensitive app based on the internal RC oscillator.

To Peter_Morley, the first thing to do is put a xtal in there! :)
 

MrChips

Joined Oct 2, 2009
30,824
Wow. Both RB and I had made the assumption that the op was using a xtal.
The lesson to learn here is... Never assume anything!
 

peter_morley

Joined Mar 12, 2011
179
HAHAHA sometimes the smallest details mean a lot. I have only been programming pics since the fall so I am a little ignorant on common practice.
I will try the xtal when I get my hands on one I hope to bring you guys good news so I can start the fun part of this project!
 

peter_morley

Joined Mar 12, 2011
179
I have attached a table that shows oscillator modes.

On the table I only see the crystal being able to supply up to 40 MHz,
but on the summary page of the PIC 18F45K20 it says explicity:
"Four crystal modes up to 64 MHz".

Does this mean using a 16 MHz crystal then using the HSPLL multiplier set to 4 to achieve a 64MHz clock or does that mean I can connect a 64MHz crystal by itself?

Thanks for the continuous help again. Very grateful!
 

Attachments

Thread Starter

THE_RB

Joined Feb 11, 2008
5,438
You need a 2 pin xtal 16MHz, and two 22pF caps. It is all shown in the datasheet chapter on connecting a xtal.

The PIC osc CONFIG should be set to HSPLL mode.

I'm not very familiar with the 18F45K20 but I am pretty sure you cannot use a 64MHz xtal or 64MHz xtal oscillator. It needs to be a 16MHz xtal and HSPLL mode. :)
 

peter_morley

Joined Mar 12, 2011
179
I'm going by the info on page 385 of the spec sheet:
According to the above data sheet I could use an oscillator (4 pin) to set up a 64MHz signal using the EC mode.

EC mode would just be an external clock so oscillators and 555 timers would be okay to use for the EC mode?
 

John P

Joined Oct 14, 2008
2,026
Generally though, a 555 is pretty stable over a short term. You might have trouble setting it for an exact frequency, but for generating pixels for a display, I'd expect it to show straight vertical lines. What a processor does internally, I have no idea.
 

Thread Starter

THE_RB

Joined Feb 11, 2008
5,438
I'm going by the info on page 385 of the spec sheet:

Thanks for the info MrChips, I stand corrected! :)

The PIC 18FxxKxx series are very new and have a lot more oscillator options than the typical older PICs.

I would still be using a 16MHz xtal and the PIC HSPLL, as a 64MHz xtal can be fussy regarding PCB layout etc and forget about using one an a breadboard!

That was part of the reason for the PIC using lower freq xtals and HSPLL as a design preference as the lower freq xtals are much easier to work with.
 

peter_morley

Joined Mar 12, 2011
179
Thank you THE_RB and MrChips for your help and your patience. I received the 16Mhz xtal and set up the HSPLL.

IT WORKS!!! *fireworks and explosion sounds*

It is absolutely rock solid and not one pixel jitters at all. I would have never thought of putting a xtal in there to "tighten" up the clock.

Even though the solution was quite simple I have learned a lot from just trouble shooting the vga signal over and over again.

I feel I now have a better overall understanding of how a vga signal works and therefore will be better prepared for snags in the road ahead.

Hopefully I can repay you the favor by helping you guys out on your future problems!!! Haha probably not for a while but who knows. :D
 

MrChips

Joined Oct 2, 2009
30,824
Glad we can be of assistance.

I have a number of VGA projects planned that will be of interest to AAC members and hobbyists in general. We will begin with a primitive "Pong" game and then take it from there. I will call on your help when needed.
 

peter_morley

Joined Mar 12, 2011
179
Awesome! My beginning project is translating a bmp file to a text file with color byte data seperated by spaces using a C++ program.
I will have to obviously convert that color into 6 bit color.

So the next step is learning the read and write requirements of an exernal SRAM connected to the PIC. Should be a challenge but looking forward to it.
 
Top