Asm sleep - pbp sleep


Closed Thread
Results 1 to 32 of 32

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    Yes, I checked it again. For some reason I remember to have two NOPs. Sorry for that. Have one or three. It is up to you.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    I rephrase: at least one NOP.

    You may have as many as you want of course. Will not argue that. Still, I do not know which case(s) will not need the NOP, so put it there in any case!

    Ioannis

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    Quote Originally Posted by sayzer View Post
    Yes, I checked it again. For some reason I remember to have two NOPs. Sorry for that. Have one or three. It is up to you.
    So I've run all the test Sayzer has suggested. No changes. I then strip code to a couple of lines. I have done this on multipal 1936 and different boards.


    Code:
    Asm
     __config _CONFIG1,_FOSC_INTOSC & _CLKOUTEN_OFF & _MCLRE_ON & _BOREN_OFF & _WDTE_OFF & _FCMEN_OFF & _CP_OFF & _CPD_OFF & _IESO_OFF
     __config _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_LO & _LVP_OFF
    endasm  
    define OSC 8
        OSCCON=%01110000   ;1110=8Mhz                                                 
        ANSELA=$0   
        ANSELB=$0    
        ADCON0=$0
        PortA=0
        PortB=0                                      
        PortC=0 
        TrisA=%00000001                                                                                
        TrisB=%00001001        
        TrisC=%00000000   
        Avar    var byte
        Bvar    var byte
        Cvar    var byte 
        
    SleepMode:
    ASM
    ;    BTFSS   BAUDCON,RCIDL  ;Check for High, no receive in progress 
    ;    GOTO $-1                     ;return to previous line
    ;    BSF BAUDCON,WUE        ;Wake on Rx from Master
    ;    BSF PORTA,1            ;LED
       
        SLEEP
        BSF  PORTC,1   ;LED 
        nop
        nop
        nop                   .
    ENDASM
    SLEEP is the first command after which my LED flashes apx. every 2.14seconds.
    I then expand the code.

    Code:
    SleepMode:
    ASM
    ;    BTFSS   BAUDCON,RCIDL  ;Check for High, no receive in progress 
    ;    GOTO $-1                     ;return to previous line
                   
        BSF BAUDCON,WUE        ;Wake on Rx from Master
        BSF PORTA,1    ;LED 
        SLEEP
        BSF  PORTC,1   ;LED 
        nop
        nop
        nop                   .
    ENDASM
           END
    I run the code and LED A.1 is on and LED C.1 is blinding every 2.14sec.
    I then expand the code.

    Code:
    SleepMode:
    ASM
        BTFSS   BAUDCON,RCIDL  ;Check for High, no receive in progress 
        GOTO $-1                     ;return to previous line
        BSF BAUDCON,WUE        ;Wake on Rx from Master
        BSF PORTA,1            ;LED  
        SLEEP
        BSF  PORTC,1   ;LED 
        nop
        nop
        nop                    ; Should be in sleep for 10sec.
    ENDASM
    I run the code and No LED comes on. The program is stuck in the loop BTFSS BAUDCON, RCIDL & GOTO $-1. This is a HARDWARE RESET not caused by any of my code unless something in the configs are at falt. Threre are no interrupts as I have tested all flag bits i can think of. Rx stays LOW. No com is connected to the board. RCIDL should be HIGH but it is not.
    CONFIGS !!! Next round of testing.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,664


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    its all the same problem
    what bank is baudcon in?
    what bank is porta or portc in ?


    ASM
    BTFSS BAUDCON,RCIDL ;Check for High, no receive in progress
    GOTO $-1 ;return to previous line
    BSF BAUDCON,WUE ;Wake on Rx from Master
    BSF PORTA,1 ;LED
    SLEEP
    BSF PORTC,1 ;LED
    nop
    nop
    nop ; Should be in sleep for 10sec.
    ENDASM
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    Your MCLRE is ON.
    If you are using power adapter (not battery), make sure you have 100nf cap from MCLRE pin to GND. And I am not even asking about 4K7 - 10K res to vdd; Assuming it is already there.

    And, if the osc is giving you issues somehow, then try OSCCON=%01110010.
    And check OSC stable bits in OSCSTAT.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,664


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    if you are going to do this sort of thing in asm then you need to understand how banked memory access is
    used for this chip. hint [ baudcon is not in access bank ]
    Warning I'm not a teacher

  7. #7
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    Quote Originally Posted by richard View Post
    if you are going to do this sort of thing in asm then you need to understand how banked memory access is
    used for this chip. hint [ baudcon is not in access bank ]

    Thanks guys for all your replies. I really do appreciate the time you've
    taken.
    So Richard, I should have understood what you were saying the first time. I converted all code to PBP and it looks like RCIDL is set after all. However it didn't change the results.
    I then went to battery power, no change. Still a reset every 2.14sec. I also changed several of the configs with no change in results. I may mark this one up as part of the magical mystery tour as I have a work around for the problem. This is one of a couple problems that I could never solve. The other was the inability to make RA.7 a digital I/O. I wonder if my software has some corruption. Yea, when all else fails blame it on the software. Wayne

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,159


    Did you find this post helpful? Yes | No

    Default Re: Asm sleep - pbp sleep

    Did you set WDT to OFF?

    Ioannis

Similar Threads

  1. Can't @sleep
    By MOUNTAIN747 in forum General
    Replies: 3
    Last Post: - 30th December 2010, 17:29
  2. 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
  3. Help with PBP 'SLEEP' command
    By dreadmaul in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th November 2006, 07:40
  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 Mode in PBP
    By Keith in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th March 2005, 20:58

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