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

Delays stop working if ICD=TRUE is enabled on 18F4520

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



Joined: 08 Apr 2008
Posts: 8

View user's profile Send private message

Delays stop working if ICD=TRUE is enabled on 18F4520
PostPosted: Tue Apr 08, 2008 7:40 pm     Reply with quote

Hello,


Does anyone know what would cause a Delay_Ms to not work when the IDC-TRUE is set? It like the delays are gone but if I load the debug everything works. I’ve tried all the options I know of but still the same issue.

Thanks
Code:

#### Code snip . c ####

include "main.h"
#int_RTCC

void RTCC_isr(void)
{
output_bit(PIN_D1,0);
Delay_Ms(2000);
}

void main()
{
// setup_adc_ports(NO_ANALOGS|VSS_VDD);
// setup_adc(ADC_OFF|ADC_TAD_MUL_0);
// setup_psp(PSP_DISABLED);
// setup_spi(SPI_SS_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);
enable_interrupts(GLOBAL);

enable_interrupts(INT_RTCC);

for(;;)
  {
   output_bit(PIN_D1,1);

   // restart_wdt();
  }

}

Code:

####3 .H #################
#include <18F4520.h>
#device adc=8
#device ICD=TRUE
//#FUSES NODEBUG
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //Low power osc < 200 khz
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //Reset when brownout detected
#FUSES BORV25 //Brownout reset at 2.5V
#FUSES PUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
//#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
//#FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES MCLR //Master Clear pin enabled
#FUSES XINST //Extended set extension and Indexed Addressing mode enabled
//#FUSES CCP2C1
//#FUSES NOLPT1OSC
//#use delay(clock=4000000)
#use delay(crystal=4mhz)
//#use delay(clock=40000000,RESTART_WDT)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 8:14 pm     Reply with quote

Quote:
#FUSES XINST //

This is a problem. The extended instruction set is not supported.
Using XINST will give erratic operation. Change the fuse to NOXINST.
Do this in all of your programs.
incubi



Joined: 08 Apr 2008
Posts: 8

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 9:22 pm     Reply with quote

Looks like that's it, man its always the little things Evil or Very Mad

Thanks for the help

incubi
incubi



Joined: 08 Apr 2008
Posts: 8

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 10:19 pm     Reply with quote

PCM programmer

Would you happen to know why adding a var at the top/global would stop the interrupt from working? Example,
Code:

#include "main.h"
#int_RTCC

byte myvar;

void  RTCC_isr(void)
{
         output_bit(PIN_D1,1);
         Delay_Ms(500);

}

Seems to kill the interrupt not sure why
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 11:00 pm     Reply with quote

Yes. The #int_RTCC tells the compiler that the following function is
an interrupt function. You can't stick a global variable between the #int
statement and the function. Always put the #int statement on the line
just above the interrupt function. Example:
Quote:

#int_RTCC
void RTCC_isr(void)
{
output_bit(PIN_D1,1);
Delay_Ms(500);

}
incubi



Joined: 08 Apr 2008
Posts: 8

View user's profile Send private message

PostPosted: Wed Apr 09, 2008 3:50 am     Reply with quote

Where was this kind of help back in the 90s when I was learning C Smile

Thanks PCM programmer,

incubi
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