Status after @ SLEEP Command


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default Status after @ SLEEP Command

    Hi There,

    I am using " @ SLEEP" and processor wakes up when Int RB0 pin goes high.
    After the wake up, my lcd is behaving weird.

    If I use, DT's instant interrupt, it works as expected; if I only use Int flag and intcon enable bit to go to sleep and wake up from there, then I get LCD issue.

    What register should I take care of?
    Before getting into sleep, I used "CLEAR" but this time, RB0 int pin does not see 1 or 0. Like it is not even an input pin.

    Thank you.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    Hi Sayzer, There are likely several possible causes. The first that comes to mind is context saving. Depending on what chip you are using, it is not done automaticly for you. Have a look at the interrupt section of the datasheet.

    DT_INT tends to context saving for you which is one of the things that make it so easy to use and powerful.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    Hi Bert,

    Actually, there is no interrupt routine.
    And I can not use DTs instant int. routine because the pic is almost full.
    No more space.

    I am using 16F628A.
    there is a button on RB0.

    PIC is always in sleep using @ SLEEP

    When the pin goes high, PIC turns on LCD (LCD Vdd pin is connected to PIC pin, draws 2mA).

    All works ok with DTs routine.
    But, since I onlly need to wake up the PIC, DTs routine is too much to use for code saving purposes.
    So I use the traditional way.

    Code:
    OPTION_REG.6 = 1    ' Int on rising edge.
    INTCON = %00010000   
    IntFlag VAR INTCON.1
    Using intflag here, system wakes up ok.
    Turns on LCD ok.
    But what on LCD is not correct.
    random things.

    Again, all works ok with DTs.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    If you power down the LCD before sleep you will need to reinitialize it on wakeup. Try placing flags = 0 just before @ SLEEP so PBP will reinitialize it first.

    Or, if you're using an external oscillator, you might need a short delay after wakeup for it to stabilize before sending data to the display.
    Regards,

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

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    motion seconded
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    Quote Originally Posted by Bruce View Post
    If you power down the LCD before sleep you will need to reinitialize it on wakeup. Try placing flags = 0 just before @ SLEEP so PBP will reinitialize it first.

    Or, if you're using an external oscillator, you might need a short delay after wakeup for it to stabilize before sending data to the display.
    Thank you Bruce.

    I am using internal osc.

    Here is my simplified code.

    Would you please indicate where do I need to put the flags and what exactly o I need to do?
    IF I put CLEAR command before sleep, it helps but does not solve the issue completely.


    Code:
    LCDVdd var PORTA.0
    Switch var PORTB.0
    Input switch  ' An external 220K is tied to Vdd. Draws approx. 0.12mA.
    OPTION_REG.6 = 1    ' Int on rising edge.
    INTCON = %00010000   
    IntFlag VAR INTCON.1 
    START:
        
        low lcdvdd               ' Turn off lcd.
        
        ' Keep all pins low to draw minimum current.
        low LCD_DB5
        low LCD_DB6
        low LCD_DB7
        low LCD_RS
        low LCD_E 
    
        IntFlag = 0
    @ SLEEP         ; Sleeping now. If switch is released, then processor will wake up.
    @ NOP          
        high lcdvdd     ' Power up LCD.
        pause 250       ' LCD wakes up.
        
    ChkBtn:
        lcdout $fe,1,"Test"
        pause 1000
        
      
        if Switch then chkbtn    ' Loop until Switch is down.
        ' Here, switch is down now.
        
        goto start
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    Try placing FLAGS = 0 just before @ SLEEP.
    Regards,

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

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    From the manual...
    The LCD is initialized the first time any character or command is sent to it using LCDOUT. If it is powered down and then powered back up for some reason during operation, an internal flag can be reset to tell the program to reinitialize it the next time it uses LCDOUT:
    FLAGS = 0
    FLAGS = 0 is a lost children feature... but documented
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Status after @ SLEEP Command

    Thank you Bruce. Problem disappeared.

    Steve, lost child saved a life.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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