View previous topic :: View next topic |
Author |
Message |
Dax12R
Joined: 19 Dec 2010 Posts: 4 Location: Surrey
|
USE DELAY PIC18F45K50 Xtal medium - Hi power settings |
Posted: Tue Nov 19, 2019 5:25 pm |
|
|
My code stop setting the config options for some unknown reason.
If I used the following.
Code: |
#fuses HSM //High speed Osc, medium power 4MHz-16MHz
#use delay(clock=32M,crystal=8MHz) |
but the HSM fuse gets changed after the #use delay line.
if I place a copy of the #fuse line after the #use delay line it works.
Is there a way of setting Medium power OSC in the USE delay line ?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 19, 2019 7:29 pm |
|
|
Do it in this order.
Code: |
#include <18F45K50.h>
#use delay(crystal=8M, clock=32M)
#fuses HSM
//======================================
void main()
{
while(TRUE);
}
|
Then it gives you HSM, and that's the only thing changed in the Config Bits.
Quote: |
Configuration Fuses:
Word 1: E322 PLL4X PLLEN NOCPUDIV LS48MHZ HSM PRIMARY FCMEN IESO
Word 2: 3C5E PUT BROWNOUT BORV19 NOLPBOR NOWDT WDT32768
Word 3: D300 CCP2C1 PBADEN T3CKC0 SDOB3 MCLR
Word 4: 00A1 STVREN NOLVP ICSP2 NOXINST NODEBUG
Word 5: C00F NOPROTECT NOCPB NOCPD
Word 6: E00F NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 400F NOEBTR NOEBTRB
|
Tested with CCS vs. 5.091. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Wed Nov 20, 2019 2:03 am |
|
|
He already knows this.
Quote: |
if I place a copy of the #fuse line after the #use delay line it works.
|
He was asking if it was possible to get #use delay to default to selecting HSM.
I don't think it does. I also think it is 'right' not to do so....
By default #use delay selects the oscillator it thinks is 'right'. You can always
override this by adding the fuse afterwards (as PCM_Programmer shows).
Normally it's decision is 'right' often fixing incorrect clock selections.
In this case by default at 8MHz it selects HSM. But if you run the PLL it
switches to using HSH. Now this is interesting, if you look at the data
sheet, it does not show HSM as a legitimate option, if you are selecting
the PLL. (Table 3-1). It looks as if MicroChip want the extra drive of
HSH, when the PLL is used, and CCS have correctly realised/applied this.
It says that the PLL is off in 'all other modes'.
So it looks as if you should not use HSM with the PLL. However the data
sheet does not explicitly 'say' this, just having it in the table for PLL
selection. Obviously you can try it using the fuse after the setting as
PCM_Programmer shows, but be prepared that it may have some
issues at particular supply voltages/temperatures. I doubt if it actually
saves much power (given the CPU is running at 32Mhz), so it is
probably safer to use what the data sheet shows (as CCS do).
You may well find that with the HSM fuse selected, the PLL does not
actually enable. This is what Table3-1 implies. |
|
|
Dax12R
Joined: 19 Dec 2010 Posts: 4 Location: Surrey
|
|
Posted: Wed Nov 20, 2019 11:55 am |
|
|
Thanks for the replies
The odd thing is that the compiled hex code change without changing the source at all.
The only thing that has changed, is that I cloned the C drive from a small old SSD to a new one, same make and type.
I always seem to waste time over such little things.
Last one was Hours trying to work out why a PIC32MX would not even start
One look at the Addendum. Crystal input does not work.
How did that get past QA. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Wed Nov 20, 2019 12:12 pm |
|
|
I suspect you used a newer compiler.
Back in the 5.06x versions, the compiler used HSM if 8MHz was selected.
Then it was found to cause issues, with the PLL. They read the data sheet,
and switched to using HSH if you selected the PLL. Current compilers do this. |
|
|
|