Newsgroup: it.hobby.elettronica.digitale
Titolo: sleep, interrupt, non funza

Salve,
Visto che non ho trovato esempi di interrupt in C ho strusato il file asm
prodotto da icprog
aggiungendo un blocchetto per la gestione dell'interrupt svegliato da RB0
(INTF) e uno sleep alla fine.
Compilo cosė: mpasm bof.asm. (mi da qualche warning)
Il problema é che il programma non passa affatto in sleep e quando dal menu di
icprog scelgo view/assembler non trovo
pių le istruzioni sleep , org 04h,...
Qui sotto c'é di bof.asm e anche bof.lst
Mi direste dove sbaglio p.f?
grazie
marco
; Generated by WinDis84, (c) Nigel Goodwin 1998.
            ;LIST      P=16F84, F=INHX8M
            PROCESSOR       16F84a
            RADIX           DEC
            include "P16F84a.inc"
            ORG     0x0000
            CLRF    STATUS
            MOVLW   0x00
            MOVWF   PCLATH
            GOTO    Label_0001
;;;;;;;;;;;;;;
 ORG     04H
        ;**********************************************************************
        ; Interrupt handler
        ;**********************************************************************
        ;non faccio niente per non complicare
 
        bcf     INTCON,INTF
        ;Ritorna al programma principale
        retfie
;;;;;;;;;;;;;;;;     
Label_0001  MOVLW   0x0C
            MOVWF   FSR
            MOVLW   0x0F
            CALL    Label_0002
            CLRF    STATUS
            GOTO    Label_0003
Label_0004  XORWF   FSR       , W
            CLRF    INDF
            INCF    FSR       , f
Label_0002  XORWF   FSR       , W
            BTFSS   STATUS    , Z
            GOTO    Label_0004
            RETLW   0x00
            ORG     0x03D4
Label_0006  MOVWF   0x0C
Label_0005  CLRWDT
            NOP
            NOP
            NOP
            NOP
            NOP
            NOP
            DECFSZ  0x0C      , f
            GOTO    Label_0005
            BCF     STATUS    , RP0
            RETURN
Label_0009  MOVLW   0x64
            BCF     STATUS    , RP0
            CALL    Label_0006
            MOVLW   0xFF
            ADDWF   0x0D      , f
            BTFSS   STATUS    , C
            DECF    0x0E      , f
            MOVF    0x0E      , W
            IORWF   0x0D      , W
            BTFSS   STATUS    , Z
            GOTO    Label_0007
            GOTO    Label_0008
Label_0007  GOTO    Label_0009
Label_0008  BCF     STATUS    , RP0
            RETURN
Label_0003  MOVLW   0x01
            BSF     STATUS    , RP0
            MOVWF   TRISB
            BCF     STATUS    , RP0
            BSF     PORTB     , 01
            MOVLW   0x88
            MOVWF   0x0D
            MOVLW   0x13
            MOVWF   0x0E
            CALL    Label_0009
            CLRF    PORTB
            MOVLW   0xD0
            MOVWF   0x0D
            MOVLW   0x07
            MOVWF   0x0E
            CALL    Label_0009
            movlw   10010000B
            movwf   INTCON
            SLEEP
            NOP
            GOTO    Label_0001
 
            ORG     0x2000
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
 
            ORG     0x2007
            DATA    0x11
 
            ORG     0x2100
            DATA    0xFF
            ....
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
********************************************************************************
MPASM 02.80 Released              BUF.ASM   10-25-2001  11:19:10         PAGE
1
LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE
                      00001 ; Generated by WinDis84, (c) Nigel Goodwin 1998.
                      00002 
                      00003             ;LIST      P=16F84a, F=INHX8M
                      00004             PROCESSOR       16F84a
                      00005             RADIX           DEC
                      00006 
                      00007             include "P16F84a.inc"
                      00001         LIST
                      00002 ; P16F84A.INC  Standard Header File, Version 2.00
Microchip Technology, Inc.
                      00134         LIST
0000                  00008             ORG     0x0000
                      00009 
0000   0183           00010             CLRF    STATUS
0001   3000           00011             MOVLW   0x00
0002   008A           00012             MOVWF   PCLATH
0003   2806           00013             GOTO    Label_0001
                      00014 ;;;;;;;;;;;;;;
0004                  00015  ORG     04H
                      00016 
                      00017
