Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F4550 oscillator – Proteus Error

Status
Not open for further replies.

viki2000

New Member
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.
 
Am no expert on Proteus, but as far as I am aware you can only specify the frequency via the Edit box as show, it disregards any xtal on the osc pins for simulation functions.

000388.jpg
 
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.

If you look at the screenshots (pictures) in the folder Proteus from my link above, you can see that I did specify the CPU frequency in that Edit box inside the Proteus and I mentioned it 48MHz.

I want 48 MHz for the CPU and that should be mentioned inside Proteus where is that Edit box, isn’t’ it?

Then why do I see 4 MHz in your screenshot?
 
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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top