View previous topic :: View next topic |
Author |
Message |
Woody
Joined: 11 Sep 2003 Posts: 83 Location: Warmenhuizen - NL
|
No CLKOUT while set as fuse |
Posted: Thu Mar 25, 2021 1:42 pm |
|
|
Hi all,
I'm using a (for me) new PIC (18F55Q43) and run into something that looks like either a compiler issue or me not getting it.
In short, the #fuses CLKOUT does not work.
-The PIC uses an external oscillator
-The PIC runs code (blink a led)
-I can toggle the CLKOUT pin (PIN_A6) so HW wise it seems fine.
-If I look at the config word (using CCS Device programmer SW) the
"Output clock on OSC2" in not selected.
- If I select this manually, save it to the .hex file, load and run it, the CLKOUT works.
So either I am forgetting something, or the compiler forgets something.
And another question that arose while researching this: is there a way to see what bits in the config word are set in the IDE itself?
Compiler 5.103 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Woody
Joined: 11 Sep 2003 Posts: 83 Location: Warmenhuizen - NL
|
|
Posted: Thu Mar 25, 2021 2:47 pm |
|
|
I cleared the slew rate setting for A but that does not make a difference. The entire option is still not activated in the configuration word.
Although with this PIC I run into a number of differences with chips I worked with before, I start to think this might be a compiler issue after all.
Thanks for the suggestion! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 25, 2021 7:31 pm |
|
|
Can you post a small compilable program that shows the problem ?
The program should have:
- #include for the PIC
- #device statements (if any)
- #fuses (if any)
- #use delay (if any)
- other items
- A very simple main() |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19563
|
|
Posted: Fri Mar 26, 2021 1:20 am |
|
|
I'd suspect the interlock is set wrong.
The CLKOUT fuse cannot be selected when you have XT, HS, or the LP
oscillator selected. It looks as if the interlock for this is set incorrectly,
so prevents the fuse being set all the time...
If I go and edit the device table (device editor), and ensure that this fuse
is setup correctly, I see:
Code: |
#include <18F55Q43.h>
#device ADC=12
#FUSES NOWDT //No Watch Dog Timer
#FUSES CLKOUT //enable clock out
#FUSES ECH //high speed external oscillator
#use delay(CLOCK=20000000)
void main()
{
while(TRUE)
{
}
}
|
Code: |
Configuration Fuses:
Word 1: FFFF ECH RSTOSC_EXT NOCLKOUT PRLOCK1WAY CKS FCMEN
Word 2: DFF7 MCLR NOPUT NOMVECEN IVT1WAY NOLPBOR BROWNOUT BORV19 ZCDDIS PPS1WAY STVREN NOLVP NOXINST
Word 3: FF9F WDTSW NOWDT WDTWIN_SW WDTCLK_SW
Word 4: FFFF BBSIZ512 NOBOOTBLOCK NOSAF NODEBUG NOWRTB NOWRTC NOWRTD NOWRTSAF NOWRT
Word 5: FFFF NOPROTECT
|
With the bit set to 1, which disables this.
If however I then change the setting in the device editor, so it has
[NO]CLKOUT 0100 0100 1
Which means that NOCLKOUT will give 0.
Code: |
Configuration Fuses:
Word 1: FEFD ECL RSTOSC_EXT NOCLKOUT PRLOCK1WAY CKS FCMEN
Word 2: DFF7 MCLR NOPUT NOMVECEN IVT1WAY NOLPBOR BROWNOUT BORV19 ZCDDIS PPS1WAY STVREN NOLVP NOXINST
Word 3: FF9F WDTSW NOWDT WDTWIN_SW WDTCLK_SW
Word 4: FFFF BBSIZ512 NOBOOTBLOCK NOSAF NODEBUG NOWRTB NOWRTC NOWRTD NOWRTSAF NOWRT
Word 5: FFFF NOPROTECT
|
With the bit set to off, the text still says 'NOCLKOUT'...
It seems to be ignoring the actual fuse value given from the code
completely, which is why I think it is the 'interlock'. So it permanently
sets the fuse to the 'NO' state, whatever you say. You can though get
it to go to '0', by overriding the setting with device editor, so it 'thinks'
the 'NO' state is 0 instead of 1.
I'd suspect the interlock is setup to 'allow' CLKOUT, when EC is selected
(which is how it works on chips without the slew control), but in this
chip where the external oscillator settings are ECL, ECM & ECH, this
doesn't then work...
So you can get working, by changing the fuse bit in device editor as I
show for now, but it needs to be reported to CCS, that this option is not
working on this chip. |
|
|
Woody
Joined: 11 Sep 2003 Posts: 83 Location: Warmenhuizen - NL
|
|
Posted: Fri Mar 26, 2021 2:16 am |
|
|
I raised this with support.
And I managed to not notice up to now that the fuse settings are stated way down at the bottom of the .lst file. I learned something today :-)
Thanks for the reaction.
Paul |
|
|
Woody
Joined: 11 Sep 2003 Posts: 83 Location: Warmenhuizen - NL
|
|
Posted: Fri Mar 26, 2021 9:14 am |
|
|
Turned out that the #fuses CLK_OUT is overridden by a subsequent #use delay() if that statement does not contain the option 'clock_out'. As it did in my code.
Adding the option solved my problem.
It is in the manual. What can I say. Read the fine thing? |
|
|
|