View previous topic :: View next topic |
Author |
Message |
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
PIC18F47Q43 Fuse problems |
Posted: Thu Dec 14, 2023 2:37 pm |
|
|
Cannot set bits for XT, LP, NOEXTOSC, ECL, ECM, ECH in configuration word 1 with any combination I only get HS (Versions 5.101 and 5.115)
I also tried manual using #fuses 1=0xXXXX unsuccessfully
Are there other installation methods using #org or #rom ?
Code: |
#FUSES LP, RSTOSC_HFINTRC_1MHz
|
Code: |
Configuration Fuses:
Word 1: FFFA HS RSTOSC_EXT NOCLKOUT PRLOCK1WAY CKS FCMEN |
|
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Dec 14, 2023 3:21 pm |
|
|
Code: |
#include <18F47Q43.h>
#device ADC=12
#FUSES NOWDT //No Watch Dog Timer
#use delay(internal=1MHz)
void main()
{
while(TRUE)
{
//TODO: User Code
}
}
|
Configuration Fuses:
Word 1: FFEC NOEXTOSC RSTOSC_HFINTRC_1MHZ NOCLKOUT PRLOCK1WAY CKS FCMEN |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Thu Dec 14, 2023 3:28 pm |
|
|
That is, the value is taken from #use delay () and it doesn’t matter what happens in #fuse ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Thu Dec 14, 2023 3:33 pm |
|
|
Maybe it might be the programmer changing the settings and/or you have 'debug' enabled ?? |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Dec 14, 2023 3:35 pm |
|
|
You wanted an example of the compiler setting it to something other than HS. That was the simplest. Tell the compiler what you want to use and let it pick the fuse settings. |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Dec 14, 2023 3:37 pm |
|
|
Code: |
#include <18F47Q43.h>
#device ADC=12
#FUSES NOWDT //No Watch Dog Timer
#use delay(clock=1MHz)
void main()
{
while(TRUE)
{
//TODO: User Code
}
}
|
Configuration Fuses:
Word 1: FFFF ECH RSTOSC_EXT NOCLKOUT PRLOCK1WAY CKS FCMEN |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Dec 14, 2023 3:44 pm |
|
|
Also if you plan to use this device be sure to read the errata.
PIC18F27/47/57Q43 Silicon Errata
Especially the SRAM readback
Quote: |
SRAM Readback
Following a device power up sequence, there is a possibility that some SRAM locations will not return the expected
written value but will read back '00' instead.
Work around
None. The device can only recover by power cycling.
|
|
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Fri Dec 15, 2023 12:44 am |
|
|
With //#use delay() disabled, all bits are set normally. I don’t understand why this was done. In addition to the source of oscillations, the CPU frequency is affected by the PLL and frequency postscaler. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Fri Dec 15, 2023 6:51 am |
|
|
dmitrboristuk wrote: | That is, the value is taken from #use delay () and it doesn’t matter what happens in #fuse ? |
Not true.
Three ways of working:
1) You set the fuses yourself, and just select 'clock' with #use delay
This will only override your fuses if they don't support the clock being
selected.
So:
Code: |
#include <18F47Q43.h>
#device ADC=12
#FUSES NOWDT, XT //No Watch Dog Timer, XT osc
#use delay(CLOCK=1MHz)
//gives
Configuration Fuses:
Word 1: FFF9 XT 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
|
Merrily selects XT.
2) Set the clock _before_ you set the fuses. Here what you tell the fuses
to be will override what #use delay says.
So:
Code: |
#include <18F47Q43.h>
#device ADC=12
#use delay(CLOCK=10MHz) //This will have selected HS
#FUSES NOWDT, XT //No Watch Dog Timer, XT osc
//But this in then over-riden by your setting - wrong, but proves the point.
Configuration Fuses:
Word 1: FFF9 XT 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
|
3) Don't set clock fuses at all. Let the #use delay control these.
So:
Code: |
#include <18F47Q43.h>
#device ADC=12
#FUSES NOWDT
#use delay(INTERNAL=1MHz)
//Will give
Configuration Fuses:
Word 1: FFEC NOEXTOSC RSTOSC_HFINTRC_1MHZ 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
|
The use of the right keywords with #use delay, and the _order_ of the
settings allows every possibility. |
|
|
dmitrboristuk
Joined: 26 Sep 2020 Posts: 55
|
|
Posted: Fri Dec 15, 2023 2:58 pm |
|
|
Thank you, I didn't pay attention to this before |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Sat Dec 16, 2023 4:58 am |
|
|
Oh, and one extra little thing. The reason the compiler defaults to HS mode
much more than you'd expect is in the errata for the chip. The XT oscillator
doers not work reliably above 2MHz on this chip family..... |
|
|
|