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

Tracing Interrupt Timing

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



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

Tracing Interrupt Timing
PostPosted: Tue Feb 21, 2006 3:26 pm     Reply with quote

I have 3 interrupts in my program. I reduced the program to what you see just to check on the timing. I used a USB Logic Analyzer to get the wave forms below. H11AA1 is an AC input. FORCE forces the AC off. INT is the interrupt on pin_b0 (H11AA1) and RTCC and TIMER1 are toggle outputs every interrupt of RTCC and TIMER1.

There is some latency on INT line after H11AA1 line goes high, but I think there is a big difference in where the Logic Analyzer sees a 1 and where the processor sees a low to high. What bugs me is when I force the AC off and the H11AA1 goes high for a few ms, INT keeps interrupting.

RTCC (Yellow) should be interrupting every 250us yet I only see a change every 6-10ms.

TIMER1 is right on with 25ms interrupts.




Code:
#include <18F4620.h>

#device ICD=TRUE
#device adc=10

#zero_ram
#use delay(clock=4096000,restart_wdt)

#FUSES WDT                    //Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES NOPUT                    //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                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOLPT1OSC                //Timer1 configured for higher power operation
#FUSES MCLR                     //Master Clear pin enabled


#define timerst 39936

#int_RTCC
RTCC_isr()
{
output_toggle(pin_a2);
}


#int_EXT
EXT_isr(){
output_toggle(pin_e1);
}


#int_TIMER1
TIMER1_isr()
{

set_timer1(get_timer1() + timerst);  // .025s overflows with 4.096MHz crystal
output_toggle(pin_a1);

}




void main(){
int a,b;

set_tris_a(0b11111001);
set_tris_b(0b00000001);
set_tris_c(0b10110000);
set_tris_d(0b00000000);
set_tris_e(0b00000001);

setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
setup_adc_ports(AN0|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_8_BIT|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,3,1);
setup_timer_3(T3_DISABLED);

EXT_INT_EDGE(L_TO_H);
enable_interrupts(INT_EXT);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RTCC);
enable_interrupts(GLOBAL);


while (1){
a = 1;
b = 2;
}
}
Ttelmah
Guest







PostPosted: Tue Feb 21, 2006 3:43 pm     Reply with quote

You are setting the tris registers, but have not selected fast_io. as such the compiler will be overriding these settings.
The unit is behaving as if there is an interconnection to the output being driven by the RTCC, and the INT input. I'd be checking for 'silly' things (like one of the Vdd connections not being made, which can lead to very odd behaviour from the chip), or supply noise being generated by the output line, or a direct interconnection somewhere...

Best Wishes
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

PostPosted: Tue Feb 21, 2006 4:00 pm     Reply with quote

Sorry, some of the problem was traces on the board not making it to the connector where the leads were connected. I put the leads right on the processor and got expected waveforms.
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