> On Sun, Dec 7, 2008 at 5:10 PM, solarwind wrote: >> All I need is a simple example how to get the interrupt on pin change >> to work. There aren't many C examples for this. >> > > Do you understand how PIC interrupts work yet? (not being snide here, > you're learning and that's cool.) > > C example will be very similar to the assembler. You'll want to learn > the "set register" and "set/clear a single bit" instructions, at > least, to understand the datasheet examples. The actual interrupt > handler tends to vary by compiler; consult the manual for the compiler > you are using. Again, you do *not* actually need to use an interrupt handler, nor globally enable interrupts to get interrupt-on-change to work to wake up from sleep. As Olin noted, an enabled interrupt-on-change causes an interrupt *condition*, but it only becomes an actual interrupt if interrupts are globally enabled. So, you want to do the following: 1: Make sure you properly initialize your inputs as digital as opposed to analog (often controlled by a port called ANSEL, but this varies amoung several different PICs). 2: Make sure your inputs are set up as inputs rather than outputs (this is the default condition, check out TRIS registers for this). 3: Make sure that interrupts are globally disabled (often a flag bit called GIE). This is the default condition. 4: Make sure the interrupt-on-change interrupt is enabled (another flag bit). Now a SLEEP should be terminated when the input bit changes, but no interrupt handler is needed. Some baby steps: I would start by trying to write a program that just copied the state of an input bit to an output bit. This makes sure you have inputs set up as inputs and outputs as outputs. Then I would try to add the interrupt-on-change/wakeup from SLEEP logic. -- Bob Ammerman RAm Systems -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist