PDA

View Full Version : 12F683 EXTERNAL CRYSTAL CONFIG for DTMFOUT statement



jackberg1
- 17th March 2022, 18:38
Hello,
I currently using a 12F683 at 8mhz internal osc, with this code below and it's working fine no problem at all.

#CONFIG
; __config _INTRC_OSC_NOCLKOUT & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _BOD_OFF & _CP_ON & _CPD_OFF
#ENDCONFIG

OSCCON = $70 ; 8mhz

This is the config set from meConfig setup program:

#CONFIG
__config _INTOSC & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
#ENDCONFIG


Now I need to use the same 12F683 chip with an 16mhz and/or 20mhz external crystal,

What do I need to change to make it work at 16 or 20mhz external crystal, please provide both config 16 and 20mhz crystal.

Thank's to reply.

mark_s
- 17th March 2022, 22:20
At the top Define 16mhz or 20mhz

OSCCON = 0

In the config replace

_INTOSC or _INTRC_OSC_NOCLKOUT with _HS_OSC

jackberg1
- 18th March 2022, 00:27
Thank's Mark_s for the quick reply,

I did changed theses lines, but there's one thing is odd, I have to turn MCLRE_ON to "on" if it's "OFF" nothing is working properly
look at my listing, I did this to test if the Pic is running at 16mhz,

Cheer,


#CONFIG
__config _HS_OSC & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
#ENDCONFIG

OSCCON = 0
DEFINE OSC 4 ;RUN 4X 16MHZ CRYSTAL
;DEFINE OSC 16 ;RUN 1X 16MHZ CRYSTAL PAUSE 1000 = 1 SEC

ANSEL = 0 ; Set all digital PULLUP Resistor page:10
CMCON0 = 7 ; Analog comparators off

LED Con 0

DO ; main loop
TOGGLE LED
PAUSE 1000
LOOP
END

jackberg1
- 18th March 2022, 11:30
Thank's Mark_s for the quick reply,

I did changed theses lines, but there's one thing is odd, I have to turn MCLRE_ON to "on" if it's "OFF" nothing is working properly
look at my listing, I did this to test if the Pic is running at 16mhz,

Cheer,


#CONFIG
__config _HS_OSC & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
#ENDCONFIG

OSCCON = 0
DEFINE OSC 4 ;RUN 4X 16MHZ CRYSTAL
;DEFINE OSC 16 ;RUN 1X 16MHZ CRYSTAL PAUSE 1000 = 1 SEC

ANSEL = 0 ; Set all digital PULLUP Resistor page:10
CMCON0 = 7 ; Analog comparators off

LED Con 0

DO ; main loop
TOGGLE LED
PAUSE 1000
LOOP
END




----------------------------------------------- NEW CONFIG SEEM TO WORK ----------------------------------------------

IF DEFINE OSC 4 LED BLINK 2 times on-off / 1 sec FOR 16MHZ CRYSTAL
IF DEFINE OSC 8 LED BLINK 1 times on-off / 1 sec FOR 16MHZ CRYSTAL
IF DEFINE OSC 16 LED BLINK ON 1 SEC, BLINK OFF 1 SEC, FOR 16MHZ CRYSTAL

Let me know if this new config is correct.

Thank's again for comments.


; config setup from meConfig program
#CONFIG
__config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_ON & _CPD_OFF & _BOD_OFF & _IESO_OFF & _FCMEN_OFF
#ENDCONFIG


;OSCCON = 0
;DEFINE OSC 4 ;RUN 4X 16MHZ CRYSTAL
;DEFINE OSC 8 ;RUN 2X 16MHZ CRYSTAL
DEFINE OSC 16 ;RUN 1X 16MHZ CRYSTAL PAUSE 1000 = 1 SEC


ANSEL = 0 ; Set all digital PULLUP Resistor page:10
CMCON0 = 7 ; Analog comparators off


LED Con 0


DO ; main loop
TOGGLE LED
PAUSE 1000
LOOP
END