include "P12c509a.inc"
__CONFIG h’000E’ ; CP off, WDT on, internal cLOCk
DCCon equ 0
Ovl_in equ 1
Relay equ 2
Ovl_out equ 4
CBLOCK 0x0007
state ;state sequence
time0 ;counter0
time1 ;counter1
time2 ;counter2
ENDC
org 0
MOVwf OSCCAL ;set cal
bcf STATUS,PA0
MOVlw B’10001111’
option
;GP0 DCC ON/OFF (hi is ON);;;;;;GP1 is overload input (active lo)
;GP2 Reverse output ;;;;;;;;GP4 overload output (HI is overload)
;-----------------------------
MOVlw B’00000010’
tris GPIO
MOVlw B’00000001’ ;set ports
MOVwf GPIO
clrf state
;main loop starts here. SCANs for hi on overload.
test clrwdt
btfss GPIO,Ovl_in ;look for overload
goto set1
test1 btfsc state,0 ;check state
goto caltim ;reset delay
goto test ;look again
;here if true overload
set1 bcf GPIO,DCCon ;turn off
btfsc state,0 ;0 if first time after reset
goto state1
bsf state,0 ;set to state 1
MOVf GPIO,W ;get port setting
xorlw B’00000100’ ;reverse relay
MOVwf GPIO
call dely25 ;delay 25 millisecs for relay
bsf GPIO,DCCon ;turn back on
goto test ;look for overload
state1 bsf GPIO,Ovl_out ;set alarm
call del500
bsf state,7 ;set timeout
bcf GPIO,Ovl_out ;alarm off
bsf GPIO,DCCon ;output on
goto test
caltim call timout ;reset timer
goto test
delay MOVlw 0xFF ;short delay
MOVwf time0
delay1 clrwdt
nop
nop
decfsz time0,F
goto delay1
retlw 0
dely25 clrwdt
MOVlw .30 ;25 millisecs
MOVwf time1
del25a MOVlw 0xFF
MOVwf time2
del25b decfsz time2,F
goto del25b
decfsz time1,F
goto del25a
retlw 0
del500 MOVlw 0xFF ;500 millisecs
MOVwf time1
del500a MOVlw 0xFF
MOVwf time2
del500b clrwdt
nop
nop
nop
nop
decfsz time2,F
goto del500b
decfsz time1,F
goto del500a
retlw 0
timout btfss state,7 ;continue countdown
goto countdn
MOVlw 0xFF ;set counters
MOVwf time1
timo2 MOVlw 0xFF
MOVwf time2
bcf state,7
countdn decfsz time2,F
retlw 0
decfsz time1,F
goto timo3
clrf state ;reset
retlw 0
timo3 MOVlw 0xFF
MOVwf time2
retlw 0
end
Previous article:PIC12c508 read and write 93LC46 PICC program
Next article:12F675 Temperature Display Program
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Single Voltage Reference vs. Dual Voltage Reference - III
- How to prevent excessive current when controlling multiple uln2003-driven stepper motors?
- DSP28335 Hardware Overview and Registers
- EEWORLD University Hall -- Experts teach you how to DIY a pocket PC
- Chapter 6 Application of SPI - OLED Display
- PCB circuit board questions
- STMicroelectronics SiC products and industrial application guide live data collection
- MSP430 capture device is simple and practical
- Colorful wallet programmed with CircuitPython
- The storage and downloading of time values sent by customers require sum verification or CRC verification