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

📄 main.asm

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

;---------------------------------------------------------------------------------------
;Example_counter16_28pin
;
;Project Objective
;    To demonstrate the operation of the Counter16 user module of the PSoC microcontroller.  
;
;Overview
;    A 16 bit Counter module continuously keeps running until an inverted "Enable" (ie., disable) 
;    signal from pin P1[4] pauses it.  
;
;    At every second (Terminal count of the counter) a variable is increment and the value of 
;    which is sent to the LED array at Port2. The count pauses for the duration the switch 
;    (connected to P1[4]) is closed.
;
;    Upon program execution all hardware settings from the device configuration are loaded 
;    into the device and main.c is executed. The 24 MHz system clock is divided by 16 (VC1) 
;    and 15 (VC2) and inturn it is divided by 100 (VC3) to produce a 1 KHz clock.  This is 
;    given as input clock to the Counter16 user module which has a period of 1000 (999+1), 
;    effectively producing a TerminalCount interrupt at a duration of 1 second.  In the ISR, 
;    a variable is increased and sent to an LED array connected to Port2. The variable is 
;    reset to zero once its value reaches 0x10(ie.,16).   The "Enable" input of the Counter16 
;    user module is connected to P1[4].  The input is "Inverted" in the user module, ie., when 
;    the switch is closed (connected to Vcc), the counter will be disabled and when the switch 
;    is released the counter continues its operation.   
;    
;Project Settings
;
;  Global resources                            
;        CPU_Clock       = SysClk/2           CPU clock set to 12 MHz
;        VC1             = 16                 divide 24MHz clock by 16
;        VC2             = 15                 divide VC1 by 15
;        VC3 Source      = VC2                select VC2 as source for VC3
;        VC3             = 100                divide VC2 by 100
;
;  User Module Parameters
;     Counter16
;        Clock           = VC3                Input is 1 KHz clock from VC3
;        Enable          = Row_0_Input_0      Input is routed through GlobalInOdd_4
;        CompareOut      = None               Not used.
;        TerminalCountOut= None               Not used
;        Period          = 999                Set to 999 and count down to 0
;        CompareValue    = 0                  Not used.
;        CompareType     = Less Than          Not used.
;        InterruptType   = Terminal Count     To generate interrupt after
;                                             the count reaches 0.
;        ClockSync       = SyncToSysClk       Synchronize to system clock
;        TC_PulseWidth   = Full width         Generate a full pulse width
;                                             at every terminal count.    
;        InvertEnable    = Invert             The Enable Input is Inverted, so
;                                             that a logic high disables the 
;                                             Counter, and a logic low keeps 
;                                             the counter running.
;    
;Input 
;    P1[4]          -    High Z, GlobalInOdd_4
;            
;Output
;    P2[0]-P2[3]    -    Strong
;
;How to use this with the Proto board
;
;    CY3210-PSoCEVAL1
;        -   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
;        -   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.
;
;    CY3210-MiniEval1
;        -   In JP1, 1 and 2 to be connected  (for 28 pin operation)
;
;
;Language selection:
;The program can be executed either in C or assembly. The procedure to 
;select language is as follows:
;In the header file, language.inc,
;     For C:   C_LANG:   equ 1 
;   For asm:   C_LANG:   equ 0
;
;-----------------------------------------------------------------------------------------


;---------------------------------------------------------------------------------------
;
;-----------------------------------------------------------------------------
;  Include Files
;-----------------------------------------------------------------------------
include "m8c.inc"                       ; part specific constants and macros
include "PSoCAPI.inc"                   ; PSoC API definitions for all User Modules
include "language.inc"                  ; Defines the code to be executed (Assembly or C) 

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

_main:
	
IF ( C_LANG )             
    lcall _mainc                     ; Execute codes written in C language in mainc.c
ELSE
    lcall _mainasm                   ; Execute codes written in Assembly language in mainasm.asm
ENDIF   
  
    ret

⌨️ 快捷键说明

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