Sleep does not really sleep...


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: Sleep does not really sleep...

    Additional info:

    The ADC uses internal Vref of 0.6 volts to check the battery power supply. Before sleep the ADC is switched off.

    Also UART is switched off, along with Tmr1 and some ports setting.

    The only one that stays as input, is the Portb.7 the Rx pin but even if it is grounded the current stays at 1.8mA.

    WDT is disabled.

    BOR is disabled.

    /MCLR is set as internal and as the data sheet states, there is an internal pull up.

    Ioannis
    Last edited by Ioannis; - 18th June 2022 at 22:39.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: Sleep does not really sleep...

    The interrupt on change is created by a matrix keyboard connected on portB (0-6).

    I noticed that a short keypress allows PIC go to sleep, while a longer press keeps it semi awake.

    Then I added this while-wend check just before pressed=0 in the main routine and now works OK:

    Code:
    main:
    portb=$78   'set port to 01111000
    txsta=0     'Turn off all peripherals
    rcsta=0     'before sleeping
    adcon0.0=0  'Disable ADC
    while pressed:pause 10:wend
    pressed=0   'reset flag pressed
    intcon.0=0  'reset RBIF flag
    t1con.0=0   'turn off timmer 1
    buzzer=0
    @ sleep
    @ nop
    Though not elegant nor explains why this happens, it kinda fixed the problem.

    Ioannis

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Wait for key release

    Any idea how can the keyboard matrix scan routine check for key release, before jumps to the keycheck subroutine please?

    Code:
    keyscan:
    while 1
        for ix=0 to 2     'scan columns
            portb=~dcd ix 'invert polarity
            keyin=portb & %01111000
            if keyin<>120 then keycheck  'if key is pressed then check it
        next ix
    wend
    Ioannis

Similar Threads

  1. Asm sleep - pbp sleep
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 18th May 2020, 21:13
  2. Can't @sleep
    By MOUNTAIN747 in forum General
    Replies: 3
    Last Post: - 30th December 2010, 17:29
  3. Trying to add a sleep function or pretend to sleep
    By lilimike in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th May 2010, 19:10
  4. How to go to sleep
    By savnik in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd September 2006, 18:38
  5. @sleep
    By jheissjr in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 5th March 2006, 22:42

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