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

📄 main.asm

📁 Example_DUALADC_28pin CY3210-PSoCEVAL1 and CY3210-MiniEval1 Board Project
💻 ASM
字号:
;;***********************************************************************************************
;;***********************************************************************************************
;;  FILENAME: main.asm
;;
;;  Version: 1.0, Updated on 27th July 2004
;;
;;  DESCRIPTION: Main file of Example_DUALADC_28pin example project
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress MicroSystems 2000-2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
;
;***********************************************************************************************
;Example_DUALADC_28pin, a CY3210-PSoCEVAL1 and CY3210-MiniEval1 board project
;
;Project Objective:
;To demonstrate the operation of the 7-13 Bit variable DUALADC,Analog-to-Digital Converter
;user module of the PSoC microcontroller.A Programmable Gain Amplifier (PGA) with unity 
;gain and a LCD for display are also incorporated.
;
; Overview:
;The following changes were made to the default settings in the device editor.
; 
;    Select user modules
;        Select an DUALADC_1 module from the ADCs category
;        Select a PGA_1 module from the Amplifiers category
;        Select a PGA_2 module from the Amplifiers category
;        Select a LCD_1 module from the MiscDigital category   
;        in this example these UMs are renamed as DUALADC,PGAtoADC1,PGAtoADC2,LCD respectively. 
; 
;    Place user modules
;        1) select DUALADC,and then select the analog column 0(digital block
;           is fine with the default placement) and move ADC1 to block ASC10 to place it.
;           For placing ADC2 select analog column 1 and move ADC2 to block ASD11 to place it.
;           For digital block Placement details refer to the UM Datasheet.  
;        2) Select PGAtoADC1 and move it to block ACB00 to place it.
;        3) Select PGAtoADC2 and move it to block ACB01 to place it. 
;        4) Select LCD and select port_2 for LCD port.
; 
;
;Set the global resources and UM resources in the device editor window as shown in the project
;settings below.
;
;Upon program execution all hardware settings from the device configuration are loaded 
;into the device and main.asm is executed. The 24 MHz system clock is divided by 16 
;(VC1) to produce a 1.5MHz clock which is provided as the clock for DUALADC.For DUALADC,
;Once the DataClock is determined CalcTime is found by the relation 
;CalcTime>=DataClock*260/CPUClock,for this example DataClock is taken as 1.5MHz and 
;CPUClock as 12MHz to get a CalcTime of 32.5 Dataclocks.In the device editor this is set to 35.
;The input to ADC1 at P0[1] and input to ADC2 at P0[0]is sampled at approximately 46sps,
;Sample Rate=DataClock /((2^bits+2)+CalcTime).For the example DataClock is 1.5MHz and the 
;resolution is 13 Bits.
;
;By varying the dividers of VC1 and VC2 sample rates can be generated. The gain of the 
;amplifier feeding the input of the ADC is unity,and this is variable from 1/16 to 16. 
;
;Note:
;Apply the same clock from same source for both analog and digital blocks af ADC to make it work properly.
;More information is provided in the UM data sheet.
;
; Circuit Connections
;This example project runs on the CY3210-PSoCEVAL1 and CY3210-MiniEval1 boards or compatible 
;hardware.An analog input voltage is required on port_0_1, and port_0_0 and varying this voltage
;will cause value in the LCD to change.The voltage must not exceed Vcc by more than 0.5 volts as
;per the device specification.A PGA with unity gain is used just to route the analog input to ADC
;from port pin.
;
;The table below shows the translation of input analog voltage to digital for a signed output.
;
;DC voltage        Decimal value        Hexadecimal equivalent  
;     0                -4096                    F000      
;     1                -2458                    F666     
;     2                -820                     FCCC      
;     2.5              -1                       FFFF    
;     3                 819                     0333      
;     4                 2457                    0999
;     5                 4095                    0FFF
;
;(while verifying the negative values displayed using calculator,prefix the hexadecimal value 
;with F.for example,if the displayed value in the LCD is F666,in a 10 digit calculator enter 
;FFFFFFF666 and then convert to decimal to get -2458) 
;
;The table below shows the translation of input analog voltage to digital for a Unsigned output.
;
;DC voltage        Decimal value        Hexadecimal equivalent  
;     0                0                        0000      
;     1                1638                     0666     
;     2                3276                     0CCC      
;     2.5              4095                     0FFF    
;     3                4195                     1333      
;     4                6553                     1999
;     5                8191                     1FFF
;
; Project Settings:
;
;    Global resources
;        VC1            =    12                  ;divide 24MHz clock by 12
;        VC2            =    2                   ;divide VC1 by 2
;        RefMux         =    Vdd/2 +/- Vdd/2     ;This sets the ADC to use 2.5 volts for its
;                                                 zero reference (AGND) and measures signals 
;                                                 in a range that is 2.5 volts above and below AGND
;             
;        Analog Power   =    SC on/Ref High      ;This turns on the clock to the SC blocks  
;                                                 and sets the internal references for their best 
;                                                 performance. The power level can be reduced 
;                                                 once a project has been successfully developed.

