il programma è abbastanza semplice;
tramite un pulsante cambio il gioco i esecuzione e tramite un altro pulsante scelgo 2 diversi tempi per l'esecuzione...sono 6 giochi luce,è un display 7 segmenti mi dice il gioco in esecuzione...
il problema nasce se viene via la luce,si ripartirebbe dal gioco 1...è possibile fare in modo che anche se manca la corrente al ripristino,riparta da dove si è fermata?
ad esempio se si utilizza il gioco " 5 " al ripristino della corrente continui il 5
non so come fare...è tutto funzionante per il resto
- Codice: Seleziona tutto
;**************************************************
;CENTRALINA LUCI CARLO MUSUMECI
;**************************************************
PROCESSOR 16F84A
RADIX DEC
INCLUDE "P16F84A.INC"
ERRORLEVEL -302
;Setup of PIC configuration flags
;XT oscillator
;Disable watch dog timer
;Enable power up timer
;Disable code protect
__CONFIG 3FF1H
LED EQU 0
NEXT EQU 4
SPEED EQU 7
ORG 0CH
Count RES 2
Shift RES 1
nTick RES 1
;Reset Vector
;Start point at CPU reset
ORG 00H
bsf STATUS,RP0 ; seleziona banco registri 1
movlw 00010000B ;
movwf TRISA ;assegna IN OUT in TRISA
movlw 10000000B ; //////
movwf TRISB ; idem
movlw 00000100B
movwf OPTION_REG
;Commuta sul primo banco dei registri
bcf STATUS,RP0 ;seleziona Banco registri 0
movlw 00000001B
movwf Shift
Mainloop
GIOCO1
call GIOCOLUCI1
btfsc PORTA,NEXT
goto GIOCO2
goto GIOCO1
GIOCO2
call GIOCOLUCI2
btfsc PORTA,NEXT
goto GIOCO3
goto GIOCO2
GIOCO3
call GIOCOLUCI3
btfsc PORTA,NEXT
goto GIOCO4
goto GIOCO3
GIOCO4
call GIOCOLUCI4
btfsc PORTA,NEXT
goto GIOCO5
goto GIOCO4
GIOCO5
call GIOCOLUCI5
btfsc PORTA,NEXT
goto GIOCO6
goto GIOCO5
GIOCO6
call GIOCOLUCI6
btfsc PORTA,NEXT
goto GIOCO1
goto GIOCO6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,SOTTO PROGRAMMI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GIOCOLUCI1
movlw 00000110B ;mostra nel display 7 segmenti collegato in PORTB il numero " 1 "
movwf PORTB ;//////////////////////////////////////////////////////////
movlw 00000001B
movwf PORTA
call Delay
movlw 00000010B
movwf PORTA
call Delay
movlw 00000100B
movwf PORTA
call Delay
movlw 00001000B
movwf PORTA
call Delay
RETURN
GIOCOLUCI2
movlw 01011011B
movwf PORTB
movlw 00000001B
movwf PORTA
call Delay
movlw 00000011B
movwf PORTA
call Delay
movlw 00000111B
movwf PORTA
call Delay
movlw 00001111B
movwf PORTA
call Delay
RETURN
GIOCOLUCI3
movlw 01001111B ; DISPLAY CHE TI DICE IL NUMERO DEL GIOCO
movwf PORTB
;SEQUENZA GIOCO 3
movlw 00001110B
movwf PORTA
call Delay
movlw 00001101B
movwf PORTA
call Delay
movlw 00001011B
movwf PORTA
call Delay
movlw 00000111B
movwf PORTA
call Delay
return
GIOCOLUCI4
movlw 01100110B
movwf PORTB
;SEQUENZA GIOCO 4
movlw 00000001B
movwf PORTA
call Delay
movlw 00000011B
movwf PORTA
call Delay
movlw 00000111B
movwf PORTA
call Delay
movlw 00001111B
movwf PORTA
call Delay
movlw 00000111B
movwf PORTA
call Delay
movlw 00000011B
movwf PORTA
call Delay
movlw 00000001B
movwf PORTA
call Delay
movlw 00000000B
movwf PORTA
call Delay
RETURN
GIOCOLUCI5
movlw 01101101B ; DISPLAY CHE TI DICE IL NUMERO DEL GIOCO
movwf PORTB
;SEQUENZA LUCI 5
movlw 00000001B
movwf PORTA
call Delay
movlw 00000011B
movwf PORTA
call Delay
movlw 00000111B
movwf PORTA
call Delay
movlw 00001111B
movwf PORTA
call Delay
movlw 00001110B
movwf PORTA
call Delay
movlw 00001100B
movwf PORTA
call Delay
movlw 00001000B
movwf PORTA
call Delay
RETURN
GIOCOLUCI6
movlw 01111101B ; DISPLAY CHE TI DICE IL NUMERO DEL GIOCO
movwf PORTB
;SEQUENZALUCI
movlw 00000001B
movwf PORTA
call Delay
movlw 00000011B
movwf PORTA
call Delay
movlw 00000110B
movwf PORTA
call Delay
movlw 00001100B
movwf PORTA
call Delay
movlw 00001000B
movwf PORTA
call Delay
RETURN
Delay
movlw 6
movwf TMR0
btfsc PORTB,SPEED
goto tm1
goto tm2
tm1
movlw 40
movwf Count
goto DelayLoop
tm2
movlw 16
movwf Count
goto DelayLoop
DelayLoop
movf TMR0,W
btfss STATUS,Z
goto DelayLoop
movlw 6
movwf TMR0
decfsz Count,1
goto DelayLoop
return
END

Elettrotecnica e non solo (admin)
Un gatto tra gli elettroni (IsidoroKZ)
Esperienza e simulazioni (g.schgor)
Moleskine di un idraulico (RenzoDF)
Il Blog di ElectroYou (webmaster)
Idee microcontrollate (TardoFreak)
PICcoli grandi PICMicro (Paolino)
Il blog elettrico di carloc (carloc)
DirtEYblooog (dirtydeeds)
Di tutto... un po' (jordan20)
AK47 (lillo)
Esperienze elettroniche (marco438)
Telecomunicazioni musicali (clavicordo)
Automazione ed Elettronica (gustavo)
Direttive per la sicurezza (ErnestoCappelletti)
EYnfo dall'Alaska (mir)
Apriamo il quadro! (attilio)
H7-25 (asdf)
Passione Elettrica (massimob)
Elettroni a spasso (guidob)
Bloguerra (guerra)



io generalmente li riuso queste procedure ovunque e mai dato problemi