;**********************************************************************
                      00018         ; Interrupt handler
                      00019
;**********************************************************************
                      00020 
                      00021          
0004   108B           00022         bcf     INTCON,INTF
                      00023 
                      00024         ;Ritorna al programma principale
0005   0009           00025         retfie
                      00026 
                      00027  
                      00028  
                      00029  
                      00030  ;;;;;;;;;;;;;;;;     
0006   300C           00031 Label_0001  MOVLW   0x0C
0007   0084           00032             MOVWF   FSR
0008   300F           00033             MOVLW   0x0F
0009   200F           00034             CALL    Label_0002
000A   0183           00035             CLRF    STATUS
000B   2BEF           00036             GOTO    Label_0003
000C   0604           00037 Label_0004  XORWF   FSR       , W
000D   0180           00038             CLRF    INDF
000E   0A84           00039             INCF    FSR       , f
000F   0604           00040 Label_0002  XORWF   FSR       , W
0010   1D03           00041             BTFSS   STATUS    , Z
0011   280C           00042             GOTO    Label_0004
0012   3400           00043             RETLW   0x00
03D4                  00044             ORG     0x03D4
03D4   008C           00045 Label_0006  MOVWF   0x0C
03D5   0064           00046 Label_0005  CLRWDT
03D6   0000           00047             NOP
03D7   0000           00048             NOP
03D8   0000           00049             NOP
03D9   0000           00050             NOP
MPASM 02.80 Released              BUF.ASM   10-25-2001  11:19:10         PAGE
2
LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE
03DA   0000           00051             NOP
03DB   0000           00052             NOP
03DC   0B8C           00053             DECFSZ  0x0C      , f
03DD   2BD5           00054             GOTO    Label_0005
03DE   1283           00055             BCF     STATUS    , RP0
03DF   0008           00056             RETURN
03E0   3064           00057 Label_0009  MOVLW   0x64
03E1   1283           00058             BCF     STATUS    , RP0
03E2   23D4           00059             CALL    Label_0006
03E3   30FF           00060             MOVLW   0xFF
03E4   078D           00061             ADDWF   0x0D      , f
03E5   1C03           00062             BTFSS   STATUS    , C
03E6   038E           00063             DECF    0x0E      , f
03E7   080E           00064             MOVF    0x0E      , W
03E8   040D           00065             IORWF   0x0D      , W
03E9   1D03           00066             BTFSS   STATUS    , Z
03EA   2BEC           00067             GOTO    Label_0007
03EB   2BED           00068             GOTO    Label_0008
03EC   2BE0           00069 Label_0007  GOTO    Label_0009
03ED   1283           00070 Label_0008  BCF     STATUS    , RP0
03EE   0008           00071             RETURN
03EF   3001           00072 Label_0003  MOVLW   0x01
03F0   1683           00073             BSF     STATUS    , RP0
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are
correct.
03F1   0086           00074             MOVWF   TRISB
03F2   1283           00075             BCF     STATUS    , RP0
03F3   1486           00076             BSF     PORTB     , 01
03F4   3088           00077             MOVLW   0x88
03F5   008D           00078             MOVWF   0x0D
03F6   3013           00079             MOVLW   0x13
03F7   008E           00080             MOVWF   0x0E
03F8   23E0           00081             CALL    Label_0009
03F9   0186           00082             CLRF    PORTB
03FA   30D0           00083             MOVLW   0xD0
03FB   008D           00084             MOVWF   0x0D
03FC   3007           00085             MOVLW   0x07
03FD   008E           00086             MOVWF   0x0E
03FE   23E0           00087             CALL    Label_0009
03FF   3090           00088             movlw   10010000B
Warning[220]: Address exceeds maximum range for this processor.
0400   008B           00089             movwf   INTCON
                      00090 
Warning[220]: Address exceeds maximum range for this processor.
0401   0063           00091             SLEEP
Warning[220]: Address exceeds maximum range for this processor.
0402   0000           00092             NOP
Warning[220]: Address exceeds maximum range for this processor.
0403   2806           00093             GOTO    Label_0001
                      00094  
2000                  00095             ORG     0x2000
Warning[220]: Address exceeds maximum range for this processor.
2000   000F           00096             DATA    0x0F
Warning[220]: Address exceeds maximum range for this processor.
MPASM 02.80 Released              BUF.ASM   10-25-2001  11:19:10         PAGE
3
LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE
2001   000F           00097             DATA    0x0F
Warning[220]: Address exceeds maximum range for this processor.
2002   000F           00098             DATA    0x0F
Warning[220]: Address exceeds maximum range for this processor.
2003   000F           00099             DATA    0x0F
                      00100  
