![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
jafeucht
Joined: 28 May 2010 Posts: 2
|
Problem with delay_ms on PIC18LF |
Posted: Fri May 28, 2010 2:42 am |
|
|
I am having a bit of trouble with the strangest error. The error happens after I upload the following code to a PIC18LF4525 40-pin DIP using a SUPERPRO 580U programmer.
Code: | #include <18F4525.h>
#device adc=8
#fuses NOWDT,WDT128,HS,NOPROTECT,NOIESO,BROWNOUT,BORV21,PUT,NOCPD,STVREN
#fuses NODEBUG,NOLVP,NOWRT,NOWRTD,NOEBTR,NOCPB,NOEBTRB,NOWRTC,NOWRTB,NOFCMEN
#fuses XINST,NOPBADEN,LPT1OSC,MCLR
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
void main() {
unsigned int i;
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF|ADC_TAD_MUL_0);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
while (1) {
delay_ms(1000);
puts("Hello, world");
}
return;
}
|
The problem is when I actually run this code, the I2C interrupt is never called, and the delay_ms(1000) line seems to be ignored, so I get rapid "Hello, world"s on my serial port monitor. Is there any reason why the delay_ms statement would be ignored in this code? Is anybody running into this same problem?
Thanks in advance for your help. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19364
|
|
Posted: Fri May 28, 2010 4:42 am |
|
|
Change one fuse. XINST -> NOXINST.
CCS does not support XINST, and if this fuse is selected, you will get indeterminate errors...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
jafeucht
Joined: 28 May 2010 Posts: 2
|
That worked |
Posted: Fri May 28, 2010 7:03 am |
|
|
Ttelmah wrote: | Change one fuse. XINST -> NOXINST.
CCS does not support XINST, and if this fuse is selected, you will get indeterminate errors...
Best Wishes |
Wow, that worked. Thanks a lot! I just about pulled all my hair out over that.
![Laughing](images/smiles/icon_lol.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19364
|
|
Posted: Fri May 28, 2010 8:43 am |
|
|
You did the 'critical thing', of posting a small test program with the problem.
This is why you will see some of the 'gol hands' here asking for this like a mantra. It really is vital. The problem is so often 'hidden' somewhere in the fuses, or setup lines, and not in the actual part of the program where it appears to be....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|