Wierd sleep issue


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    orca's Avatar
    orca Guest


    Did you find this post helpful? Yes | No

    Wink

    Thank you Mister e,

    It never occurred to me to read the data sheet, especially any part of section 9. I have since found the problem. Although I'm not sure why yet, somehow on power-up intcon<1> gets set even thought the data sheet indicates that the intcon register 'should' power up to all zeros. Anyway, if I place the clear intcon<1> , ext int flag bit, code just before the sleep command rather than after the problem goes away.

    However, I do appreciate the code help with the assembler code:

    asm
    clrf 32h
    endasm

    The misuse of that explains why I needed the CLEAR statement just prior to the snipet of code as they should be redundant statements, I think. Anyway the reason for that is when exiting sleep the LCD would not work properly. After days of haed wracking I finally took a look at the PBP commands for the LCD, i.e. LCDOUT, LCDIN etc. What I found was when the LCDOUT command is issued it looks at a flag bit called LCDINIT and if the bit is clear it then initializes the LCD, if set it does not go through the initialize routine. So, since exiting sleep is a just a continuation of the code the LCDINIT flag is still set so subsequent calls to LCDOUT ignore the initialization routine even though the LCD was turned off. Therefore the LCDINIT flag needs to be cleared after exiting sleep. Guess where the LCDINIT flag bit, among others, is stored by PBP, 0x32.

    Thanks for your assistance!

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


    Did you find this post helpful? Yes | No

    Default Damn you searched a lot for that!

    O.K.. so now go on the PBP manual, scroll the page and you'll discover
    FLAGS=0.

    Always trust yourself. All those POR default... may sometimes be true, sometimes not. I always set them myself.

    Great to know it's workinf for you now.
    Steve

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

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. Using Sleep
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th August 2008, 04:05
  4. 16F628A current high during sleep
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th October 2006, 10:21
  5. SLEEP Command and Interupts 16F648A
    By ghoot in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 28th May 2004, 18:35

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