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

📄 main.s

📁 cypress 的ad采集例程,适用于cy8系列.
💻 S
字号:
	.module main.c
	.area text(rom, con, rel)
	.dbfile ./main.c
	.dbfunc e main _main fV
_main::
	.dbline -1
	.dbline 179
; //***********************************************************************************************
; //***********************************************************************************************
; //  FILENAME: main.C
; //   Version: 1.0, Updated on 2004/07/27 at 15:37:10
; //  DESCRIPTION: Main file of Example_ADCINC12_28pin example project
; //-----------------------------------------------------------------------------
; //  Copyright (c) Cypress MicroSystems 2000-2003. All Rights Reserved.
; //*****************************************************************************
; //*****************************************************************************
; 
; /***********************************************************************************************
; Example_ADCINC12_28pin, a CY3210-PSoCEVAL1 and CY3210-MiniEval1 board project
; 
;  Project Objective:
; To demonstrate the operation of the 12-Bit Incremental Analog-to-Digital Converter user 
; module of the PSoC microcontroller.Also this example demonstrates the clock generation 
; using a counter and routing.A Programmable Gain Amplifier (PGA) with unity gain, 
; a 8-bit counter and a LCD user module are also incorporated.
; 
;  Overview:
;  The following changes were made to the default settings in the device editor.
;  
; 	Select user modules
; 	   Select an ADCINC12_1 module from the ADCs category
; 	   Select a PGA_1 module from the Amplifiers category
; 	   Select a Counter8_1 module from the Counters category
; 	   Select a LCD_1 from Misc Digital category
; 	   in this example these UMs are renamed as ADCINC12,PGA,Counter8,LCD respectively. 
; 	Place user modules
; 		1) select ADCINC12, and then select the analog block (digital blocks
;                are fine with the default placement) and move it to block ASC10 to place it.
;         2) select PGA and move it to block ACB00 to place it
;         3) select Counter8 and move it to block DCB03 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.c is executed.
; 
; For this example the 8-bit counter is used to provide a clock for A/D converter. 
; this approach provides an example of clock generation and routing.  The clock
; output from the counter is used as a source for the Analog Column clocks (AnalogClock_0_Select).
; This clock is then selected as the clock input for AnalogColumn_Clock_0, which supplies
; it as input to all blocks in that column.This counter clock is also selected as the input to 
; the timer and counter components of the ADC(DBB01 and DCB02 respectively) using the row 
; broadcast (BC0). The 8-bit counter, DCB03 is set to run at 1.5MHz by the setting 
; the counter value to 15.This amounts to dividing the 24MHz(Use SysClk Direct) input clock by 16.
; Each time the counter reaches 0 it is automatically reloaded. A compare value
; for the counter is set to 7 which sets up a duty cycle at the output of approximately 50%.
; 
; 
; The 12-bit ADC is a single user module that consists of 3 PSoC blocks.Each PSoC 
; block can be individually placed.Once they are placed each block must be clocked 
; with the same clock source.The clock signal to each of the digital sections of the 
; ADC can be configured in the user module menu or device editor.  
; Analog values are sampled at pin P0[1] at:
; Sample Rate = 1.5MHz(counter output)/(65*256)= 90 samples/sec.  
; Further information is supplied in the data sheet included for the user module.
; 
; 
; Clock Routing.  Using the device editor click on the AnalogClock_0_Select mux icon.  Select 
; the block ID of the block containing the 8-bit counter. In this example it is DCB03. Click 
; on the clock mux icon associated with the analog column where the ADC analog block is 
; placed.  In the example this is the column 0. Select the appropriate source.  For the example 
; this is AnalogClock_0_Select.This demonstrates using a digital PSoC block to supply a specific
; clock to an analog section of the chip.The ADC timer and counter blocks must have a clock
; source specified that is identical to the one just selected on ACLK0 and the analog column.
; 
; 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 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				-2048				F800
; 	1				-1229				FB33
; 	2				-410				FE66
; 	2.5(AGND)		-1					FFFF
; 	3				409					199
; 	4				1228				4CC
; 	5				2047				07FF
; 
; (while verifying the negative values displayed using calculator,prefix the hexadecimal value 
; with F.for example,if the displayed value in the LCD is ECCC,in a 10 digit calculator enter 
; FFFFFFECCC and then convert to decimal to get -4916) 
; 
; Project Settings:
; 		Global resources
; 			VC1				=	1					// Divide sysclock by 1
; 			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.
; 	     
; 		ADCINC12
; 	       CNT Clock		=	Row_0_Broadcast		//Clock from conuter 
; 	       TMR Clock		=   Row_0_Broadcast
; 	       Input			=   ACB00				//Route input through PGA
; 	       ClockPhase		=	Normal
; 	       ClockSync		=	Sys to Sync Clock
; 
; 		AnalogColumn_Clock_0=	AnalogClock_0_select
; 		AnalogClock_0_select=	DCB03				//Select the output of counter
; 		
;  		Counter8 
;  			Clock			=	Disable				//since Use SysClk Direct is used
; 			Enable			=   High				//Enable continous count
; 			Compare Out		=	None
; 			Terminal Count	=	None	
; 			Period			=   15
;         	Compare Value	=	 7					//Set to half of the period to get 50% duty cycle	
;         	Compare Type	=   Less Than or Equal to
;     		Interrupt Type	=	Compare True
;     		Clock Sync		=	Use SysClk Direct	//Provides low-skew access to system clock
;     		InvertEnable	=	Normal    	
; 
; 		PGA
; 	      	Gain			=	1.000						//set for unity gain
; 	      	Input			=	AnalogColumn_Input_MUX_0    //input is from column mux
; 	      	Reference		=	AGND							
; 		  	AnalogBus		=	Disable						//the output will not go to the analog output bus		
; 
; 		AnalogColumn_InputMUX_0 	=	PORT_0_1
; 	  
; 
; 	   LCD
; 	   	  LCDPort			=	Port_2
; 	   	  BarGraph			=	Disable
; 		  	  
; Input:
; 				  
; 	    	Pin					Select				Drive
; 	     	P0[1]			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 
; port_0_1 through a jumper wire.Connect LCD at J9 for output.
; 
; For CY3210-MiniEval1 board variable end of a pot is readily connected to port_0_1.
; 
; 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
; */
; 
; //----------------------------------------------------------------------------
; // 'C' Main line
; //-----------------------------------------------------------------------------
; #include "m8c.h"
; #include "psocapi.h"
; 
; 
; 
; void main()
; {
	.dbline 182
; 		
; 	
;     Counter8_Start();	
	push X
	xcall _Counter8_Start
	.dbline 183
;     PGA_Start(PGA_HIGHPOWER);							// Start PGA with High power
	mov A,3
	xcall _PGA_Start
	.dbline 185
; 	
; 	LCD_Start();                 						// Initialize LCD  
	xcall _LCD_Start
	.dbline 188
; 	
; 	
; 	ADCINC12_Start(ADCINC12_HIGHPOWER);					//ADC power level set to highest power.
	mov A,3
	xcall _ADCINC12_Start
	.dbline 190
; 	
; 	ADCINC12_GetSamples(0);								//The zero argument sets the ADC to sample continuously.:
	mov A,0
	xcall _ADCINC12_GetSamples
	pop X
	.dbline 192
; 	
; 	M8C_EnableGInt;										//Enable global interrupts
		or  F, 01h

	.dbline 196
; 	
; 	
; 		
; 	for(;;)
	.dbline 197
; 	{
L6:
	.dbline 199
L7:
	.dbline 199
	push X
	xcall _ADCINC12_fIsDataAvailable
	pop X
	cmp A,0
	jz L6
	.dbline 201
	push X
	mov X,1
	mov A,0
	xcall _LCD_Position
	.dbline 202
	xcall _ADCINC12_iGetData
	mov [__r1],A
	push X
	mov A,[__r1]
	pop X
	xcall _LCD_PrHexInt
	.dbline 205
	xcall _ADCINC12_ClearFlag
	pop X
	.dbline 209
	.dbline 196
	.dbline 196
	xjmp L7
X0:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend

⌨️ 快捷键说明

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