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

advice on use of interrupts

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







advice on use of interrupts
PostPosted: Wed Sep 02, 2009 2:40 pm     Reply with quote

As both electronics and weather are a hobby of mine, I'm putting together my own weather station. The current design has a remote/outside sensor board with a PIC16LF876A connected to several sensors, relaying data back to another PIC inside to do other things with the data.

The remote probe should sip as little power as possible. To accomplish this, my design goal is to use an external 32khz crystal on timer1 and sleep the PIC. When the timer rolls over, the PIC should wake up, poll several sensors (SCP1000, SHT15, etc) and report the data collected via a serial output.

How would you guys recommend accomplishing this? My original idea was to have an ISR that did something like:
Code:

{
  read_sensor_1();
  read_sensor_2();
  report_data();
}

However, I've seen advice that ISRs should be kept as simple as possible. Considering that the routines to read the sensors can be complex, is it advisable to call them inside of an ISR? Is there a better way to accomplish what I want to do?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Sep 02, 2009 2:53 pm     Reply with quote

You don't need to use an interrupt routine. This program shows how
to put the PIC to sleep, and then have it wake up when Timer1 rolls
over from 0xFFFF to 0x0000. Timer1 runs from a watch crystal
oscillator connected to the T1OSI and T1OSO pins.
http://www.ccsinfo.com/forum/viewtopic.php?t=28158&start=8

You could take most of the code in main(), and put it in a while(1)
loop. Then it would periodically wake up (every 2 seconds) and
read your sensors.
thefloyd



Joined: 02 Sep 2009
Posts: 46

View user's profile Send private message

PostPosted: Wed Sep 02, 2009 3:20 pm     Reply with quote

PCM programmer wrote:
You don't need to use an interrupt routine. This program shows how
to put the PIC to sleep, and then have it wake up when Timer1 rolls
over from 0xFFFF to 0x0000. Timer1 runs from a watch crystal
oscillator connected to the T1OSI and T1OSO pins.
http://www.ccsinfo.com/forum/viewtopic.php?t=28158&start=8

You could take most of the code in main(), and put it in a while(1)
loop. Then it would periodically wake up (every 2 seconds) and
read your sensors.


thank you. That's exactly what I had mapped out in my mind, but couldn't figure out..
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