Tuesday, 4 November 2014

assembly - PIC 16F1503 - change the frequency of internal oscillator


My configuration bits are as follows:


#include  
__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?



Answer



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.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...