MAS4585
Newbie level 5
Hello All
Good Evening...
I am trying to design a Fish feeder timer with 12F675. Its has 5 Pre Programmed out put that are for 1 Second,2 ,4,6 and 8 seconds.
Output will turn off after the pre programed time was reached. Simulation of the circuit with Proteus is working... But the real hardware showing some faulty trigger.
when I complile the code with MPlab 8.33, There show an error.
"Symbol not previously defined (TMR0IE)"
Please see the complete code below.
I dont understand, What is real problem....Any help would appriciated.
Regards
Good Evening...
I am trying to design a Fish feeder timer with 12F675. Its has 5 Pre Programmed out put that are for 1 Second,2 ,4,6 and 8 seconds.
Output will turn off after the pre programed time was reached. Simulation of the circuit with Proteus is working... But the real hardware showing some faulty trigger.
when I complile the code with MPlab 8.33, There show an error.
"Symbol not previously defined (TMR0IE)"
Please see the complete code below.
Code:
list n=0, c=150, r=dec
; File: main.asm
; Target: PIC12F675
;*********************************************************************
; ___ ___
; VDD ->|1 U 8|<- VSS
; LED1 <>|2 7|<> LED3
; LED2 <>|3 6|<> LED4
; SW1n ->|4 5|<> LED5
; ¯¯¯¯¯¯¯
; PIC12F675
;
;*********************************************************************
;
; If the switch is Press and hold (My timer output is enable for 1 Minute minimum) either Press, all LED will be ON.
; After 1 Second, LED 1 Turn Off,
; After 2 Second, LED 2 Turn Off
; After 4 Second, LED 3 Turn Off
; After 6 Second, LED 4 Turn Off
; After 8 Second, LED 5 Turn Off.
;
; (5 LED is used for Manual Timer selection for the Motor will Enable..)
;
#include <p12f675.inc>
LIST
;==========================================================================
; MPASM PIC12F675 processor include
;
; (c) Copyright 1999-2013 Microchip Technology, All rights reserved
;==========================================================================
LIST
errorlevel -302 ; suppress banksel warning messages
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
#define TIMER0_INTERRUPTS_PER_SECOND D'4000'
#define LED1 GPIO,5
#define LED2 GPIO,4
#define LED3 GPIO,0
#define LED4 GPIO,2
#define LED5 GPIO,1
#define SW1n GPIO,3
ISR_DATA udata_shr 0x20
WREG_save res 1
STATUS_save res 1
TIMER_DATA udata_shr
IntsInOneSecond res 2
Seconds res 1
RESET_CODE CODE 0x000
goto Start
ISR_CODE CODE 0x004
movwf WREG_save
movf STATUS,W
movwf STATUS_save
btfsc INTCON,TMR0IE
btfss INTCON,TMR0IF
goto ISR_Exit
bcf INTCON,TMR0IF
movlw 256-250+3
addwf TMR0,F
movlw -1
addwf IntsInOneSecond,F
skpc
addwf IntsInOneSecond+1,F
skpnc
goto ISR_Exit
movlw HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
movwf IntsInOneSecond+1
movlw LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
movwf IntsInOneSecond
incf Seconds,F
ISR_Exit:
movf STATUS_save,W
movwf STATUS
swapf WREG_save,F
swapf WREG_save,W
retfie
START_CODE CODE
Start:
btfsc STATUS,RP0
goto OscillatorCalibrationFailed
banksel OSCCAL
call GetOSCCAL
movwf OSCCAL
OscillatorCalibrationFailed:
banksel ANSEL
clrf ANSEL
clrf TRISIO
movlw B'11011111'
movwf OPTION_REG
banksel INTCON
clrf INTCON
clrf GPIO
movlw 0x07
movwf CMCON
movlw HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
movwf IntsInOneSecond+1
movlw LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
movwf IntsInOneSecond
clrf Seconds
clrf TMR0
movlw 256-250+3
addwf TMR0,F
bsf INTCON,TMR0IE
bsf INTCON,GIE
AppStart:
clrf GPIO
AppLoop:
btfsc SW1n
goto AppLoop
bcf INTCON,TMR0IE
movlw HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
movwf IntsInOneSecond+1
movlw LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
movwf IntsInOneSecond
clrf Seconds
movlw B'00110111' ; LED1-5 on
movwf GPIO
bsf INTCON,TMR0IE
AppTimeout:
movf Seconds,W
xorlw D'1'
skpnz
goto LED1_off
xorlw D'1'^D'2'
skpnz
goto LED2_off
xorlw D'2'^D'4'
skpnz
goto LED3_off
xorlw D'4'^D'6'
skpnz
goto LED4_off
xorlw D'6'^D'8'
skpnz
goto LED5_off
xorlw D'8'
sublw D'8'
skpc
goto WaitForButtonUp
CheckSwitch:
btfsc SW1n
goto AppStart
goto AppTimeout
;
;
;
WaitForButtonUp:
btfsc SW1n
goto AppStart
goto WaitForButtonUp
;
;
;
LED1_off:
movlw B'00010111' ; LED1 off
movwf GPIO
goto CheckSwitch
LED2_off:
movlw B'00000111' ; LED1-2 off
movwf GPIO
goto CheckSwitch
LED3_off:
movlw B'00000110' ; LED1-3 off
movwf GPIO
goto CheckSwitch
LED4_off:
movlw B'00000010' ; LED1-4 off
movwf GPIO
goto CheckSwitch
LED5_off:
movlw B'00000000' ; LED1-5 off
movwf GPIO
goto CheckSwitch
OSCCAL_CODE CODE 0x3ff
GetOSCCAL:
end
I dont understand, What is real problem....Any help would appriciated.
Regards
Last edited by a moderator: