[SOLVED] System clock wrong in pic18f ?

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
30,557
I have some PIC18F1220 which I thought I would use up on a project.
In testing an output using a delay routine obtained from https://www.golovchenko.org/home/delay_loops , which I have used several times in the past, The time was entirely different from what it should be.
I made sure I had the system clock set OK, i.e. OSCCON = 0x60 (4Mhz) and CONFIG OSC= INTIO1 in order to 'scope the output on pin RA6.
Using the recently acquired FNIRS1-1013D, the wave form on RA6 displayed 2.32Khz?
I have used this PIC in past and do not recall any issues like this?
Any ideas of being something stupidly simple? :oops:
 

MrChips

Joined Oct 2, 2009
34,627
I have some PIC18F1220 which I thought I would use up on a project.
In testing an output using a delay routine obtained from https://www.golovchenko.org/home/delay_loops , which I have used several times in the past, The time was entirely different from what it should be.
I made sure I had the system clock set OK, i.e. OSCCON = 0x60 (4Mhz) and CONFIG OSC= INTIO1 in order to 'scope the output on pin RA6.
Using the recently acquired FNIRS1-1013D, the wave form on RA6 displayed 2.32Khz?
I have used this PIC in past and do not recall any issues like this?
Any ideas of being something stupidly simple? :oops:
Just a thought.
Try setting the oscilloscope TIME/DIV to the shortest time (highest frequency) and then switch it till you see the waveform.
 

Thread Starter

MaxHeadRoom

Joined Jul 18, 2013
30,557
Just a thought.
Try setting the oscilloscope TIME/DIV to the shortest time (highest frequency) and then switch it till you see the waveform.
Damn it Sir! you were right!:cool:
The lower Freq. must have been an harmonic?
So now why doesn't the delay loops show correct, Maybe I need to do the same!! o_O
 

nsaspook

Joined Aug 27, 2009
16,249
I have some PIC18F1220 which I thought I would use up on a project.
In testing an output using a delay routine obtained from https://www.golovchenko.org/home/delay_loops , which I have used several times in the past, The time was entirely different from what it should be.
I made sure I had the system clock set OK, i.e. OSCCON = 0x60 (4Mhz) and CONFIG OSC= INTIO1 in order to 'scope the output on pin RA6.
Using the recently acquired FNIRS1-1013D, the wave form on RA6 displayed 2.32Khz?
I have used this PIC in past and do not recall any issues like this?
Any ideas of being something stupidly simple? :oops:
Add this: OSCCON=0b01100000; // 4Mhz internal clock

Never mind, seems you have the problem solved if you're actually getting the correct frequency on RA6. :D
 
Last edited:

Lo_volt

Joined Apr 3, 2014
370
Just a thought.
Try setting the oscilloscope TIME/DIV to the shortest time (highest frequency) and then switch it till you see the waveform.
I saw this many years ago when trying to look at a 40MHz clock with the scope down in the kHz range. The first clue was that, even though I was seeing what looked like a valid signal, I couldn't trigger properly. No matter where I set the trigger threshhold, the waveform would wander. Only as I turned up the sweep rate did I see what was going on.
 
Top