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

Code execution cycle. Timers routines.

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



Joined: 20 Nov 2006
Posts: 8

View user's profile Send private message

Code execution cycle. Timers routines.
PostPosted: Sun Aug 12, 2007 11:06 pm     Reply with quote

Does anyone can explain me how is the code execution sequence on a PIC microcontroller (in this case 16F877A)?

for example:
Code:


#int_timer1
void trata_t1(){

}

void main(){

  setup_adc_ports(NO_ANALOGS);
  setup_adc(ADC_OFF);
  setup_psp(PSP_DISABLED);
  setup_spi(FALSE);
  setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
  setup_timer_1( T1_INTERNAL | T1_DIV_BY_1 );
  setup_timer_2(T2_DISABLED,0,1);
  setup_comparator(NC_NC_NC_NC);
  setup_vref(VREF_LOW|-2);

  enable_interrupts (global );
  enable_interrupts (int_timer1);

  while(1){
   
   
   
  }


}


With the code above. The code on the while(1) block is executed in parallel with the timer1 code block? some asyncronous relation or while routines in the timer1 block are executing, the code in the main 'while' loop waits till it ends?

I'm a little confused about it. Can anyone help me?
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sun Aug 12, 2007 11:56 pm     Reply with quote

The 16F877A is in the infinite loop while(1). It will stay there forever however periodically the timer will generate an interrupt. When the interrupt occurs the 16F877A suspends the while(1) operation saving its state and then executes the timer1 interrupt service routine at the end of the execution of the interrupt service routine the while(1) state of the 16F877A is restored and the infinite loop continues until the next timer interrupt. It is not truly parallel it is just normal serial operations of the PIC are suspended when the interrupt occurs and resumed after the service routine is done. There is a measure of parallelism in the hardware since the hardware of the 16F877A can both execute the program instructions and at the same time operate the timer and its interrupt.
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