"单片机入门程序实例:闪烁灯设计与学习"
需积分: 4 180 浏览量
更新于2024-03-16
收藏 592KB DOC 举报
# Delay Program for 0.2 second delay
MOV R6, #200 ; Initialize register R6 with 200
L1: SUB R6, #1 ; Decrement R6
JZ L2 ; Jump to L2 if R6 equals zero
SJMP L1 ; Jump to L1
L2: RET ; Return from subroutine
# Main Program
MAIN: MOV P1.0, #1 ; Turn on LED
CALL DELAY ; Call delay subroutine
MOV P1.0, #0 ; Turn off LED
CALL DELAY ; Call delay subroutine
SJMP MAIN ; Repeat forever
DELAY: ; Delay subroutine
MOV R6, #200 ; Initialize register R6 with 200
L1: SUB R6, #1 ; Decrement R6
JZ L2 ; Jump to L2 if R6 equals zero
SJMP L1 ; Jump to L1
L2: RET ; Return from subroutine
This program achieves the desired functionality of blinking an LED connected to port P1.0 with a time interval of 0.2 seconds. It utilizes a delay subroutine to create the desired delay, which is achieved by decrementing a register and looping until it reaches zero. The main program turns on the LED, calls the delay subroutine, turns off the LED, calls the delay subroutine again, and repeats this process indefinitely. This example is suitable for self-study as it provides a hands-on approach to learning about programming microcontrollers.
2020-08-27 上传
2012-12-22 上传
2010-05-27 上传
2011-02-28 上传
2013-09-02 上传
2009-06-22 上传
编码开发
- 粉丝: 1
- 资源: 11
最新资源
- Angular实现MarcHayek简历展示应用教程
- Crossbow Spot最新更新 - 获取Chrome扩展新闻
- 量子管道网络优化与Python实现
- Debian系统中APT缓存维护工具的使用方法与实践
- Python模块AccessControl的Windows64位安装文件介绍
- 掌握最新*** Fisher资讯,使用Google Chrome扩展
- Ember应用程序开发流程与环境配置指南
- EZPCOpenSDK_v5.1.2_build***版本更新详情
- Postcode-Finder:利用JavaScript和Google Geocode API实现
- AWS商业交易监控器:航线行为分析与营销策略制定
- AccessControl-4.0b6压缩包详细使用教程
- Python编程实践与技巧汇总
- 使用Sikuli和Python打造颜色求解器项目
- .Net基础视频教程:掌握GDI绘图技术
- 深入理解数据结构与JavaScript实践项目
- 双子座在线裁判系统:提高编程竞赛效率