PIC12F675 not waking up


Closed Thread
Results 1 to 8 of 8
  1. #1
    peterk's Avatar
    peterk Guest

    Smile PIC12F675 not waking up

    Hi,

    New to the forum,

    Melanie you may have already rxed a message.

    I am trying to save power and 12f675 draws almost nothing when asleep.

    Here the program

    ' GPIO.0 = Led Out
    ' GPIO.1 =
    ' GPIO.2 = Trigger In
    ' GPIO.3 =
    ' GPIO.4 = Osc
    ' GPIO.5 = Osc

    DEFINE ONINT_USED 1
    INTCON.3 = 1 ' Enable the port change interrupt
    CMCON = 7 ' Disables Analog Inputs
    ANSEL = 0 ' Sets Analog Inputs as Digital I/O

    TRISIO = $FF ' All As Inputs

    High GPIO.0
    Pause 10
    Low GPIO.0

    On_Test: ' Wait for the interupt on GPIO.2, ie Rear Panel Switch

    Pause 1
    IF GPIO.2 = 0 Then
    GoTo Awake
    EndIf
    INTCON.0 = 0 ' Clear the RB port change flag bit
    Nap 7 ' Go to sleep. When the watchdog is
    ' disabled, NAP won't wake up until
    ' an interrupt occurs.

    GoTo On_Test ' Do it again upon waking

    Awake:

    Low GPIO.0
    Pause 10
    High GPIO.0
    Pause 10

    GoTo Awake


    All the progam does is wakes up, doesn't perform awake, then goes back to sleep. (I monitor the current consuption)

    When I program the PIC I leave the watchdog off.

    Thanks for any help

    Peter

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Of course it's not waking up. By disabling the WatchDog Timer you've disabled NAP (read about how NAP works in the PBP manual).

  3. #3
    peterk's Avatar
    peterk Guest


    Did you find this post helpful? Yes | No

    Default

    OK, So why does this work for 16F628?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Post the complete code for the 16F628 and when I've a free moment I'll look into it.

  5. #5
    peterk's Avatar
    peterk Guest


    Did you find this post helpful? Yes | No

    Default

    As follows;
    ' PicBasic Pro program to demonstrate wake on interrupt.

    ' You should DISABLE THE WATCHDOG TIMER when programming the
    ' PICmicro device.

    ' The program outputs the condition of the switches on the
    ' LEDs, then immediately goes into power-down mode. When
    ' the condition on any switch changes, the RB port change
    ' interrupt occurs, waking the part.
    ' Since the global interrupt enable bit is not set, no
    ' jump to the interrupt vector occurs. Program execution
    ' is resumed, the LEDs are updated, and the part goes back
    ' to sleep.
    ' To further reduce the power consumption, all unused
    ' hardware peripherals should be disabled. The PORTB
    ' pullups should be replaced with external resistors, and
    ' the internal pullups disabled.


    ' Define ONINT_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    DEFINE ONINT_USED 1

    ' Define the pins that are connected to pushbuttons.
    ' The switches must be connected to PORTB, pins 4,5,6,
    ' or 7 in order to use the RB port change interrupt.
    sw1 VAR PORTB.4

    ' Define the pins that are connected to LEDs
    led1 VAR PORTB.0

    INTCON.3 = 1 ' Enable the RB port change interrupt
    OPTION_REG = $7f ' Enable PORTB pull-ups
    TRISB = %11111000 ' Set PORTB.0-2 (LEDs) to output, 3-7 to input

    main: ' main program begins here

    PORTB = 0 ' Turn off all LEDs

    ' Check any button pressed to toggle on LED
    IF sw1 = 0 Then
    GoTo Start
    EndIf
    INTCON.0 = 0 ' Clear the RB port change flag bit

    NAP 7 ' Go to sleep. When the watchdog is
    ' disabled, NAP won't wake up until
    ' an interrupt occurs.

    GoTo main ' Do it again upon waking

    Start:
    ' Rest of program

    Thanks Mel

    End

  6. #6
    peterk's Avatar
    peterk Guest


    Did you find this post helpful? Yes | No

    Default

    Got It Melanie !

    I looked at some of your example programs and utilised the following;
    ' Test Program for 32 Khz
    ' Interupt to wake
    ' Works 5 Jun 04
    ' Pause 1 = 122.07 ms
    ' Pauseu 1 = 122.07 us
    ' GPIO.0 = Led Out
    ' GPIO.1 =
    ' GPIO.2 = Trigger In
    ' GPIO.3 =
    ' GPIO.4 = Osc
    ' GPIO.5 = Osc

    DEFINE ONINT_USED 1
    INTCON=%00010000 ' enable Interrupt
    OPTION_REG.6=0 ' Trigger on Falling edge
    CMCON = 7 ' Disables Analog Inputs
    ANSEL = 0 ' Sets Analog Inputs as Digital I/O
    TRISIO = $FF ' All As Inputs

    High GPIO.0 ' Test Pulse
    Pause 10
    Low GPIO.0

    On_Test: ' Wait for the interupt on GPIO.2, Low from Switch

    IF GPIO.2 = 0 Then
    GoTo Awake ' Wake Up And Exit
    EndIf
    INTCON.1=0 ' Reset Interrupt Flag

    @ Sleep ' Go to @ sleep.

    GoTo On_Test ' Do it again upon waking

    Awake:

    Low GPIO.0 ' FlashLED
    Pause 1
    High GPIO.0
    Pause 1

    IF GPIO.1 = 0 Then
    Low GPIO.0 ' Turn LED Off
    GoTo On_Test ' Wait for next interupt of Switch Low
    EndIf

    GoTo Awake ' Flash LED Continuosly

    Thanks

    Peter

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Just very quickly Peter, as I'm under serious pressure today... interrupts don't work the same way on the 12 series PICs as they do on the 16 series... read "Special Features of the CPU" interrupt section in the 12F's Datasheet. Your program may not be executing the way you think it is...

    PS. Also the TRISIO for the output pin should be a '0' not a '1'.

  8. #8
    peterk's Avatar
    peterk Guest


    Did you find this post helpful? Yes | No

    Default

    hi Melanie,
    Thanks for the info
    will check out and let you know
    peter

Similar Threads

  1. PIC12F675 problem with port 5
    By NL2TTL in forum mel PIC BASIC
    Replies: 2
    Last Post: - 5th June 2009, 01:23
  2. SERIN with a PIC12F675
    By ewandeur in forum Serial
    Replies: 4
    Last Post: - 30th July 2007, 15:04
  3. PiC12F675 w/10Mhz Xtal, any special consideration?
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th March 2007, 10:50
  4. PIC12F675 trouble
    By russman613 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th February 2006, 18:40
  5. Erratic PIC12F675 behavior
    By russman613 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 27th February 2006, 14:46

Members who have read this thread : 1

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