2007                  00101             ORG     0x2007
Warning[220]: Address exceeds maximum range for this processor.
2007   0011           00102             DATA    0x11
                      00103  
2100                  00104             ORG     0x2100
2100   00FF           00105             DATA    0xFF
2101   00FF           00106             DATA    0xFF
2102   00FF           00107             DATA    0xFF
2103   00FF           00108             DATA    0xFF
2104   00FF           00109             DATA    0xFF
2105   00FF           00110             DATA    0xFF
2106   00FF           00111             DATA    0xFF
2107   00FF           00112             DATA    0xFF
2108   00FF           00113             DATA    0xFF
2109   00FF           00114             DATA    0xFF
210A   00FF           00115             DATA    0xFF
210B   00FF           00116             DATA    0xFF
210C   00FF           00117             DATA    0xFF
210D   00FF           00118             DATA    0xFF
210E   00FF           00119             DATA    0xFF
210F   00FF           00120             DATA    0xFF
2110   00FF           00121             DATA    0xFF
2111   00FF           00122             DATA    0xFF
2112   00FF           00123             DATA    0xFF
2113   00FF           00124             DATA    0xFF
2114   00FF           00125             DATA    0xFF
2115   00FF           00126             DATA    0xFF
2116   00FF           00127             DATA    0xFF
2117   00FF           00128             DATA    0xFF
2118   00FF           00129             DATA    0xFF
2119   00FF           00130             DATA    0xFF
211A   00FF           00131             DATA    0xFF
211B   00FF           00132             DATA    0xFF
211C   00FF           00133             DATA    0xFF
211D   00FF           00134             DATA    0xFF
211E   00FF           00135             DATA    0xFF
211F   00FF           00136             DATA    0xFF
2120   00FF           00137             DATA    0xFF
2121   00FF           00138             DATA    0xFF
2122   00FF           00139             DATA    0xFF
2123   00FF           00140             DATA    0xFF
2124   00FF           00141             DATA    0xFF
2125   00FF           00142             DATA    0xFF
2126   00FF           00143             DATA    0xFF
2127   00FF           00144             DATA    0xFF
2128   00FF           00145             DATA    0xFF
2129   00FF           00146             DATA    0xFF
MPASM 02.80 Released              BUF.ASM   10-25-2001  11:19:10         PAGE
4
LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE
212A   00FF           00147             DATA    0xFF
212B   00FF           00148             DATA    0xFF
212C   00FF           00149             DATA    0xFF
212D   00FF           00150             DATA    0xFF
212E   00FF           00151             DATA    0xFF
212F   00FF           00152             DATA    0xFF
2130   00FF           00153             DATA    0xFF
2131   00FF           00154             DATA    0xFF
2132   00FF           00155             DATA    0xFF
2133   00FF           00156             DATA    0xFF
2134   00FF           00157             DATA    0xFF
2135   00FF           00158             DATA    0xFF
2136   00FF           00159             DATA    0xFF
2137   00FF           00160             DATA    0xFF
2138   00FF           00161             DATA    0xFF
2139   00FF           00162             DATA    0xFF
213A   00FF           00163             DATA    0xFF
213B   00FF           00164             DATA    0xFF
213C   00FF           00165             DATA    0xFF
213D   00FF           00166             DATA    0xFF
213E   00FF           00167             DATA    0xFF
213F   00FF           00168             DATA    0xFF
                      00169 
                      00170             END
MPASM 02.80 Released              BUF.ASM   10-25-2001  11:19:10         PAGE
5
SYMBOL TABLE
  LABEL                             VALUE 
