⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.asm

📁 8位计数器的程序
💻 ASM
字号:
;*****************************************************************************
;*****************************************************************************
;  FILENAME: main.asm
;   Version: 1.0, Updated on 27 July 2004
;
;  DESCRIPTION: Main file of the Example_counter8_28pin Project.
;
;-----------------------------------------------------------------------------
;  Copyright (c) Cypress MicroSystems 2000-2003. All Rights Reserved.
;*****************************************************************************
;*****************************************************************************

;***********************************************************************************************
;Project Objective
;     To demonstrate the operation of the Counter8 user module of the PSoC microcontroller.
;
;Overview
;    A 8 bit Counter module counts the number of switch closures on the pin P1[4] and counts 
;    down from 255 to 0.  The port pin als is simultaneously read and whenever an input pulse is
;    received to the counter, the existing counter value output to LCD.
;
;    Upon program execution all hardware settings from the device configuration are loaded 
;    into the device and main.asm is executed.  A counter8 module having its input clock 
;    connected from P1[4] will be ready to take input from a switch, which on closed 
;    connects to Vcc.  The value of the counter is decremented each time there is a transition 
;    from low to high in this pin.  (ie., whenever the switch is closed)  Parallel to this, 
;    the software continuously reads the state of the pin. Whenever the value of the pin 
;    goes high, the software reads the counter value and outputs on to the LED array.
;
;Project Settings
;
;     Global resources      - No change
;
;     Timer32
;        Clock             = Row_0_Input_0          Input is routed through GlobalInOdd_4
;        Enable            = High                   Enable the counter for continuous operation
;        CompareOut        = None                   Not used.
;        TerminalCountOut  = None                   Not used
;        Period            = 255                    Set to 255 and count down to 0
;        CompareValue      = 0                      Not used.
;        CompareType       = Less Than or Equal     Not used.
;        InterruptType     = Terminal Count         Not used
;        ClockSync         = SyncToSysClk           Synchronize to system clock
;        TC_PulseWidth     = Full width             Not used
;        InvertEnable      = Normal                 Not used.
;
;        
;Input 
;    P1[4]          -     Pull Down (External)
;    
;Output
;    P2[0]-P2[7]    -    Strong
;
;How to use this with the Proto board
;
;    CY3210-PSoCEVAL1
;            - Connect a 4.7k resistor from GND Pin of J5 to breadboard and from that point 
;              connect a wire to P1[4] and from the same point connect a wire to SW (switch) 
;              in J5.  ie., in simple terms, the P1[4] is pulled down to ground through a 
;              resistor and connected to a switch, which connects to Vcc when closed.
;            - Connect a wire between P2[0] and LED1
;            - Connect a wire between P2[1] and LED2
;            - Connect a wire between P2[2] and LED3
;            - Connect a wire between P2[3] and LED4
;
;    CY3210-MiniEval1
;            - In JP1, 1 and 2 to be connected for 28 Pin operation
;
;    Note: Additional 4 LEDs can be placed and connected in the breadboard to see the upper 
;          nibble output of Port2.
;***********************************************************************************************

;-----------------------------------------------------------------------------
;  Include Files
;-----------------------------------------------------------------------------
include "m8c.inc"                       ; part specific constants and macros
include "PSoCAPI.inc"                   ; PSoC API definitions for all User Modules

;-----------------------------------------------------------------------------
;  Global Symbols
;-----------------------------------------------------------------------------
export _main


;-----------------------------------------------------------------------------
;  FUNCTION NAME: Main
;
;  DESCRIPTION:
;      Main function. Performs system initialization and loops infinitely.
;      
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:        None
;        
;  RETURNS:          None.
;
;  SIDE EFFECTS:     None.
;
;  THEORY of OPERATION or PROCEDURE:
;    1) Start the user module
;    2) Check for any input for counter from p1[4]
;    3) If input pulse is received, output the counter value 
;
_main:
	
    call    Counter8_Start          ;start Counter
    ljmp    _outputCounterValue     ;first time display the counter value directly
    
_infiniteLoop:                      ;infinite loop
    mov     A,reg[PRT1DR]           ;Read Port1 to A
    and     A,0x10                  ;Check the status of P1[4]
    jz      _infiniteLoop           ;if not set, loop back

_outputCounterValue:                ;else
    call    Counter8_bReadCounter   ;read current count of counter8 to A
    mov     reg[PRT2DR],A           ;move A to Port2
    jmp     _infiniteLoop           ;loop back
	
	ret

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -