avrei bisogno di una mano perché non riesco a capire cosa non funziona nella programmazione che ho realizzato.
il programma consiste nel far attivare delle porte a cui sono collegati dei motorini che sollevano un braccio e rilasciandolo questo braccio picchia su uno xilofono. questo progetto mi serve per la maturità. E non riesco a capire cosa non va bene, perché durante il debug il programma si ferma alla routine di avvio e fin qui va bene, però se tolto la routine di avvio il programma fa quello che vuole e salta alcune istruzioni.
grazie a tutti :)
- Codice: Seleziona tutto
#ifdef __18F4520
#include <p18f4520.inc>
CONFIG WDT=OFF, OSC=RCIO6, LVP=OFF
#else ifdef __18F46K22
#include <p18f46k22.inc>
CONFIG WDTEN=OFF, FOSC=HSMP, LVP=OFF
;CONFIG WDTEN=OFF, FOSC=RCIO6, LVP=OFF
#endif
CONT1 equ 0x03
CONT2 equ 0x04
org 0x0000
RESET_V
goto START ;Reset Vector
; movf 0x00
; movwf TRISD
; movf 0xff
; movwf TRISB
org 0x020
START:
call GIPO
call avvio
call Init
call SI
call SI
call DO
call RE
call RE
call DO
call SI
call LA
call SOL
call SOL
call LA
call SI
call LA
call SOL_V
call SOL_V
call LA
call LA
call SI
call SOL
call LA
call SI_V
call DO_V
call SI
call SOL
call LA
call SI_V
call DO_V
call SI
call SOL
call LA
call RE_B
goto $
;-----------------------------------------------------------------------------------------------------------
; routine avvio
;-----------------------------------------------------------------------------------------------------------
avvio:
avvio_1: btfss PORTB,0
bra avvio_1
return
;------------------------------------------------------------------------------------------------------------
; routine movimento
;------------------------------------------------------------------------------------------------------------
SI:
bsf PORTD,4
;SI_1: btfsc PORTB,4
; BRA SI_1
call delaySI
bcf PORTD,4
return
SI_V:
bsf PORTD,4
;SI_V1: btfsc PORTB,4
; BRA SI_V1
call delaySI_V
bcf PORTD,4
return
DO:
bsf PORTD,0
;DO_1: btfsc PORTB,0
; BRA DO_1
call delayDO
bcf PORTD,0
return
DO_V:
bsf PORTD,0
;DO_V1: btfsc PORTB,0
;BRA DO_V1
call delayDO_V
bcf PORTD,0
return
RE:
bsf PORTD,1
;RE_1: btfsc PORTB,1
; BRA RE_1
call delayRE
bcf PORTD,1
return
SOL:
bsf PORTD,2
;SOL_1: btfsc PORTB,2
; BRA SOL_1
call delaySOL
bcf PORTD,2
return
SOL_V:
bsf PORTD,2
;SOL_V1: btfsc PORTB,2
; BRA SOL_V1
call delaySOL_V
bcf PORTD,2
return
LA:
bsf PORTD,3
;LA_1: btfsc PORTB,3
; BRA LA_1
call delayLA
bcf PORTD,3
return
RE_B:
bsf PORTD,5
;RE_B1: btfsc PORTB,5
; BRA RE_B1
call delayRE_B
bcf PORTD,5
return
;------------------------------------------------------------------------------------------------------------
; configurazione porte
;-----------------------------------------------------------------------------------------------------------
GIPO:
setf ADCON1 ;Make analog mux’d pins digital
clrf LATB ;Clear PORTB output latches
movlw b'11111111' ;Load value to make lower 4 bits outputs
movwf TRISB ;Move value to TRISB
setf ADCON1 ;Make analog mux’d pins digital
clrf LATD ;Clear PORTB output latches
movlw b'00000000' ;Load value to make lower 4 bits outputs
movwf TRISD ;Move value to TRISB
;Il pin RA0 al reset è configurato come ingresso analogico
;occorre predisporlo come ingresso digitale
movlb 0X0f ;set bank 15
bcf ANSELA,0 ;RA0 digital I/O
movlb 0X00 ;set bank 0
bcf TRISA,0 ;confuguro RA0 come output
bcf LATA,0 ;led acceso
return
;---------------------------------------------------------------------------------------------------------------
; delay routine
;---------------------------------------------------------------------------------------------------------------
delaySI:
movlw 0x0a
movwf CONT2
delay_SI1:
decfsz CONT2
bra delay_SI1
return
delaySI_V:
movlw d'5'
movwf CONT2
delay_SI_V1:
decfsz CONT2
bra delay_SI_V1
return
delayDO:
movlw 0x0a
movwf CONT2
delay_DO1:
decfsz CONT2
bra delay_DO1
return
delayDO_V:
movlw d'5'
movwf CONT2
delay_DO_V1:
decfsz CONT2
bra delay_DO_V1
return
delayRE:
movlw 0x0a
movwf CONT2
delay_RE1:
decfsz CONT2
bra delay_RE1
return
delayRE_B:
movlw 0x0a
movwf CONT2
delay_RE_B1:
decfsz CONT2
bra delay_RE_B1
return
delaySOL:
movlw 0x0a
movwf CONT2
delay_SOL1:
decfsz CONT2
bra delay_SOL1
return
delaySOL_V:
movlw d'5'
movwf CONT2
delay_SOL_V1:
decfsz CONT2
bra delay_SOL_V1
return
delayLA:
movlw 0x0a
movwf CONT2
delay_LA1:
decfsz CONT2
bra delay_LA1
return
;-----------------------------------------------------------------------------------------------
; timer PIC
;-----------------------------------------------------------------------------------------------
Init:
call Timer1
call Interrupts
return
Timer1:
;configurazione Timer1 - 16 bits in interrupts
;base delay=100 msec
movlw b'00110010' ;Fclock=Fosc/4, Prescaler 1:8,Clock=System Clock, R/W in one operation,Disable (bit0)
movwf T1CON
bcf T1GCON,7 ;TMR1GEN=0
movlw 0x9e ;Tclock=2usec * 25000= 50 msec // 65535-25000= 0x9e57
movwf TMR1H
movlw 0x57
movwf TMR1L
;setto il contatore delay on/off led
movlw 0x02
movwf CONT1
return
Interrupts:
;setto int per Timer1
;setto interrput priority enable
movlw b'10000000' ;IPEN=1
iorwf RCON
;resetto eventuale int pendente sul timer1
movlw b'11111110' ;reset receiver interrupt flag bit
andwf PIR1 ;PERIPHERAL INTERRUPT REQUEST1
;setto l'interrupt relativo al overflow del TIMER1
movlw b'00000001' ;set TMR1IE bit0
movwf PIE1 ;PERIPHERAL INTERRUPT ENABLE1 REGISTER
;setto interrupt priority high (vector 0x008)
movlw b'00000001' ;set RECEIVER INTERRUPT PRIORITY bit0 TMR1IP
movwf IPR1 ;INTERRUPT PRIORITY REGISTER1
;setto enable general e peripheral interrupt enable bit
bsf INTCON,7 ;GIE_GIEH
bsf INTCON,6 ;PEIE_GIEL
;enable timer1
bsf T1CON,0
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)


