Author Topic: 4 MHz oscillator with pic18f2550  (Read 6729 times)

0 Members and 1 Guest are viewing this topic.

Offline daliah

  • Contributor
  • Posts: 5
4 MHz oscillator with pic18f2550
« on: May 04, 2011, 04:17:55 pm »
Hi, I'm new in hardware stuff and I am using PIC microcontrollers.
I found an article where a 20 MHz crystal clock is used with pic18f2550.
I need to build the circuit as soon as possible, but i didn't find such a clock in the nearest store!!
I already have a 4 MHz crystal clock. Is it ok if I use it with pic18f2550??

Thank you.
 

Offline armandas

  • Frequent Contributor
  • **
  • Posts: 336
  • Country: jp
    • My projects
Re: 4 MHz oscillator with pic18f2550
« Reply #1 on: May 04, 2011, 04:32:55 pm »
Hi, I'm new in hardware stuff and I am using PIC microcontrollers.
I found an article where a 20 MHz crystal clock is used with pic18f2550.
I need to build the circuit as soon as possible, but i didn't find such a clock in the nearest store!!
I already have a 4 MHz crystal clock. Is it ok if I use it with pic18f2550??

Thank you.

It should fine as long as you set the configuration bits right. You might also have to use different load capacitors, although that should not be too critical.
 

Offline francisjoe45

  • Contributor
  • Posts: 5
Re: 4 MHz oscillator with pic18f2550
« Reply #2 on: May 04, 2011, 04:34:47 pm »
Check the datasheet, but I think it would work, you just have to remember to connect both pins in series with 33uF capacitors to the ground. Good luck!
 

Offline daliah

  • Contributor
  • Posts: 5
Re: 4 MHz oscillator with pic18f2550
« Reply #3 on: May 04, 2011, 04:59:59 pm »
Ok, thank you :)
 

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: 4 MHz oscillator with pic18f2550
« Reply #4 on: May 05, 2011, 01:23:40 am »
If you don't need precise frequency control and don't need USB, the PIC18F2550 has a built-in 8MHz oscillator that you can use.

Page 27 in the data sheet http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf

Offline daliah

  • Contributor
  • Posts: 5
Re: 4 MHz oscillator with pic18f2550
« Reply #5 on: May 05, 2011, 02:52:05 pm »
I do need USB, what min frequency can I use with it??
 

Offline dimlow

  • Frequent Contributor
  • **
  • Posts: 301
  • Country: gb
  • Likes to be thought of as
    • Dimlow Ponders
Re: 4 MHz oscillator with pic18f2550
« Reply #6 on: May 05, 2011, 03:10:20 pm »
Not 33uF No.... 27pF but it will work without in most cases

4Mhz for USB BTW you have to set the pll to get 48Mhz from 4Mhz

if you have just started then i would forget about USB for a few months
« Last Edit: May 05, 2011, 03:17:06 pm by dimlow »
 

Offline daliah

  • Contributor
  • Posts: 5
Re: 4 MHz oscillator with pic18f2550
« Reply #7 on: May 06, 2011, 05:58:28 am »
well dimlow I'm using 15 pF.

"if you have just started then i would forget about USB for a few months"...what do you mean by this???
 

Offline dimlow

  • Frequent Contributor
  • **
  • Posts: 301
  • Country: gb
  • Likes to be thought of as
    • Dimlow Ponders
Re: 4 MHz oscillator with pic18f2550
« Reply #8 on: May 06, 2011, 06:26:23 am »
what i mean is concentrate on learning what the pic can do for you and how you can use all its features first. Play , experiment. Dont just jump into USB, because you will get bitten. it can get very complex. The USB stack is not something that is easy to program. Even if using one of the built in stacks the come with you compiler ( I dont know what compiler your using you using) it can be still be quite complex.

If you jump right into USB before starting with the simpler aspects of the chip i think you would give up quite quickly and the experience of micro controllers will not be so enjoyable..
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 606
  • Country: it
Re: 4 MHz oscillator with pic18f2550
« Reply #9 on: May 06, 2011, 10:15:10 am »
If you really need USB in a short time (and the application to be developed is simple), I think the stack provided by Microchip is quite easy to use, in my experience it was one of the first things I dealt with about PICs. However, I agree with dimlow it's good to play/experiment a little with some other features before, although not strictly necessary. It depends much on your knowledge about programming and electronics.

You can use oscillator at 4MHz x 1 to 6, 10 or 12 (see figure 2-1 of the datasheet). For USB you need a stable and enough accurate oscillator (i.e. a quartz based one), so you can't use the internal (R-C) one.
« Last Edit: May 06, 2011, 10:16:41 am by scrat »
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline daliah

  • Contributor
  • Posts: 5
