PDA

View Full Version : PIC16F15355 config setting to work on internal OSC with clock 4MHz



eltra11
- 5th November 2020, 14:16
Anyone can help about how to realize to make 16F15355 work correctly with Internal Oscillator on 4MHz clock frequency.
How to adjust config 1 – 5 and other registers to realize that.
Here is a default configs from 16F15355.INFO file

MPASM __CONFIG Directive Options
;
; The PBP default configuration for the PIC16F15355 is:
;
; #CONFIG
; __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
; __config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
; __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_6 & _WDTCCS_SC
; __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
; __config _CONFIG5, _CP_OFF
; #ENDCONFIG

What have to be changed from Available __CONFIG labels for PIC16F15355 from 16F15355.INFO file in above configs?
Is it necessary to additionally add setting in OSCON1, OSCON2, OSCON3, OSCFRQ, OSCSTAT, OSCTUNE, OSCEN registers ?

Ioannis
- 9th November 2020, 21:07
I do not have this chip but maybe you should do also this:

OSCCON1=%00000011
OSCCON2=%00000011

So you will have a 32MHz/8=4MHz

You also have the FCMEN_ON which means that if your main clock is not working you will be informed to do something.

Ioannis

eltra11
- 10th November 2020, 10:57
Hi Ioannis
thank you very much, it works !

mpgmike
- 20th November 2020, 06:17
My understanding is that "FCMEN_ON" is only needed with an external oscillator. If it fails, the PIC reverts to INTOSC.

Also, if you just configure your OSCCON1 for 32 MHZ, you can then select 4 MHZ in OSCFRQ.

eltra11
- 24th November 2020, 21:37
Here are what I did according to Ioannis sugestion:
In Config word:
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON

;HFINTOSC with OSCFRQ= 32 MHz and CDIV = 1:1 - means Int.Osc 32 MHz
Then I put
OSCCON1 = %00000011 ' 32 MHz divide by 8 = 4MHz
OSCCON2 = %00000011 ' 32 MHz divide by 8 = 4MHz
DEFINE OSC 4

Do you mean that I have to do:
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON

;HFINTOSC with OSCFRQ= 32 MHz and CDIV = 1:1 - means Int.Osc 32 MHz
And then to define
OSCFRQ = %00000010 'by HFINTOSC Frequency Selection bits define 4 MHz Osc.Freq.
DEFINE OSC 4 'tell PBP that the operating frequency is 4 MHz

To be all correct with HFINTOSC is it FCMEN_ON or FCMEN_OFF

mpgmike
- 25th November 2020, 01:24
FCMEN is the Clock FailSafe Monitor for EXTOSC. If your crystal oscillator fails, FCMEN will revert to INTOSC, for safety sake. If you aren't running EXTOSC, you don't need FCMEN. It probably doesn't hurt having it on using INTOSC, though.

eltra11
- 25th November 2020, 09:59
Hi mpgmike
thank you very much on your suggestions and explanations.
Have a nice time