View previous topic :: View next topic |
Author |
Message |
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
Solved: Compiler bug for PIC18F26K22 |
Posted: Thu Apr 14, 2011 11:47 am |
|
|
Just a heads up:
With the 4.120 compiler
I'm almost positive that the compiler has a bug at least for this chip. If you try to enable WDT either in hardware or under software control, it will not actually set the relevant config bits and you won't really have WDT enabled. You have to manually set the bits in the output hex file.
If anyone else is using a K22 chip it would be interesting to have confirmation if it's happening to anyone else or if an older compiler version doesn't mess up.
Last edited by collink on Thu Apr 14, 2011 1:09 pm; edited 1 time in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 14, 2011 11:50 am |
|
|
If using you're "ICD=TRUE", or the DEBUG fuse, or possibly other means,
this will put the PIC in debug mode, and WDT is not allowed in that mode.
It will be disabled for you (without informing you of this).
Are you in Debug mode ? |
|
|
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Thu Apr 14, 2011 11:56 am |
|
|
PCM programmer wrote: | If using you're "ICD=TRUE", or the DEBUG fuse, or possibly other means,
this will put the PIC in debug mode, and WDT is not allowed in that mode.
It will be disabled for you (without informing you of this).
Are you in Debug mode ? |
Shouldn't be either one.
I have "#fuse NODEBUG" and I do not have ICD=TRUE |
|
|
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Thu Apr 14, 2011 11:58 am |
|
|
In fact, for completeness, here are my fuses:
#fuses INTRC
#fuses WDT_SW //enable software control of WDT
#fuses WDT32 //32x prescaler
#fuses NOPLLEN //Allow the code to turn PLL on or off. Defaults to off
#fuses NOMCLR,NOWDT,NOBROWNOUT,BORV20,NOLVP
#fuses NODEBUG //don't enable chip level debugging
//fuses related to code and data protection:
#fuses PROTECT,CPD,CPB,NOWRT,NOWRTD,NOWRTB,NOWRTC,NOEBTR,NOEBTRB
I'm reasonably sure that those should all be kosher. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 14, 2011 12:35 pm |
|
|
This test program does set WDT in the Config bits. (With vs. 4.120)
Code: |
#include <18F26K22.h>
#fuses INTRC_IO, WDT, NOPLLEN
#use delay(clock=4M)
//===================================
void main()
{
while(1);
}
|
Quote: |
Configuration Fuses:
Word 1: E800 INTRC_IO NOPLLEN PRIMARY FCMEN IESO
Word 2: 3F1E PUT BROWNOUT BORV20 WDT WDT32768
Word 3: BF00 CCP2C1 PBADEN CCP3B5 HFOFST TIMER3C0 CCP2B5 MCLR
Word 4: 0081 STVREN NOLVP NOXINST NODEBUG
Word 5: C00F NOPROTECT NOCPB NOCPD
Word 6: E00F NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 400F NOEBTR NOEBTRB |
|
|
|
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
|
Posted: Thu Apr 14, 2011 12:46 pm |
|
|
Hmmm... I just noticed that I didn't update to 4.120 on this machine (it's got 4.119 installed). I wonder if that makes a difference. I'll try it out later on my laptop and see if it works on 4.120 but not on 4.119
Well, thank you for testing on your end. Now it's likely something I did wrong one way or the other; either I forgot to update the compiler on this machine or I did something screwy to the program... |
|
|
collink
Joined: 08 Jan 2010 Posts: 137 Location: Michigan
|
NOT a compiler bug |
Posted: Thu Apr 14, 2011 1:08 pm |
|
|
Turns out it was a brain bug not a compiler bug. Look back a few posts where I posted my whole fuses list. See the NOWDT buried in there on the middle fuses line? ARghhh.... |
|
|
|