3
\$\begingroup\$

My configuration bits are as follows:

#include <P16F1503.inc> 
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _BOREN_OFF & _CLKOUTEN_OFF
__CONFIG _CONFIG2, _WRT_OFF & _STVREN_OFF & _LVP_OFF

The relevant part of code I am using for changing the frequency is this:

banksel OSCCON
movlw   b'01101000'     ; Int. osc. 4 MHz
movwf   OSCCON
btfss   OSCSTAT, HFIOFR ; Is internal oscillator running?
goto    $-1             ; No, loop one line back...
btfss   OSCSTAT, HFIOFS ; Is internal oscillator stable?
goto    $-1             ; No, loop one line back...

My debug tool is unfortunately just simulator. The problem is that execution never reaches the breakpoint on line 192:

enter image description here

So this means that internal oscillator never gets stable?

I am using:

  • IDE: MPLAB X IDE v1.20
  • Compiler: MPASM v5.45

What am I doing wrong?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Might be that the simulator doesn't simulate the HFIOFS bit. There are a couple of things it doesn't do. \$\endgroup\$ Commented Jun 13, 2012 at 11:58
  • \$\begingroup\$ Great.. That makes sense! \$\endgroup\$
    – PrimosK
    Commented Jun 13, 2012 at 13:32

1 Answer 1

2
\$\begingroup\$

If you are using the simulator, you must comment out those two tests for the oscillator running or being stable. Since you don't have any hardware running, the tests will always fail. They should be OK if you use a debugger like the PICkit 2/3 or ICD 3.

\$\endgroup\$
2
  • \$\begingroup\$ So the configuration bits and code I posted seems ok? \$\endgroup\$
    – PrimosK
    Commented Jun 13, 2012 at 13:32
  • \$\begingroup\$ It looks OK, I used something like it with the 16F1503. \$\endgroup\$ Commented Jun 13, 2012 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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