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 support@ccsinfo.com

Problem with delay_ms on PIC18LF

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



Joined: 28 May 2010
Posts: 2

View user's profile Send private message

Problem with delay_ms on PIC18LF
PostPosted: Fri May 28, 2010 2:42 am     Reply with quote

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.
Ttelmah



Joined: 11 Mar 2010
Posts: 19359

View user's profile Send private message

PostPosted: Fri May 28, 2010 4:42 am     Reply with quote

Change one fuse. XINST -> NOXINST.
CCS does not support XINST, and if this fuse is selected, you will get indeterminate errors...

Best Wishes
jafeucht



Joined: 28 May 2010
Posts: 2

View user's profile Send private message

That worked
PostPosted: Fri May 28, 2010 7:03 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19359

View user's profile Send private message

PostPosted: Fri May 28, 2010 8:43 am     Reply with quote

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