Sharp pulse on ADC input and NAP


Results 1 to 12 of 12

Threaded View

  1. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Sharp pulse on ADC input and NAP

    I have not tested this since I don't have a 12F675, but something like this should work. You might need to tweak the internal CVref settings.

    Hook your sensor output to GPIO.1 Vin-. When your sensor outputs 1V (or anything > CVref) it should wake-up from sleep.

    If you don't have PBP3 just get rid of the config line, and use what you have.

    Code:
    #CONFIG
      __config  _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _CP_OFF
    #ENDCONFIG
     
    DEFINE OSCCAL_1K 1 ' load internal osc calibration value
     
    LED VAR GPIO.2      ' LED output
    CmpFlag VAR PIR1.3  ' alias comparator interrupt flag bit
    CoutBit VAR CMCON.6 ' CMCON.6 is set while voltage on Vin- > CVref
     
    ANSEL = 0          ' disable A/D
    GPIO = 0           ' LED off on POR
    TRISIO = %00000010 ' GPIO.1 = input for Vin- comparator, rest outputs
    VRCON = %10100111  ' internal CVref enabled, low range.
                       ' CVref = (VR3:VR0 / 24) * VDD.
                       ' with (VR3:VR0) = 7 we have (7/24) * 3.3V
                       ' so internal CVref = 0.9625V
                       ' a voltage > 0.962V on Vin- (GPIO.1) will set COUT,
                       ' set the comparator interrupt flag, and wake us up.
    CMCON = %00010100  ' Comparator w/o Output and with Internal Reference
     
    PIR1 = 0           ' clear flags before enabling comparator int
    PIE1 = %00001000   ' comparator interrupt enabled.
    INTCON = %01000000 ' enable peripheral interrupts for comparator
                       ' global interrupts disabled, so there's no jump to
                       ' an interrupt vector. We're just waking-up from sleep.
     
    TEST:
      WHILE CoutBit    ' wait for COUT to clear. This clears when the voltage on
      WEND             ' Vin- falls below the internal CVref
      CmpFlag = 0      ' clear comparator interrupt flag bit before entering sleep
      @ SLEEP          ' should sleep until comparator trips
      HIGH LED
      PAUSE 500
      LOW LED
      GOTO TEST
      end
    Last edited by Bruce; - 13th August 2011 at 16:53.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts