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.