2

Author Topic: Pic18f4550 and oscillator config  (Read 889 times)

0 Members and 1 Guest are viewing this topic.

Offline extreme.alyTopic starter

  • Jr. Member
  • **
  • Posts: 47
  • Helpful? 0
Pic18f4550 and oscillator config
« on: February 27, 2013, 03:45:55 PM »
Hello,
Im fairly new to microcontroller and i need help in configuring pins, bits and codes to make my microcontroller (pic18f4550) run using 20Mhz at whatever prescaler..

I actually want to display text on my 16x2 lcd but i cant make the delays the library requires to make the lcd run properly..

Can i even make do it without an external oscillator? These terms in datasheet are killing me PLL, HS, XS and what not!

P.s im using mplab c..
Also suggest me whats better, mplab c or hi-tech?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,935
  • Helpful? 98
Re: Pic18f4550 and oscillator config
« Reply #1 on: February 27, 2013, 07:48:31 PM »
When you say "mplab c" I assume you mean C18 from Microchip. So, since C18 has been 'the standard' for PIC18F chips for a while this is probably best, there is a lot of example code written in C18.

Have you looked into and read through the Microchip User's forum? There would be lots of example code to start with plus lots of discussion on writing C18 code for PIC18F's including LCD displays.

HiTech C is what I have been using for PIC coding in C (I do mostly assembler). This compiler is being phased out and has been changed a bit to look more like C18. Also, both seem to being phased out in favor of Microchip's newer XC compilers.

Figuring out the CONFIG settings the first time is a bit mind boggling but its not that hard. The DS (data sheet) has a section describing the setting. Also, copy the CONFIG setting in the example C18 Code to get started.

Terminology:
 PLL = Phase Lock Loop and can be use to multiply the XTAL frequecy.
Look this up with Google or Wiki for more info and read the PIC DS.

HS, XT are PIC oscillator modes and are selected on the XTAL frequency as per the DS section (2.0 in the pic18f4550 DS) on the oscillator. Typically the XT mode is lower frequency XTALs, 4MHz or lower) and HS for High Speed XTALs, 4MHz or higher.

Be sure the read all the MPLAB Help/Topics as there is lots of good info there (very unlike typical Microsoft help). Next is to start with the example code found under the C18 install directory and also the C18 documents.

Lastly, MPLAB has a fairly good Simulator so that you can run or step code and examine any register or variable with hardware. This is a good place to get started to understand the code and the PIC's Hardware and requires nothing to buy.

As to the PIC hardware, download the documents for the Microchip Demo boards that can use the PICs you are interested in. The Docs include a full schematic and are very useful to learn how they should be wired. There are also some free sample code to go with the various Demo boards to see how to program.

 


Get Your Ad Here