;
;    DUALADC
;        Clock          =    VC1                 ;counter and analog block must have same clock
;        ADCResolution  =    13 Bits             ;can be selected from 7-13 bits 
;        ClockPhase     =    Norm                ;normal phase is the default
;        ADC Input1     =    P0[1]     
;        ADC Input2     =    P0[0]    
;        CalcTime       =    35                  ;obtained when integrate time selected as 20ms
;        DataFormat     =    signed              ;range between -4096 and 4095
;        ClockSync      =    Sync to SysClk 
;
;    AnalogColumn_Clock_0    =    VC1
;    AnalogColumn_Clock_1    =    VC1
;   
;    PGAtoADC1
;        AnalogBus      =    Disable             ;the output will not go to the analog output bus
;        Gain           =    1.000               ;set for unity gain
;        Input          =    AnalogColumn_Input_MUX_0    ;input is from column mux
;        Reference      =    AGND       
;
;    AnalogColumn_InputMUX_0    =    PORT_0_1  
;
;    PGAtoADC2
;        AnalogBus      = Disable                ;the output will not go to the analog output bus
;        Gain           = 1.000                  ;set for unity gain
;        Input          = AnalogColumn_Input_MUX_1;input is from column mux
;        Reference      = AGND       
;
;    AnalogColumn_InputMUX_1    =    PORT_0_0  
;
;    LCD
;        LCDPort        =    Port_2              ;Connect LCd to port2
;        BarGraph       =    Disabled 
;       
; Input:
;      
;    Pin        Select        Drive
;    P0[1]   AnalogInput   High Z analog
;    P0[0]   AnalogInput   High Z analog       
; Output:
;   
;    Port[2]-LCD port.For pins Default settings are made when LCD is connected to a port.
;   
;How to use this with the Proto board:
;
;For input Connect a Variable end of pot(R11) which is terminated at J5 in CY3210-PSoCEVAL1 board to 
;P0[1] using a jumper wire and for second ADC connect a variable source to P0[0]
;Connect LCD at J9 for output.
;
;For CY3210-MiniEval1 board variable end of a pot is readily connected to port_0_1.
;For second ADC connect a variable source to P0[0]
;Note:
;For CY3210-MiniEval1 board LCD connections are to be made on the Bread board.The following table 
;shows LCD connection for CY3210-MiniEval1 board:(dont forget to connect Vcc and ground to LCD and 
;for nominal contrast,ground contrast control pin of LCD through 1.5K resistor)
;
;port pins            LCD Pin 
; P2[0]  Connect to   LCD_D4
; P2[1]  Connect to   LCD_D5
; P2[2]  Connect to   LCD_D6
; P2[3]  Connect to   LCD_D7
; P2[4]  Connect to   LCD_E
; P2[5]  Connect to   LCD_RS 
; P2[6]  Connect to   LCD_RW

