View previous topic :: View next topic |
Author |
Message |
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
Enabling CLKOUT |
Posted: Thu Aug 11, 2022 9:56 am |
|
|
I'm using a PIC16F1823 and v5.109 of the PCWHD compiler. I am trying enable the CLKOUT feature that will output Fosc/4. I setup the pic as:
Code: |
#FUSES WDT //Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
#FUSES CLKOUT
//Set Clock speed
#use delay(internal=8MHZ,RESTART_WDT)
|
When I build the code, the list file indicates that CLKCOUT is disabled:
Code: |
Configuration Fuses:
Word 1: 3FDC INTRC_IO WDT PUT MCLR NOPROTECT NOCPD BROWNOUT NOCLKOUT IESO FCMEN
Word 2: 1EFF NOWRT PLL_SW STVREN BORV19 NODEBUG NOLVP
|
According to the data sheet, the only FOSC configurations that don't support this mode are LP, XT, and HS.
What am I missing? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Thu Aug 11, 2022 10:31 am |
|
|
Code: |
//Set Clock speed
#use delay(internal=8MHZ,RESTART_WDT)
#FUSES WDT //Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
#FUSES CLKOUT
|
Or:
Code: |
#FUSES WDT //Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES MCLR //Master Clear pin enabled
#FUSES NOCPD //No EE protection
#FUSES PUT //Power Up Timer
//Set Clock speed
#use delay(internal=8MHZ,RESTART_WDT, CLOCK_OUT)
|
The point is that the oscillator setting in #use delay, always defaults
to turning off clock out. The fuse is therefore being overridden by this.
So you either have to put the fuse after the use delay statement, or
tell this to enable the clock out. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1908
|
|
Posted: Thu Aug 11, 2022 10:34 am |
|
|
One more thing: ensure that if that particular processor has slew rate control/limiting, that it is turned off for that pin. It defaults to on.
Spent many hours trying to figure out why I couldn't see the clkout signal myself once, and the culprit was the slew rate control for that pin. |
|
|
SeeCwriter
Joined: 18 Nov 2013 Posts: 160
|
|
Posted: Thu Aug 11, 2022 12:53 pm |
|
|
Your suggestions worked. Thanks. |
|
|
|