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.

[SOLVED] PIC18F4550 hardware and software problem

Status
Not open for further replies.

AliRazoR

Advanced Member level 4
Joined
Oct 26, 2010
Messages
115
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,001
Hi

i am using pic18F4550, in MikroC i put Delay_ms(1000),it works on protuse but when i implement the circuit, it is not working properly. if i make Delay_ms(10000) it works.what is the problem.
(i need 1 second delay)

thanks in advance
 

Oscillator speed settings between MikroC, Proteus and circuit might be different.
 
i put 4mhz for prtous and MikroC, and also when i implemented the circuit , i put 4mhz
 

i am using pic18F4550, in MikroC i put Delay_ms(1000),it works on protuse but when i implement the circuit, it is not working properly. if i make Delay_ms(10000) it works.what is the problem.
(i need 1 second delay)

Describe "it is not working properly," is a peripheral not initializing properly. What exactly is not functioning?

In the physcial circuit a Delay_ms(10000) is 10 secs, not 1 sec, if your delay routines and clock settings are correct.

What type of OSC are you using in the physical circuit? Can you upload your code or better yet zip up the whole project, so we can examine it?
 
I use Crystal Oscillator, i will upload it for you.thanks
 

please help, i have to submit my project on Saturday.

---------- Post added at 17:13 ---------- Previous post was at 16:30 ----------

I found this on the net but i did not understand it, could you help me for 4MHz crystal what should i do?:

When you open your project, on the left hand side you have "clock" field where you need to put the speed your uC is running on. You can also go to project properties and set it there. Note that this is not always equal to the crystal speed.

For example, if you use PLL and your crystal is 10MHz the uC will run on 40MHz and not on 10MHz hence you have to enter 40000000 in that field and not 10000000.

The delay_*() functions generate delay loop relating to this field so if you enter wrong value there, all delay* functions will create "wrong" delay.

attached example pic
 

I've ran your simulation, as far as I can tell the delays are taking 10 secs not 1 sec to complete. The simulation runs at a fairly slow pace, due to these 10 sec delays.

You have the MCU clock speed set correctly, I've already checked.

Maybe the difference in the speed of animation is due to the Proteus system animation settings on your computer.

What type of computer system are you running Proteus on?
 
thanks for reply.

I know the proteus delay with the code that i gave you is 10sec, but when i program the pic and put it in the circuit, the delay is one second!!!!(i need one second delay in practical circuit)i want to know how i can calculate the delay???

Chapter 8: Other MCU's Circuits - Book: PIC Microcontrollers
 

Ok, now I understand your problem. Let me look over your code and see if there's a clock configuration or delay routine issue.

So the speed of the animation is acceptable, when you implement it in physical hardware it seem to run 10x faster, correct?

It's 11AM here, I'll get back with you late this afternoon.
 
simulation delay_ms(10000)= practical delay_ms(1000)

thanks so much.
 

One more thing, I do not have the MikroC compiler loaded on this system, I rarely use it. Can you check to see what the clock configuration setting is set to in the MikroC IDE?

Make sure it's set to HS, not HSPLL. If it is set to HSPLL, that is your problem.

---------- Post added at 18:13 ---------- Previous post was at 18:11 ----------

You are using an external 4MHz crystal correct? If not what are you using for your clock?
 
yes i am using 4MHz external.

 

Great, I see your problem, thanks for posting the screen shot. Because the 18F4550 has USB capability it defaults to using a PLL to synthesize a 96MHz clock signal. I'll have to move to the system with MikroC installed and see if I can figure out the best approach to dealing with the problem.

Basically your supplying a 4MHz OSC which is being multiplied several times over. Out of curiosity, enter 40.0000 (40MHz) in the Oscillator Frequency (MHz) box on the left. Then recompile and test the new code on your physical hardware.
 
again thanks.i will try it
 

Actually enter 48.000 (48 MHz) in the Oscillator Frequency (MHz) box on the left. I believe that is the actual system clock rate you are running.

It's all coming back to me now, the 18F4550 has always been the source of confusion when you're dealing with the system clock due to the USB requirements.

**broken link removed**
 
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 thankssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

you helped me so much.
we have to add this on the code:

Osccon=0x62; //for 4MHz I/P Xtal, for more information read datasheet section "oscillator configuration"
 

Great, I should have realized the problem as soon as I saw you were using a PIC18F4550 and the x10 difference on the delay routines. The system clock settings for that series of PICs has cause a great deal of frustration with a great many people.

Good Luck with your presentation.
 
mikroElektronika • View topic - 18F4550 MCU oscillator basics

---------- Post added at 19:07 ---------- Previous post was at 19:05 ----------

Great, I should have realized the problem as soon as I saw you were using a PIC18F4550 and the x10 difference on the delay routines. The system clock settings for that series of PICs has cause a great deal of frustration with a great many people.

Good Luck with your presentation.

thanksssssssssssssssssssssssssssssssssssss

have nice day, i wish you the best.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top