Re: 4 MHz oscillator with pic18f2550
« Reply #10 on: May 06, 2011, 11:37:17 am »
Thank you for your advice, I really appreciate it. You're 100 right, but the problem is that I need the USB right now because I have to deliver my project in less than a month. The good thing is that I found some coding that will help me.

I had the other option to work with serial comminication, but I don't have the serial port in my laptop, so I thought that it's easier to work with USB rather than converting from serial to USB because this might cause me problems.
Isn't it right??
 

Offline scrat

  • Frequent Contributor
  • **
  • Posts: 606
  • Country: it
Re: 4 MHz oscillator with pic18f2550
« Reply #11 on: May 06, 2011, 12:22:33 pm »
There are many simple serial to USB converters, devices or ICs to be embedded in the design.

If you plan to go with the MCU's USB peripheral, Microchip USB framework is a simple set including useful examples. In this case, since you don't need very high bitrates (as serial connection was an option) my advice is to try with the serial emulation.

Depending on which are the application and specs, one can help you choose between the various options.
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. - Elbert Hubbard
 

Offline metalphreak

  • Frequent Contributor
  • **
  • Posts: 815
  • Country: au
  • http://d.av.id.au
    • D.av.id.AU
Re: 4 MHz oscillator with pic18f2550
« Reply #12 on: May 07, 2011, 11:46:21 am »
You need to set the oscillator clock setting to NODIV aka Direct Input. The PIC uses a 4Mhz signal to generate all the clocks it needs. If you use an 8/12/16/20/24/40/48 Mhz crystal it needs to divide it by 2/3/4/5/6/10/12 to get 4mhz.

If you are using something like WinPic800 to flash the .hex file onto the device, you can change settings there to whatever configuration you need.

Offline Zad

  • Super Contributor
  • ***
  • Posts: 1013
  • Country: gb
    • Digital Wizardry, Analogue Alchemy, Software Sorcery
Re: 4 MHz oscillator with pic18f2550
« Reply #13 on: May 07, 2011, 05:18:24 pm »
If you need USB quickly and with a minimum of overhead, I would suggest using one of FTDI's modules, the FT232 for example.

http://uk.farnell.com/ftdi/um232r/evaluation-kit-usb-uart-ttl-ft232rl/dp/1146036


Offline Teknotronix

  • Regular Contributor
  • *
  • Posts: 145
  • Country: au
Re: 4 MHz oscillator with pic18f2550
« Reply #14 on: May 09, 2011, 12:37:18 am »
Hi,

I too use the 4Mhz crystal option on my USB projects with the PIC18F4458 (Same family as yours). I choose this setup over the 20Mhz you see in all the examples because, when running in XT mode, I read somewhere it results in lower dynamic currents due to less gain with the feedback inverter (can't find source of info). You will need 27pf caps or somewhere in that region, however consider that the higher the value, the longer the startup time.

Here are the config bits I use in my projects. You might need to change a few for your requirements:

#pragma config PLLDIV   = 1
#pragma config CPUDIV   = OSC1_PLL2
#pragma config USBDIV   = 2
#pragma config FOSC     = XTPLL_XT
#pragma config FCMEN    = OFF
#pragma config IESO     = OFF
#pragma config PWRT     = OFF
#pragma config BOR      = ON
#pragma config BORV     = 3
#pragma config VREGEN   = ON
#pragma config WDT      = OFF
#pragma config WDTPS    = 32768
#pragma config MCLRE    = ON
#pragma config LPT1OSC  = OFF
#pragma config PBADEN   = OFF
//      #pragma config CCP2MX   = ON
#pragma config STVREN   = ON
#pragma config LVP      = OFF
//      #pragma config ICPRT    = OFF
#pragma config XINST    = OFF
#pragma config CP0      = OFF
#pragma config CP1      = OFF
//      #pragma config CP2      = OFF
//      #pragma config CP3      = OFF
#pragma config CPB      = OFF
//      #pragma config CPD      = OFF
#pragma config WRT0     = OFF
#pragma config WRT1     = OFF
//      #pragma config WRT2     = OFF
//      #pragma config WRT3     = OFF
#pragma config WRTB     = OFF
#pragma config WRTC     = OFF
//      #pragma config WRTD     = OFF
#pragma config EBTR0    = OFF
#pragma config EBTR1    = OFF
//      #pragma config EBTR2    = OFF
//      #pragma config EBTR3    = OFF
#pragma config EBTRB    = OFF
#pragma config DEBUG    = OFF
Don't drone me bro!

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf