I actually just checked and you can use the AD_INT -- A/D Converter Interrupt in his 14 bit version as well... So you don't have to use an 18F
Thanks Darrel
http://darreltaylor.com/DT_INTS-14/intro.html
I actually just checked and you can use the AD_INT -- A/D Converter Interrupt in his 14 bit version as well... So you don't have to use an 18F
Thanks Darrel
http://darreltaylor.com/DT_INTS-14/intro.html
Best Regards,
Kurt A. Kroh
KrohTech
“Goodbye and thanks for all the fish”
brid0030, Why not look for a PIC that has an analog comparator with an interrupt available. That way the PIC can sleep indefinitely untill the voltage comparator is triggered at which time you can wake and make a measurement then time stamp the data and, back to sleep...
Dave Purola
N8NTA
The A/D interrupt fires when an A/D conversion is complete. This is handy for entering sleep mode, and having the PIC wake up when the A/D conversion is complete. With the oscillator shut down during sleep, you get much more stable A/D readings.
The comparator can also wake the PIC from sleep on change of a comparator output. This would work too, but I would check the Electrical Specifications section of the data sheet for current draw.
A/D, comparator, Vref, WDT, etc,, they all draw current during sleep. Which one is best depends on your power budget, and application. Wake up on comparator output change would probably let the PIC sleep for longer periods.
This PIC also has an ultra low-power wake-up option if you really need to squeeze power consumption down during sleep. Look for AN879 on the Microchip site.
Thanks for these suggestions. I'm still not clear how to implement them, but I have some direction for future reading. It sounds as if using "ON INTERRUPT" is generally to be avoided. I'm still not sure whether it will miss events that start and end during a long command, but it definitely would not provide the most elegant solution.
I've looked into Darrel Taylor's interrupt system, and will have to do some more research before I can grasp what is going on. Using the ultra-low-power wake up module is quite tempting. I use a large external battery so power consumption is not that big an issue, but why not save as much as possible? I don't know how to implement the module, but there is some asm code in application note AN879 (http://ww1.microchip.com/downloads/e...tes/00879C.pdf), so perhaps I can start there. If anyone has ever used the low-power wake up, I would love to see some examples.
Here's something to start with. I've converted the assembler example in the app note to PBP for you with one exception. It does not use interrupts. This just uses the ultra low-power wake-up feature to wake from sleep. Global interrupts are disabled.
With a 10K / 1uF RC network on RA0, it wakes up & toggles RC5 ~ once every 34 seconds.
An interesting note on this one is that is works whether you clear the int flag or not!Code:@ device pic16F688, intrc_osc_noclkout, wdt_off, mclr_off, protect_off ' Note: Default internal osc is set to 4MHz SleepyTime: 'BCF STATUS, RP0 ;Bank 0 'BSF PORTA, 0 ;Set RA0 data latch PORTA.0 = 1 'MOVLW H’7’ ;Turn off 'MOVWF CMCON0 ;comparators CMCON0 = 7 'BSF STATUS, RP0 ;Bank 1 'BCF ANSEL, 0 ;RA0 to digital I/O ANSEL.0 = 0 'BCF TRISA, 0 ;Output high to TRISA.0 = 0 'CALL CapDelay ;charge capacitor PAUSE 100 ' change to suite your RC circuit 'BSF PCON, ULPWUE ;Enable ULP Wake-Up PCON.5 = 1 'BSF IOCA, 0 ;Select RA0 IOC IOCA.0 = 1 'BSF TRISA, 0 ;RA0 to input TRISA.0 = 1 'MOVLW E’10001000’ ;Enable interrupt 'MOVWF INTCON ;and clear flag INTCON = %00001000 ' Note bit 7 is clear since we're not vectoring to an int handler 'SLEEP ;Wait for IOC @ SLEEP INTCON.0 = 0 ' clear int flag on wake-up Main: ' Do whatever you need here on wakeup ' insert your code here TOGGLE PORTC.5 ' do your stuff here before entering sleep mode again GOTO SleepyTime ' do the ultra low-power wake-up thing again afterwards END
Bookmarks