Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
1  
Might be that the simulator doesn't simulate the HFIOFS bit. There are a couple of things it doesn't do. – Rocketmagnet Jun 13 '12 at 11:58
Great.. That makes sense! – PrimosK Jun 13 '12 at 13:32

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
So the configuration bits and code I posted seems ok? – PrimosK Jun 13 '12 at 13:32
It looks OK, I used something like it with the 16F1503. – Leon Heller Jun 13 '12 at 15:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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