;-----------------------------------------------------------------------------
; Assembly main line
;-----------------------------------------------------------------------------

;-------------------------------------------------------------------
; Include Files
;-------------------------------------------------------------------
include "m8c.inc"                                ; part specific constants and macros
include "PSoCAPI.inc"                            ; PSoC API definitions for all User Modules
;-------------------------------------------------------------------
; String Constants
;-------------------------------------------------------------------
.LITERAL
    szDisplay1:ASCIZ "ADC-1"
    szDisplay2:ASCIZ "ADC-2"
.ENDLITERAL

export _main
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Main
;
;  DESCRIPTION:
;     Main function. Performs system initialization,gets the data for display and loops infinitely.
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:        None
;  RETURNS:          Nothing.
;  SIDE EFFECTS:     None.
;
;  THEORY of OPERATION or PROCEDURE:
;     1) Enable Global Interrupt
;     2) Start the user modules
;     3) Gets the data from ADC and displays the same on LCD
;     4) Loop Infinitely
_main:
 
    M8C_EnableGInt                               ; Enable interrupts
 
    call LCD_Start                               ; Initialize LCD  

    mov  A,PGAtoADC1_HIGHPOWER                   ; Start PGA with high power
    call PGAtoADC1_Start
 
    mov  A,PGAtoADC2_HIGHPOWER                   ; Start PGA with high power
    call PGAtoADC2_Start


    mov  A, DUALADC_HIGHPOWER                    ; Set Power and Enable A/D
    call DUALADC_Start
 
    mov  A, 00h                                  ; Start A/D in continuous sampling mode
    call DUALADC_GetSamples
 
; A/D conversion loop
_Loop1:
_Wait:                                           ; Poll until data is complete
    call DUALADC_fIsDataAvailable
    jz   _Wait
 
    call DUALADC_iGetData1ClearFlag              ; Get ADC1 Data (X=MSB A=LSB) and Reset flag
    push A                                       ; preserve ADC1 data in the stack
    push X                                       ; to use reg A & X for LCD positioning
 
    mov  A,00h
    mov  X,00h
    call LCD_Position                            ; position the cursor
 
    mov  A,>szDisplay1                           ; Load MSB part of pointer to ROM-based null  
                                                 ; terminated string.  
    mov  X,<szDisplay1                           ; Load LSB part of pointer to ROM-based null  
                                                 ; terminated string.  
    call LCD_PrCString                           ; Call function to display string at current  
                                                 ; LCD cursor position.  

    mov  A,01h                                   ; Load Row  
    mov  X,00h                                   ; Load Column  
    call LCD_Position                            ; position the cursor   
 
    pop  X                                       ; retrive ADC1 data
    pop  A
 
    call LCD_PrHexInt                            ; Print an Int in Hex to current LCD position
 
 
    call DUALADC_iGetData2ClearFlag              ; Get ADC2 Data (X=MSB A=LSB) and Reset flag
 
    push A                                       ; preserve ADC2 data in the stack
    push X                                       ; to use reg A & X for LCD positioning
 
    mov  A,00h
    mov  X,0Bh
    call LCD_Position                            ; position the cursor
 
    mov  A,>szDisplay2                           ; Load MSB part of pointer to ROM-based null  
                                                 ; terminated string.  
    mov  X,<szDisplay2                           ; Load LSB part of pointer to ROM-based null  
                                                 ; terminated string.  
    call LCD_PrCString                           ; Call function to display string at current  
                                                 ; LCD cursor position.  

 
    mov  A,01h                                   ; Load Row  
    mov  X,0Bh                                   ; Load Column  
    call LCD_Position                            ; Print an Int in Hex to current LCD position  
 
    pop  X                                       ; retrive ADC2 data
    pop  A
 
    call LCD_PrHexInt                            ; Print an Int in Hex to current LCD position

    jmp _Loop1

    ret

⌨️ 快捷键说明

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