Continue to Site

Welcome to EDAboard.com

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.

PIC18F4550 oscillator – Proteus Error

Status
Not open for further replies.

victoramas

Junior Member level 1
Joined
Jun 19, 2006
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,478
I have tried a simple project with LED blink on/off using PIC18F4550.
The compilers used are XC8 and CCS. I have used as IDE: MPLABX, CCS and Flowcode 7 (with XC8).
When the projects are burned on real device and I check with the oscilloscope the signal at pin RA0, then there is no problem.
If I use Proteus to simulate this simple project, then I have a problem when I use as oscillator for PIC18F4550 an external crystal + PLL internal to get maximum frequency 48MHz. I have tried various crystal values, but I remained at 16MHz, because this is what I have also in reality on the bench.
If the oscillator is set internal, then there is no problem with Proteus.
But if the oscillator is external, then the values seen with the virtual oscilloscope are not good.
I came to this simple project and I have tested it in various ways, because actually I was working on another project with I2C and I could not find the cause of the problem when was simulated in Proteus, which now is clear related with oscillator when is set external HS with PLL.
Below is a link with the pictures/screenshots and the projects used for LED blinking:

https://goo.gl/nPKKj2

I wrote this topic for 2 reasons:
- To share the problem found.
- To ask you if you are aware of the Proteus problem related with PIC18F4550 external oscillator and if you can double check it and confirm/refute my findings.
 

If you use 4 MHz Crystal with PLL then you have to mention Clock frequency as 4 MHz in Proteus. You should not mention 48 MHz. 48 MHz is USB Clock.
 

I guess there is confusion here about the PIC18F4550 clock(s).
There are 2 clocks for PIC18F4550: one for USB and one for CPU. They can relate.
I want the microcontroller to run at 48MHz for the program/instruction, the CPU clock (FOSC).
To achieve 48MHz we have to use an external crystal and set it as primary oscillator – datasheet page 34. OSCCON bits SCS1:SCS0=00. I tried with 20MHz and 16MHz crystal and of course different settings for configuration bits at division for PLL.
In the present examples I have chosen 16 MHz external crystal, then the division is 4, because we have to get 4Mhz before PLL – datasheet page 26:
https://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf
Then we get 96MHz after PLL and then for USB is divided by 2 and we get 48Mhz for USB, but is not my concern now.
The 96 MHz is also divided by 2 when we choose PLL postscaler CPUDIV equal with 2 and the CPU gets 48MHz.
When we work with internal oscillator, then we are limited at 8MHz for FOSC, forget about USB, is not what I am interested.
That is proved in reality on the bench with a real PIC18F4550 and a real oscilloscope.
The problem that I raised here is strictly related with Proteus.
I want PIC18F4550 CPU to run at 48 MHz in Proteus. That it fails.
So, why do you tell me about “4 MHz Crystal with PLL” and “you have to mention Clock frequency as 4 MHz in Proteus”?
I want 48 MHz for the CPU and that should be mentioned in Proteus too, isn’t’ it?
 

I’ve got the proof, the game ends here.
I have setup an I2C communication between PIC18F4550 as Master and PIC16F877A as Slave. All is done with MPLABX XC8 and then simulated in Proteus. And it works fine.
When the simulation starts, there is a message about PIC18F4550 saying:

[PIC18] PC=0x7EE0. The SCSx bits have been set. This feature is not modelled - the model continues to clock itself as before.


The SCSx bits are in OSCCON register, page 34 of the PIC18F4550 datasheet and set the system clock source:

bit 1-0 SCS1:SCS0: System Clock Select bits
1x = Internal oscillator
01 = Timer1 oscillator
00 = Primary oscillator

In other words, in Proteus, when you simulate PIC18F4550, you should use only internal oscillator, because the external oscillator is not modeled.

The_proof.jpg
 

Provide your project and I will fix it and explain it to you.

Frequency obtained after PLL is not assigned in Proteus. Only Crsyatl frequency should be assigned. I always do it in Proteus and it works fine for me.

When I use 64 MHz clock obtained from 16 MHz Crystal with 4x PLL then I only assign 16 MHz for clock frequency in Proteus and it works for me.

The SCSx bits are not problem in Proteus. Even though they are not modelled the Internal Oscillator will work fine.
 

That is a very nice offer from you. I would be happy if you can make it run.
Please see the Proteus project and the MPLABX XC8 code in the link below which I provided since the beginning with my first post:
https://goo.gl/nPKKj2

I just need PIC18F4550 to work proper with 48 MHz CPU frequency when the external crystal is 16MHz.
That’s all.

P.S. Please keep in mind that PIC18F4550 works with 48 MHz max. frequency and not 64 MHz, it uses PLL, you can have all kind of frequency crystals, even 20 MHz, but you must set some divisions in registers properly, so it is not as simple as only 4xPLL.
 

I didn't say I used 64 MHz with PIC18F4450. I use 64 MHz clock with PIC18F46K22.

Now checking your files.

Edit: I can't download from google drive. Zip all projects into one file and attach it here. Use Go Advanced > Manage Attachments button and attach file.
 

Here it is the zip file.
 

Attachments

  • Bug.zip
    1.1 MB · Views: 93

Did you try it?
Do you have any luck with it?
 

Yes, I tried it and yes there is a bug that you mentioned in Proteus latest version. 8.6.3 version.
 

I want 48 MHz for the CPU
Since PLL is running well in the real world, at least for the sake of simulation, appart from fuse settings you could consider forcing the frequency to 48MHz via F_CPU parameter, in the "source code" tab by right-clicking on the microcontroller component, and in the "project settings" submenu by changing the value of the "Clock for delays" field; Have you tried this?
 

I already mentioned that in post #2 and post #5 to use your crystal frequency for the MCU clock property.
 

You did indeed, but on post #2 you mentioned also USB besides the 48MHz and I wanted nothing to do with USB and created confusion for me.
In post #5 you mentioned only 4xPLL and PIC18F4550 has all kind of setup, divisions and that confused me second time.
You said it right, I understood it wrong.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top