Getting a 18F2525 to wake up from sleep with change of input


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84

    Default Getting a 18F2525 to wake up from sleep with change of input

    Hi All,

    Been working on this all day and I must be doing something silly!

    I want to wake up the 18F2525 from sleep by a change in port B.

    Any help appreciated as I am quickly tearing my hair out.

    Thanks
    Bob

    DEFINE OSC 20
    INCLUDE "MODEDEFS.BAS"

    #config
    __CONFIG _CONFIG1H, _OSC_HS_1H
    __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOREN_OFF_2L & _BORV_2_2L
    __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_16384_2H
    __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
    __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    __CONFIG _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L
    __CONFIG _CONFIG5H, _CPB_ON_5H
    #endconfig

    T2 var byte

    LedG VAR PORTA.1 ' Green LED
    LedR VAR PORTA.2 ' Red LED
    BUZ VAR PORTA.3 ' Buzzer OP
    KeyLine VAR PORTA.5 ' keyline
    BPear1 var PORTB.4 ' Push 1 IP
    BPear2 var PORTB.5 ' Push 2 IP
    Bcall var PORTB.6 ' Call Button
    Bcancel var PORTB.7 ' Cancel Button

    LedR = 0 ' led off
    LedG = 0 ' led off


    Start:
    BUZ = 1 ' Buzzer off
    KeyLine = 1 ' transmitter off

    '
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    Slp: ' Now prepare for sleep
    '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''
    '
    INTCON=0 ' Disable all interrupt including tmr0
    INTCON2.7 = 0 ' Enable weak pull-ups
    PORTA=%00001000 '
    PORTB=%11110000 '
    PORTC=%00001000 '
    TRISA = %00000000 '
    TRISB = %11110000 '
    TRISC = %00000000
    T2=PORTB ' Read port to ensure no setting of flag
    INTCON=%10001000 ' Enable the global interrupt and enable the change on port b

    @sleep

    PAUSE 100 ' Sound buzzer and Led as indicator of sleep exit
    ledr=1
    BUZ=0
    pause 100
    ledr=0
    BUZ=1
    pause 500
    goto slp

    end
    Last edited by BobP; - 24th February 2018 at 20:07.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,383


    Did you find this post helpful? Yes | No

    Default Re: Getting a 18F2525 to wake up from sleep with change of input

    try this
    Code:
    DEFINE OSC 20
     INCLUDE "MODEDEFS.BAS"
    
     #config
            __CONFIG    _CONFIG1H, _OSC_HS_1H
            __CONFIG    _CONFIG2L, _PWRT_OFF_2L & _BOREN_OFF_2L & _BORV_2_2L
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_16384_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
            __CONFIG    _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L
            __CONFIG    _CONFIG5H, _CPB_ON_5H
     #endconfig
    
        T2  var     byte
    
        LedG        VAR PORTA.1     ' Green LED     
        LedR        VAR PORTA.2     ' Red LED
        BUZ         VAR PORTA.3     ' Buzzer OP
        KeyLine     VAR PORTA.5     '  keyline
        BPear1      var PORTB.4     ' Push 1 IP
        BPear2      var PORTB.5     ' Push 2 IP
        Bcall     	var PORTB.6     ' Call Button
        Bcancel  	var PORTB.7     ' Cancel Button
    
        LedR = 0                    ' led off
        LedG = 0                    ' led off
    
    
     Start:
        BUZ = 1                     ' Buzzer off
        KeyLine = 1                 ' transmitter off
    
     '
     ''''''''''''''''''''''''''''''''''''''''''''''''''  ''''''''''''''''''''''''''''''
     Slp:       ' Now prepare for sleep
     ''''''''''''''''''''''''''''''''''''''''''''''''''  ''''''''''''''''''''''''''''''
     
     INTCON2.7 = 0           ' Enable weak pull-ups
        PORTA=%00001000         ' 
        PORTB=%11110000         '  
        PORTC=%00001000         ' 
        TRISA = %00000000       '
        TRISB = %11110000       '   
        TRISC = %00000000   
        T2=PORTB                ' Read port to ensure no setting of flag
        INTCON=%00001000        ' Enable the global interrupt and enable the change on port b
    
    @ sleep  
    @ nop 
    
    
    PAUSE 100               ' Sound buzzer and Led as indicator of sleep exit
        ledr=1
        BUZ=0
        pause 100
        ledr=0
        BUZ=1
        pause 500
     goto slp
    
     end
    Warning I'm not a teacher

  3. #3
    Join Date
    Mar 2004
    Location
    UK-Midlands
    Posts
    84


    Did you find this post helpful? Yes | No

    Default Re: Getting a 18F2525 to wake up from sleep with change of input

    Hi,

    Two small changes makes it work.

    Many thanks Richard I was going round in circles getting nowhere.

    Thanks
    Bob

Similar Threads

  1. 10F222 Wake on pin change
    By AvionicsMaster1 in forum PBP3
    Replies: 11
    Last Post: - 9th January 2014, 20:14
  2. Cannot wake from SLEEP
    By BrianT in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st May 2013, 08:47
  3. 16F181: can't wake up from sleep
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th January 2010, 05:33
  4. wake up from sleep
    By savnik in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2007, 18:09
  5. ? about sleep/wake on pin change and WDT
    By kessral in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th January 2007, 00:25

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