Damn, I didn't think of the fact that it will use power even when the main = core is asleep, that won't do. I have revised the design, it will only sample the ADC when it needs to = alarm, as the ADC value only affects the alarm tone there is no point me = ever doing otherwise...whoops. As for the wake-on-change I haven't ever used it before so I guess I did = mean RB1 :-) Thank-you everybody for your help with that. I have got further with the piezo problem, for something with an appaling = bandwidth it is suprisingly agile when it comes to making musical tones. Although there is something that somebody may be able to help me with, a = long time ago I'm sure I read of someones efforts to reproduce sounds via = the PIC using a large RAM table with wave data in it, if anybody thinks = they know a link it would be greatly appriciated, as melodys are extreamly = hard to code as consecutive delays. =20 >>> Vasile Surducan 11/06/2002 11:42:28 >>> On Mon, 10 Jun 2002, Michael Rigby-Jones wrote: > > I'm working on a (commercial) project that involves a 16C73, most of = the > > other circuit functions are done but I still need to read ADC channel = one > > (RA0), process the value and create a signal that gets sent to a piezo > > sounder. > > The ADC is my main problem, I have it reading values, thanks to the > > Piclist FAQ, but I need the PIC to sleep for as much of the time as > > possible, it's currently sleeping while it converts then it wakes up = and I > > send its value to the piezo code, but I need then to put it back into > > sleep and wait until ADC channel one or RA1 changes (circuit power use = is > > critical). > > I think I can work out how to wake from sleep on RA1 changing, but I = don't > > even think it's possible to wake from sleep on a change in the analog > > input? > > > You have a problem in both cases. RA1 has no interrupt on change = facility, > unless this is a typo and you meant RB1? There is no way to wake up = from a > change in analog value as you suspected, the only wakeup ascociated with = the > A/D converter is the end of conversion interrupt. The ADC module itself > raises power consumption, so depending on how often you need to sample, = you > might be better off using a timer interrupt to enable the ADC module = and > the ADC interrupt to disable the module, the aim being to keep the ADC > module disabled for as much time as possible. The timer interrupt could = be > used to check pin RA1 as well (assuming it wasn't a typo). > or to use interrupt on RB0 ( or any other interrupt on change) with a comparator. If the analog input exceed the reference then an interrupt will wake up the whole mess, perform the measurement and go back to sleep again after it finished. A time delay will be necessary from the wake up moment to measurement(s). Vasile -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads