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

60 second delay in external interrupt routine

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



Joined: 07 May 2010
Posts: 3

View user's profile Send private message

60 second delay in external interrupt routine
PostPosted: Sun May 16, 2010 5:26 am     Reply with quote

I need to implement an external interrupt service routine that has 60 second delay in it. The ISR will calibrate a robotic device in this time interval. I know that generally using long delays in interrupts is not a good practice. Also I noticed that when I use a long delay in ISR the compiler gives a warning(I have no idea about it)

How can I implement a successful ISR in CCS,with a 60 second delay?

Any help will be welcomed.
Code:

#int_ext

void compass_calibration(void);

void calibration_isr(){
   compass_calibration();
}


Code:

void compass_calibration(){
   
   output_low(pin_b1);
   compass_sync();
   spi_write(0xAA);  //slm
   spi_write(0x06);  //setconfig
   spi_write(0x05);  //cpid - period
   spi_write(0x04);  //period data uint8
   spi_write(0x00);  //terminator
   output_high(pin_b1);
   
   delay_ms(5);
   
   output_low(pin_b1);
   spi_write(0xAA);  //slm
   spi_write(0x0A);  //startcal
   spi_write(0x00);  //terminator
   output_high(pin_b1);
 
/*  output_low(pin_b0);
   while( !input(pin_b3) );
   output_high(pin_b0);*/
   motor_rotate(125,125);
   delay_ms(65000);
   motor_rotate(70,70);
   
   output_low(pin_b1);   
   compass_sync();
   spi_write(0xAA);  //slm
   spi_write(0x0B);  //stopcal
   spi_write(0x00);  //terminator
   output_high(pin_b1);
   
}
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sun May 16, 2010 9:06 am     Reply with quote

Use one interrupt to start another.
The external interrupt starts a timer interrupt that say increments a second counter. The main routine loops waiting for the seconds to reach 60.
It then can reset the seconds counter and disable the timer so a repeat of the whole sequence can occur. The two interrupts free the main routine from being blocked by the delay_ms etc.
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