18f4685 oscon and freq question

Status
Not open for further replies.

large_ghostman

Well-Known Member
Most Helpful Member
hi, i want to setup a 18f4685 to use the 8MHz internal oscillator, and wanted to just turn a pin on and off and mesure the frequency of it. i am using the following program
Code:
#pragma config OSC = IRCIO67, PWRT = OFF, WDT = OFF, MCLRE = ON, DEBUG = OFF, LVP = OFF //..............Fuse stup
#include <p18f4682.h>
#include <stdio.h>
#include <delays.h>






 void main (void)
{
  OSCCONbits.IRCF0=1;
  OSCCONbits.IRCF1=1;
  OSCCONbits.IRCF2=1;
  Nop();
  while(OSCCON & 0x02); 
  TRISCbits.TRISC1=0;
//Nop();
while(1);

        {
          
            LATCbits.LATC1=1;
           
            LATCbits.LATC1=0;
            
        }
	
}

now my questions are 1. have i set it up correctly to use the internal 8MHz clock?
2. what would your best guess at the frequency be for this clock speed?
i the reason for asking is i put it on the scope and it seems wrong to me i am geting a 47-52 duty cycle (seems reasonable) but a frequency of around 75Hz this seems slow or is that about right?
many thank yous logan
 
Well first of all, you have a semicolon after the while(1). I'm pretty sure that shouldn't be there. Right now I think it's just getting stuck on the while(1); line.

Not sure about the rest of the setup. I'd have to read the datasheet
 
ok is working now, i have no idea what was wrong but after eraseing a few times and a reprogram i got better results
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…