Xinhai MCU flashes after pressing the start button

Publisher:SereneDreamsLatest update time:2013-04-11 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
;After pressing the start key (PT2.1), the program realizes LED flashing
;Purpose: Learning the input and output control of I/O port
;===============================================
;Complete code download address: http://www.51hei.com/f/xhpms.rar
; filename: 111.asm
; chip : csu1181b
; author :
; date : 2012-07-18
;============================================
include csu1181b.inc
;=================================================
; program start
;==============================================
  org 0000h ;
  goto a1 ;
  org 0005h ;
;***************************************************
; Determine whether the start key is pressed
;***********************************************
a1: CLRWDT ; Clear the watchdog
  MOVLW 00H ; Store the data 00H in W for setting the I/O port as an input port
  MOVWF PT2EN ; Store the data in W in PT2EN (25h) to set the I/O port as an input port
  MOVLW 0FFH ; Store the data 0FFH in W for setting the I/O port to pull-up mode
  MOVWF PT2PU ;Store the data in W into PT2PU (26h) and set the I/O port to pull-up mode
  BTFSC PT2,1 ;Judge whether PT2.1 is 0, if yes, skip the next instruction (Judge whether a key is pressed, if yes, execute the following program, if no, wait for the key to be pressed)
  GOTO A1 ;Unconditionally transfer to A1
;***************************************************
; Flashing program segment
;***************************************************
A2: CLRWDT ;Clear watchdog
  MOVLW 0FFH ;Store the data 0FFH into W and use it to set the I/O port as output
  MOVWF PT3EN ;Store the data in W into PT3EN (29h) and set the I/O port as output
  MOVLW 0 ;Store the data 00H into W and use it to set the I/O port to disable pull-up mode
  MOVWF PT3PU ;Store the data in W in PT3PU (2ah) and set the I/O port to disable pull-up mode
  MOVLW 01010101B ;Store the data 01010101B in W and use it as the output data of the I/O port
  MOVWF PT3 ;Output the data in W from PT3 (28h) to drive external devices (light up the LED)
  CALL M001 ;Delay
  MOVLW 10101010B ;Store the data 10101010B in W and use it as the output data of the I/O port
  MOVWF PT3 ;Output the data in W from PT3 (28h) to drive external devices (light up the LED)
  CALL M001 ;Delay
  goto a2 ;Return and repeatedly execute the program
;********************************************************
; Delay program segment
;****************************************************
 
M001: MOVLW 2 ;
  MOVWF 80H ;
M002: MOVLW 248 ;
  MOVWF 81H ;
M003: MOVLW 250 ;
  MOVWF 82H ;
M004: DECFSZ 82H,1 ; (The result after decrement is stored in 82h) If the decrement is 0, skip the next instruction
; DECFSZ 82H,0 ; (The result after decrement is stored in the working register) If the decrement is 0, skip the next instruction
  GOTO M004 ;
  DECFSZ 81H,1 ;
  GOTO M003 ;
  DECFSZ 80H,1 ;
  GOTO M002 ;
  RETURN ; The subroutine returns
     to end ; End
;================================================
Reference address:Xinhai MCU flashes after pressing the start button

Previous article:Assembly language and assembly process
Next article:Xinhai comes with a pen-segment LCD

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号