;P IC 12C508 single-chip microcomputer lighting control system source program
;The above program uses PIC12C508 single-chip microcomputer, internal 4M Hz clock, 50HZ pulse signal input at pin 4, and output at pins 7, 6, and 3 (GP0, GP1, and GP4 ports). The gradual change part makes the light gradually brighter (or off). I don't know if there are any errors in the single-chip microcomputer lighting control system program. If there are any errors, please give me more comments. Thank you
;The program is as follows:
GPI0 EQU 6
COUNT1 EQU 11
COUNT2 EQU 12
COUNT3 EQU 13
COUNT4 EQU 14
COUNT5 EQU 15
POINTER EQU 16
POINTER1 EQU 17
ORG 00H
MOV LW 07H ;Set clock parameter 1:256 frequency division
OPTION
MOV LW 2CH ;Output port setting 0,1,4 output, 3 input 50HZ
TRIS 6
;-------------------------------
START:
;Scan 3 ports Scan 0 low potential
MOV F GPI0,W
MOV WF COUNT1
BTFSC COUNT1,3
GOTO START
NEXT: ;Scan 3 ports Scan 1 high potential
MOV F GPI0,W
MOV WF COUNT1
BTFSS COUNT1,3
GOTO NEXT
INCF COUNT2
MOV LW 100
DECFSZ COUNT2,1
GOTO START ;------External 50HZ signal, scan 100 times, delay 2 seconds
;------------------- Single chip light control system----------------------------------------
JB:
CLRF TMR0
MOV LW 250
MOV WF COUNT4
MOV WF COUNT5
INCF POINTER,F
MOV F POINTER,0
MOV WF POINTER1
MOV LW TABLE
ADDWF POINTER,0
CALL AA
MOV WF 6 ;Return, output-----on
CHANGE:
MOV F TMR0,0
MOV WF COUNT3
SUBWF COUNT4,1
BTFSS STATUS,Z ;TMR0=250? N empty loop TMR0 times Y jump out and restart the gradient
GOTO NOPDELAY1
GOTO OUT
NOPDELAY1:
NOP
DECFSZ COUNT3,1
GOTO NOPDELAY1
DECF POINTER1,F ; <--- Single-chip light control system-------|
MOV LW TABLE ; |
ADDWF POINTER1,0 ; |
CALL AA ; |
MOV WF 6 ; Return to the last displayed data and output to the GP port--- off <--|
NOPDELAY2:
NOP
DECFSZ COUNT4,1
GOTO NOPDELAY2
GOTO CHANGE
;----- Gradual----- Change------------ Single-chip light control system-----------------------------------
OUT:
MOV LW 9 ; Take the table 9 times
SUBWF POINTER,0
BTFSS STATUS,Z
GOTO JB
GOTO START
AA: MOV WF 2
TABLE:RETLW 2CH
RETLW 3CH
RETLW 2DH
RETLW 2EH
RETLW 2FH
RETLW 3DH
RETLW 3EH
RETLW 2CH
RETLW 3FH
ORG 1FFH
MOV WF OS CC AL
END
Previous article:PIC microcontroller car anti-theft alarm sound (anti-theft device)
Next article:Telephone Amplifier Controlled by PIC16C54 Microcontroller
Recommended ReadingLatest update time:2024-11-16 19:53
- Popular Resources
- Popular amplifiers
- Example interpretation of 51 single chip microcomputer complete learning and application
- Example interpretation of 51 single chip microcomputer complete learning and application
- CAN notes(Controller Area Network)
- Basic Research on Single Chip Microcomputer and Electromagnetic Compatibility (Full Version)
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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Learn how to use an oscilloscope as a recorder
- [Xingkong Board Python Programming Learning Main Control Board] 2: Burning System Image
- NB module problem
- [EETalk] Outlook for the development of consumer electronics interfaces - Will USB dominate the world?
- Compilation issues
- The Painful Experience of DSP Connecting to Emulator
- BleFi - BLE Wifi IOT Gateway Reference Design
- About the selection of energy storage inductor in DCDC circuit?
- [Analog Electronics Course Selection Test] + Assessment
- Matrix keyboard problem