MPASM 5.51 MAIN.ASM 2-23-2018 16:59:10 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 list n=0, c=150, r=dec
00002 ; File: main.asm
00003 ; Target: PIC12F675
00004 ; Created: 2018-02-23
00005 ; Author: Dan1138
00006 ;*********************************************************************
00007 ; ___ ___
00008 ; VDD ->|1 U 8|<- VSS
00009 ; LED1 <>|2 7|<> LED3
00010 ; LED2 <>|3 6|<> LED4
00011 ; SW1n ->|4 5|<> LED5
00012 ; ¯¯¯¯¯¯¯
00013 ; PIC12F675
00014 ;
00015 ;*********************************************************************
00016 ;
00017 ; If the switch is Press and hold (My timer output is enable for 1 Minute minimum) either Press, all LED will be ON.
00018 ; After 1 Second, LED 1 Turn Off,
00019 ; After 2 Second, LED 2 Turn Off
00020 ; After 4 Second, LED 3 Turn Off
00021 ; After 6 Second, LED 4 Turn Off
00022 ; After 8 Second, LED 5 Turn Off.
00023 ;
00024 ; (5 LED is used for Manual Timer selection for the Motor will Enable..)
00025 ;
00026 ;*********************************************************************
00027 ; See: https://www.electro-tech-online.com/threads/fish-feeder-idea-help-regards.153045/
00028 ;*********************************************************************
00029 #include <p12f675.inc>
00001 LIST
00002
00003 ;==========================================================================
00004 ; MPASM PIC12F675 processor include
00005 ;
00006 ; (c) Copyright 1999-2013 Microchip Technology, All rights reserved
00007 ;==========================================================================
00008
00366 LIST
00030 errorlevel -302 ; suppress banksel warning messages
00031
2007 3FC4 00032 __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
00033
00034 #define TIMER0_INTERRUPTS_PER_SECOND D'4000'
00035 #define LED1 GPIO,5
00036 #define LED2 GPIO,4
00037 #define LED3 GPIO,0
00038 #define LED4 GPIO,2
00039 #define LED5 GPIO,1
00040 #define SW1n GPIO,3
00041
00042 ISR_DATA udata_shr 0x20
0020 00043 WREG_save res 1
0021 00044 STATUS_save res 1
00045
00046 TIMER_DATA udata_shr
0000 00047 IntsInOneSecond res 2
0002 00048 Seconds res 1
00049
00050 RESET_CODE CODE 0x000
0000 2??? 00051 goto Start
00052
00053
00054 ISR_CODE CODE 0x004
0004 00?? 00055 movwf WREG_save
0005 0803 00056 movf STATUS,W
0006 00?? 00057 movwf STATUS_save
00058
0007 1A8B 00059 btfsc INTCON,TMR0IE
0008 1D0B 00060 btfss INTCON,TMR0IF
0009 2??? 00061 goto ISR_Exit
000A 110B 00062 bcf INTCON,TMR0IF
000B 3009 00063 movlw 256-250+3
000C 0781 00064 addwf TMR0,F
000D 30FF 00065 movlw -1
000E 07?? 00066 addwf IntsInOneSecond,F
000F 1C03 00067 skpc
0010 07?? 00068 addwf IntsInOneSecond+1,F
0011 1803 00069 skpnc
0012 2??? 00070 goto ISR_Exit
0013 300F 00071 movlw HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
0014 00?? 00072 movwf IntsInOneSecond+1
0015 309F 00073 movlw LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
0016 00?? 00074 movwf IntsInOneSecond
0017 0A?? 00075 incf Seconds,F
00076
0018 00077 ISR_Exit:
0018 08?? 00078 movf STATUS_save,W
0019 0083 00079 movwf STATUS
001A 0E?? 00080 swapf WREG_save,F
001B 0E?? 00081 swapf WREG_save,W
001C 0009 00082 retfie
00083
00084 START_CODE CODE
0000 00085 Start:
0000 1A83 00086 btfsc STATUS,RP0
0001 2??? 00087 goto OscillatorCalibrationFailed
0002 1683 00088 banksel OSCCAL
0003 2??? 00089 call GetOSCCAL
0004 0090 00090 movwf OSCCAL
0005 00091 OscillatorCalibrationFailed:
0005 1683 00092 banksel ANSEL
0006 019F 00093 clrf ANSEL
0007 0185 00094 clrf TRISIO
0008 30DF 00095 movlw B'11011111'
0009 0081 00096 movwf OPTION_REG
000A 1283 00097 banksel INTCON
000B 018B 00098 clrf INTCON
000C 0185 00099 clrf GPIO
000D 3007 00100 movlw 0x07
000E 0099 00101 movwf CMCON
000F 300F 00102 movlw HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
0010 00?? 00103 movwf IntsInOneSecond+1
0011 309F 00104 movlw LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
0012 00?? 00105 movwf IntsInOneSecond
0013 01?? 00106 clrf Seconds
0014 0181 00107 clrf TMR0
0015 3009 00108 movlw 256-250+3
0016 0781 00109 addwf TMR0,F
0017 168B 00110 bsf INTCON,TMR0IE
0018 178B 00111 bsf INTCON,GIE
00112 ;
00113 ;
00114 ;
0019 00115 AppStart:
0019 0185 00116 clrf GPIO
001A 00117 AppLoop:
001A 1985 00118 btfsc SW1n
001B 2??? 00119 goto AppLoop
001C 128B 00120 bcf INTCON,TMR0IE
001D 300F 00121 movlw HIGH(TIMER0_INTERRUPTS_PER_SECOND-1)
001E 00?? 00122 movwf IntsInOneSecond+1
001F 309F 00123 movlw LOW(TIMER0_INTERRUPTS_PER_SECOND-1)
0020 00?? 00124 movwf IntsInOneSecond
0021 01?? 00125 clrf Seconds
0022 3037 00126 movlw B'00110111' ; LED1-5 on
0023 0085 00127 movwf GPIO
0024 168B 00128 bsf INTCON,TMR0IE
0025 00129 AppTimeout:
0025 08?? 00130 movf Seconds,W
0026 3A01 00131 xorlw D'1'
0027 1903 00132 skpnz
0028 2??? 00133 goto LED1_off
0029 3A03 00134 xorlw D'1'^D'2'
002A 1903 00135 skpnz
002B 2??? 00136 goto LED2_off
002C 3A06 00137 xorlw D'2'^D'4'
002D 1903 00138 skpnz
002E 2??? 00139 goto LED3_off
002F 3A02 00140 xorlw D'4'^D'6'
0030 1903 00141 skpnz
0031 2??? 00142 goto LED4_off
0032 3A0E 00143 xorlw D'6'^D'8'
0033 1903 00144 skpnz
0034 2??? 00145 goto LED5_off
0035 3A08 00146 xorlw D'8'
0036 3C08 00147 sublw D'8'
0037 1C03 00148 skpc
0038 2??? 00149 goto WaitForButtonUp
0039 00150 CheckSwitch:
0039 1985 00151 btfsc SW1n
003A 2??? 00152 goto AppStart
003B 2??? 00153 goto AppTimeout
00154 ;
00155 ;
00156 ;
003C 00157 WaitForButtonUp:
003C 1985 00158 btfsc SW1n
003D 2??? 00159 goto AppStart
003E 2??? 00160 goto WaitForButtonUp
00161 ;
00162 ;
00163 ;
003F 00164 LED1_off:
003F 3017 00165 movlw B'00010111' ; LED1 off
0040 0085 00166 movwf GPIO
0041 2??? 00167 goto CheckSwitch
0042 00168 LED2_off:
0042 3007 00169 movlw B'00000111' ; LED1-2 off
0043 0085 00170 movwf GPIO
0044 2??? 00171 goto CheckSwitch
0045 00172 LED3_off:
0045 3006 00173 movlw B'00000110' ; LED1-3 off
0046 0085 00174 movwf GPIO
0047 2??? 00175 goto CheckSwitch
0048 00176 LED4_off:
0048 3002 00177 movlw B'00000010' ; LED1-4 off
0049 0085 00178 movwf GPIO
004A 2??? 00179 goto CheckSwitch
004B 00180 LED5_off:
004B 3000 00181 movlw B'00000000' ; LED1-5 off
004C 0085 00182 movwf GPIO
004D 2??? 00183 goto CheckSwitch
00184
00185 OSCCAL_CODE CODE 0x3ff
03FF 00186 GetOSCCAL:
3FC4 00187 end