PDA

View Full Version : migrating to pic18f452 from 16f877a



tamersoss
- 7th June 2007, 22:43
Dear freinds ... I am making an ultrasonic range finder ... i used timer1 to measure the time of flight ... I succeeded using pic16f877a with resoltion 0.76 mm ... i am trying to double the resolution using a faster processor ... I am trying pic18f452 ... i bought a crystal with "40.000 kds 2l" printed on the head ... i used a define instruction to tell pbp about this frequency "DEFINE OSC 40" .... i used tis crystal oscillator with 2 (22pf) on each pin ... But unfortunately the mcu failed to communicate serially with the pc software i use to test the functionality of my system ...Please let me know if i have to use different values for the capacitors ... What do you suggest ?

Melanie
- 7th June 2007, 23:34
According to the Datasheet (always READ the Datasheet) Table 22-4 External Clock Timing Requirements, on Page 268 of DS39564A the maximum xtal speed in HS mode is 25MHz.

If you need to run at 40MHz, either (a) fit a 10MHz xtal and run 4xPLL (datasheet section 2.5), or (b) input 40MHz from a external oscillator with the PIC in EC or ECIO mode (Datasheet section 2.4).

tamersoss
- 7th June 2007, 23:50
Dear melanie .... i will try your suggestion ... i saw this table and i wondered why 40 mhz is not included ... you explained it ... the datasheet says at the very begining that max freq. is 40 mhz (not max external oscillator frequency) ... i will try and let you know the result ... however , many thanks for your kind concern.

skimask
- 8th June 2007, 00:54
Dear melanie .... i will try your suggestion ... i saw this table and i wondered why 40 mhz is not included ... you explained it ... the datasheet says at the very begining that max freq. is 40 mhz (not max external oscillator frequency) ... i will try and let you know the result ... however , many thanks for your kind concern.

It's probably not the PIC's fault that it won't run at 40Mhz, it's probably the circuit board's fault. The PIC will run all day at 40Mhz (55Mhz for one of mine that I pushed up a bit) even with an external 40Mhz. The key is a well designed 40Mhz external oscillator. There's a dozen reasons why a 40Mhz crystal won't run if it's not built right, especially if you're using one of those plastic solderless breadboards. Besides that, the external 10Mhz will keep down EMI over the whole circuit board.

Melanie
- 8th June 2007, 09:22
Are you saying that you've actually had a 40MHz xtal or resonator directly work with one of these (18Fxx2) PICs (which would contradict the maximum Datasheet figures)?

skimask
- 8th June 2007, 13:49
Are you saying that you've actually had a 40MHz xtal or resonator directly work with one of these (18Fxx2) PICs (which would contradict the maximum Datasheet figures)?

Yep, 40Mhz Xtal w/ 33pf cap's right next to OSC1&2 with a bit of a ground plane around the whole thing. Wasn't too reliable though. I'd touch practically anywhere the board and the PIC would lock up. That's when I read the rest of the datasheet (DS39564C) and found what you were saying about the 25Mhz earlier and fixed the whole thing.

As far as the 55Mhz goes, that was a 13.824Mhz oscillator, and using the 4xPLL, but that was also running the chip on 6.5v.

And this was the same chip that did 40Mhz with the external crystal. My guess is that this particular 18F452 chip was 'perfect', if not better, from the factory...a once in a lifetime good deal for me...not the norm obviously...

sougata
- 9th June 2007, 08:39
Hi,

Almost all of my 18F452 designs are based on x4 PLL mode. That is I use a 10MHz crystal and get a 40MHz Fosc. They have never let me down.