Hi,
ich bin ein kompletter neuling im Programmieren von Microcontrollern und hab nun vollgendes Problem.
Wenn ich vollgendes Chipprogramm mit MPASM von Microchip in eine Hexdatei wandeln will zeigt er 2 Fehler an und ich wüsste nicht wie ich diese beheben könnte.
In der Fehlerdatei zum einen „Illegal opcode“ und zum anderen „Symbol not previously defined (turnon)“.
Das ganze soll auf den Chip PIC 12C508a gebrannt werden.
Hoffe mir kann jemand helfen.
Hier das Programm:
ITPS Software
;
; Ituner power sequencer
;
; pd 030611 initial code
LIST p=12C508A ;Target processor
#include „P12C508A.INC“ ;Header file for target processor
; GP0 = VSW12 input 1 = ignition turned on
; GP1 = ON output 1 = turn power on
; GP2 = MBON# o.d. 0 = power button pressed
; GP3 = n.c. input
; GP4 = MBON2# o.d. 0 = power button pressed (parallel out,
; makes connector flip-tolerant)
; GP5 = n.c. output 0 = terminate unused pin
; Equates
PWR_OFF equ 0x00 ;power off state
PWR_ON equ 0x02 ;power on state
SW_ON equ 0x09 ;direction for switch on
SW_OFF equ 0x1d ;direction for switch off
ONDELAY equ .15 ;power on delay 3 seconds
ONDELAY2 equ .5 ;wait 1 second until push button
BUTTON equ .2 ;push button for 400 ms
OFFDELAY equ .25 ;shut down 5 s after ignition off
HARDOFF equ .25;&&&225 ;hard off after 45 seconds
; Register variables
cblock 0x10
cntr ;state counter
cntr2 ;state counter
waitl ;delay counter low
waitm ;delay counter mid
waith ;delay counter high
endc
; ORG 0x1FF ; processor reset vector
; Internal RC calibration value is placed at location 0x1FF by Microchip
; as a movlw k, where the k is a literal value.
; Reset entry
org 0
reset movwf OSCCAL ;set oscillator calibration
movlw PWR_OFF ;set initial state
movwf GPIO
movlw SW_OFF ;set pin directions
tris GPIO
movlw b’11001101’ ;set option register (pg. 17)
;disable wake-up on GP pin change
;disable weak pull-ups
;timer0 internal clock, positive edge
;prescaler -> WDT, 1:32 -> ~0.5s
option
clrwdt ;clear watchdog
; initial state - wait until ignition is on for ONDELAY
initial movlw ONDELAY ;initial power on
movwf cntr
initwait call delay200 ;wait
btfss GPIO,0 ;ignition on ?
goto initial ;no: clear counter
decfsz cntr,f ;initial time-out
goto initwait
; turn power on, wait ONDELAY2turnon movlw PWR_ON
movwf GPIO
movlw ONDELAY2 ;wait for ONDELAY2
movwf cntr
turnon1 call delay200 ;wait
decfsz cntr,f
goto turnon1
btfss GPIO,0 ;ignition on ?
goto reset ;no: turn off again
; push the system board power button
movlw SW_ON ;push the button
tris GPIO
movlw BUTTON ;wait for BUTTON
movwf cntr
button1 call delay200 ;wait
decfsz cntr,f
goto button1
movlw SW_OFF ;release the button
tris GPIO
; power on state - shut down if ignition off for OFFDELAY
onstate movlw OFFDELAY
movwf cntr
onstate1 call delay200
btfsc GPIO,0 ;ignition on ?
goto onstate ;yes: reset timer
decfsz cntr,f
goto onstate1
; shut down - push the system board power button
movlw SW_ON ;push the button
tris GPIO
movlw BUTTON ;wait for BUTTON
movwf cntr
button2 call delay200 ;wait
decfsz cntr,f
goto button2
movlw SW_OFF ;release the button
tris GPIO
; turn-off state - turn off power after HARDOFF
; go back to restart after ONDELAY
movlw HARDOFF
movwf cntr
movlw ONDELAY
movwf cntr2
shut1 call delay200
btfss GPIO,0 ;ignition on ?
goto shut2 ;:no
decfsz cntr2,f
goto turnon ;go turn-on if ignition on for ONDELAY
goto shut3
shut2 movlw ONDELAY ;ignition off - restart on timer
movwf cntr2
shut3 decfsz cntr,f
goto shut1 ;keep waiting
goto reset ;do hard power off
; 200 ms delay routine
delay200 clrwdt ;tickle the watchdog
movlw .2 ;note count is +1 (decfsz !)
movwf waith
movlw .0
movwf waitm
clrf waitl
del1 decfsz waitl,f ;delay loop - 3 us per iteration
goto del1
decfsz waitm,f
goto del1
decfsz waith,f
goto del1
retlw 0; define configuration bits
__config _MCLRE_OFF & _CP_OFF & _WDT_ON & _IntRC_OSC
;_MCLRE_ON EQU H’0FFF’
;_MCLRE_OFF EQU H’0FEF’
;_CP_ON EQU H’0FF7’
;_CP_OFF EQU H’0FFF’
;_WDT_ON EQU H’0FFF’
;_WDT_OFF EQU H’0FFB’
;_LP_OSC EQU H’0FFC’
;_XT_OSC EQU H’0FFD’
;_IntRC_OSC EQU H’0FFE’
;_ExtRC_OSC EQU H’0FFF’
end
