1
\$\begingroup\$

Internal oscillator of PIC16f884 doesn't change frequency in the following code:

#pragma config BOREN=0,IESO=0,FOSC=INTRC_NOCLKOUT,MCLRE=1,WDTE=0,CP=1,LVP=0

volatile unsigned char counter = 0;
void setup( void )
{
  ANSEL = 0x00; // all digital
  TRISD  = 0x00; // all RD is output


// 
OSCCONbits.IRCF2 = 0;
OSCCONbits.IRCF1 = 0;
OSCCONbits.IRCF0 = 0;
OSCCONbits.SCS = 1;

while(!OSCCONbits.HTS);

//interrupt timer0
IRCF0 = 1;
IRCF1 = 1;
IRCF2 = 1;

}

No matter what values I assign to OSCCONbits.IRCFx the clock speed (as measured with a blinky light) never changes... The only other way that this could seem to behave this way, is if _delay were to somehow adjust for constant time rather than clicks, but I don't think that is the case.

EDIT: I am dumb...

why doesn't this work

int i = 0;
int *p = &i;
i = 0 // no matter what i change this to i is always one.... dumb
*p=1
\$\endgroup\$
1
\$\begingroup\$

I am so dumb, I had set the Oscillator speed in a different part of code right after it, using the shortened syntax...

&(OSCCONbits.IRCF0) == &IRCF0

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.