C                                 00000000
DC                                00000001
EEADR                             00000009
EECON1                            00000088
EECON2                            00000089
EEDATA                            00000008
EEIE                              00000006
EEIF                              00000004
F                                 00000001
FSR                               00000004
GIE                               00000007
INDF                              00000000
INTCON                            0000000B
INTE                              00000004
INTEDG                            00000006
INTF                              00000001
IRP                               00000007
Label_0001                        00000006
Label_0002                        0000000F
Label_0003                        000003EF
Label_0004                        0000000C
Label_0005                        000003D5
Label_0006                        000003D4
Label_0007                        000003EC
Label_0008                        000003ED
Label_0009                        000003E0
NOT_PD                            00000003
NOT_RBPU                          00000007
NOT_TO                            00000004
OPTION_REG                        00000081
PCL                               00000002
PCLATH                            0000000A
PORTA                             00000005
PORTB                             00000006
PS0                               00000000
PS1                               00000001
PS2                               00000002
PSA                               00000003
RBIE                              00000003
RBIF                              00000000
RD                                00000000
RP0                               00000005
RP1                               00000006
STATUS                            00000003
T0CS                              00000005
T0IE                              00000005
T0IF                              00000002
T0SE                              00000004
TMR0                              00000001
TRISA                             00000085
TRISB                             00000086
W                                 00000000
WR                                00000001
MPASM 02.80 Released              BUF.ASM   10-25-2001  11:19:10         PAGE
6
SYMBOL TABLE
  LABEL                             VALUE 
WREN                              00000002
WRERR                             00000003
Z                                 00000002
_CP_OFF                           00003FFF
_CP_ON                            0000000F
_HS_OSC                           00003FFE
_LP_OSC                           00003FFC
_PWRTE_OFF                        00003FFF
_PWRTE_ON                         00003FF7
_RC_OSC                           00003FFF
_WDT_OFF                          00003FFB
_WDT_ON                           00003FFF
_XT_OSC                           00003FFD
__16F84A                          00000001
MEMORY USAGE MAP ('X' = Used,  '-' = Unused)
0000 : XXXXXXXXXXXXXXXX XXX------------- ---------------- ----------------
03C0 : ---------------- ----XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
0400 : XXXX------------ ---------------- ---------------- ----------------
2000 : XXXX---X-------- ---------------- ---------------- ----------------
2100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
All other memory blocks unused.
Program Memory Words Used:    63
Program Memory Words Free:   961
Errors   :     0
Warnings :     9 reported,     0 suppressed
Messages :     1 reported,     0 suppressed
 
-- 
Posted from 
ge-dial-3-p10.vtx.ch
 [212.147.21.74] 
via Mailgate.ORG Server - 
http://www.Mailgate.ORG

(pic16f84a)
Ho riprovato usando solo picclite (non mpasm) e lasciando perdere ORG 04H.
RB0 é a terra tramite una resistenza di 9.4kohms. Mettendo 5 v su RB0 il
programma riparte  da label_0001
però  non si ferma subito a sleep ma riparte una seconda volta (senza input su
RB0, o in altre parole sleep funza una volta su due)
Un idea dell'errore?
; Generated by WinDis84, (c) Nigel Goodwin 1998.
            LIST      P=16F84, F=INHX8M
            include "P16FXX.inc"
            ORG     0x0000
            CLRF    STATUS
            MOVLW   0x00
            MOVWF   PCLATH
            GOTO    Label_0001
Label_0001  MOVLW   0x0C
            MOVWF   FSR
            MOVLW   0x0F
            CALL    Label_0002
            CLRF    STATUS
            GOTO    Label_0003
Label_0004  XORWF   FSR       , W
            CLRF    INDF
            INCF    FSR       , f
Label_0002  XORWF   FSR       , W
            BTFSS   STATUS    , Z
            GOTO    Label_0004
            RETLW   0x00
            ORG     0x03D0

Label_0003  MOVLW   0x10
            MOVWF   INTCON
            BSF     STATUS    , RP0
            CLRF    TRISB
            BSF     TRISB     , 00
            BCF     STATUS    , RP0
            BSF     PORTB     , 01
            MOVLW   0x88
            MOVWF   0x0D
            MOVLW   0x13
            MOVWF   0x0E
            CALL    Label_0009
            CLRF    PORTB
            MOVLW   0xD0
            MOVWF   0x0D
            MOVLW   0x07
            MOVWF   0x0E
            CALL    Label_0009
            SLEEP
            ;l'struzione sotto mi sembra inutile e non cambia niente
            BCF     INTCON    , INTF
            GOTO    Label_0001
 
            ORG     0x2000
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
            DATA    0x0F
 
            ORG     0x2007
            DATA    0x11
 
            ORG     0x2100
            DATA    0xFF
            DATA    0xFF
          ...
-- 
Posted from 
ge-dial-3-p48.vtx.ch
 [212.147.21.112] 
