CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC18F47Q43 Fuse problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
dmitrboristuk



Joined: 26 Sep 2020
Posts: 55

View user's profile Send private message

PIC18F47Q43 Fuse problems
PostPosted: Thu Dec 14, 2023 2:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 14, 2023 3:21 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 14, 2023 3:28 pm     Reply with quote

That is, the value is taken from #use delay () and it doesn’t matter what happens in #fuse ?
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Dec 14, 2023 3:33 pm     Reply with quote

Maybe it might be the programmer changing the settings and/or you have 'debug' enabled ??
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Thu Dec 14, 2023 3:35 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 14, 2023 3:37 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 14, 2023 3:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 15, 2023 12:44 am     Reply with quote

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: 19539

View user's profile Send private message

PostPosted: Fri Dec 15, 2023 6:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Dec 15, 2023 2:58 pm     Reply with quote

Thank you, I didn't pay attention to this before
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Dec 16, 2023 4:58 am     Reply with quote

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..... Sad
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group