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.

[PIC] mikroC pic18f45k22 externall oscillator

Status
Not open for further replies.

Karolina_1

Member level 3
Joined
Mar 10, 2017
Messages
67
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
639
Hi everyone
I was trying to blink led with external 8MHz oscillator but i cant succeed. I wrote the code in microC Pro and given below:

void main() {
TRISD= 0;
ANSELD=0;

do{
LATD = 0x00;
Delay_ms(300);
LATD = 0xFF;
Delay_ms(300);
}while(1);
}
Maybe i choose wrong oscillator selection. Did i connect oscillator correctly.
Configuration is given in the picture:
ff.PNG

Here is circuit:
kk.PNG

How can i make it work. I tried with internal 16MHz oscillator and its working fine but its too slow. i needed to increase it till 32MHz

Thank you
 

Code is good.

Configuration looks good.

Schematic is not complete (no power to the PIC), but no error in the partial schematic shown.

Attached is complete working project folder - proven good.

Guess the problem must be with your hardware..... how about posting a photo of your actual hardware?

Make sure that connections to the crystal and 22pF capacitors are very short in length. Leads longer than a centimetre or two may cause oscillator to fail.
 

Attachments

  • Forum.zip
    24.2 KB · Views: 72
Last edited:

Don't forget that the PIC18F family use 4 clock pulses for each instruction.
I don't know how your delay function works but if it is counting cycles then this may explain why you are getting a longer time than expected.
Susan
 
Susan picked up on your mention of internal oscillator that I missed....

If internal oscillator is acceptable for you, then why not run at 64MHz?

Read the oscillator section of the datasheet for the many different oscillator options available to you.

64MHz internal oscillator example is attached....
 

Attachments

  • Internal64MHz.zip
    24.8 KB · Views: 75
I did as you have explained above and it worked. It was helpful
 

External crystals will never be simulated. Stop posting that again and again. Frequency specified in model parameters. No external components needed. It is digital model. Don't mix it with analog one!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top