;********************************************************
;* This program is a LED light cycle flashing program, use the INT key to switch*
;* Flashing mode*www.dangdangdz.com
;********************************************************
include
;*----
MODESEL equ 20h
MODESELB equ 21h
Count equ 22h
Count1 equ 23h
Count2 equ 24h
PORTDB equ 25h
;*-----
org 0
goto start
org 4
goto ISR
org 10
start
clrf PORTD ; clear port D
movlw 00h
movwf MODESEL ; initialize mode select register
movwf MODESELB
movlw b\'10010000\'
movwf INTCON ; initialize interrupt control
bsf STATUS,RP0
clrf TRISD ; set port D to output
movlw b\'10111111\'
OPTION ; select INT falling edge to be valid
bcf STATUS,RP0
call FMsel
movwf PORTDB
movwf PORTD
main btfsc PORTB,0 ;
goto $+6 ;
call Delay ; key debounce
btfsc PORTB,0
goto $+3 ; /
call FMsel ;/
movwf PORTDB
movf MODESELB,W ;
movwf MODESEL ;
call LongDelay
bcf STATUS,C
rlf PORTDB,1
btfsc STATUS,C
bsf PORTDB,0
movf PORTDB,W
movwf PORTD
goto main
;*----------
Delay ; call instruction takes 2 instruction cycles
clrf Count ; clear Count takes 1 instruction cycle
Dloop
decfsz Count,f ; these two lines of instructions will delay
goto Dloop ; (256 * 3) -1 instruction cycle
return ; return takes 2 instruction cycles
;*----------------
LongDelay
clrf Count
clrf Count1
movlw 0x01
movwf Count2
LDloop
decfsz Count,f
goto LDloop
decfsz Count1,f
goto LDloop
decfsz Count2,f
goto LDloop
return
[page]
;*---------------
FMsel
movf MODESEL,w
movwf MODESELB
movf MODESEL,w
addwf PCL
retlw b\'11111000\'
retlw b\'11110000\'
retlw b\'11100000\ '
retlw b\'11000000\'
retlw b\'10000000\'
movlw 00h
movwf MODESELB
bsf INTCON,GIE
retlw b\'11111000\'
return
;*-------------
ISR
btfss INTCON,INTF
goto $+3
bcf INTCON,INTF
incf MODESEL
retfie
end
Programming method of single chip microcomputer controlling LED light flashing
1: Program start (START)
2: A=00000000B
3: PORT 0
4: Delay (DELAY)
5: A=11111111B
6: PORT 0
7: Delay
8: Back to the beginning
Delay subroutine programming method:
1: R6=0
2:DEL1
3: R7=0
4: $
5: R7-1
6: R7=0 is not equal to 0, return 2
7: R6-1
8: R6=0 is not equal to 0, return 4
Return to the main program
Previous article:Single chip microcomputer dynamic digital display technology
Next article:C language source code of frequency meter based on single chip microcomputer
Recommended ReadingLatest update time:2024-11-16 22:52
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- Display emulation issues
- Temperature Sensing Guide | Understanding the Design Challenges
- Last day! TI live broadcast with prizes | High-performance, low-power embedded edge AI camera applications
- [GD32E503 Evaluation] mig29_Step2 Measure the physical characteristics of DAC and ADC
- RISC-V Manual (Chinese, a guide to the open source instruction set)
- Causes of voltage drop and measures to achieve the lowest possible voltage drop
- WS2410 high performance and low power consumption 2.4G SOC chip
- Does anyone know what circuit this is and what function it has?
- Two new TI boards
- How to observe the PWM output of DSPF2812 through graph in CCS?