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

📄 dac.asm

📁 tm320lf2407测试程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
		TBLR	NEXTVALUE		;Read the next value from the table and store into NEXTVALUE

		LACC	NEXTVALUE		;Load the ACC with NEXTVALUE
		SUB	VALUE			;Subtract the previous value
		SACL	DIFFERENCE		;Store the difference between the values into DIFFERENCE
		
		LT	DIFFERENCE		;Load the TREG with DIFFERENCE
		MPY	REMAINDER		;Multiply the DIFFERENCE with REMAINDER
		PAC				;Move the product to the ACC
		SACH	REMAINDER,1		;Store the upper byte to REMAINER and shift left by 1, Q15

		LACC	REMAINDER		;Load ACC with new REMAINDER
		ADD	VALUE			;Add VALUE to get the new interpolated value
		SACL	VALUE			;Store the interpolated value into VALUE

		LT	VALUE			;Load the TREG with the new interpolated VALUE
		MPY	MAG1			;Multiply VALUE by a magnitude 
		PAC				;Move the product to ACC
		SACH	DAC1VAL,1		;Store the new value to DAC0VAL to output, shift to get Q15


;The following section performs the necessary calculations for the third sine wave

		LACC	MODREG2		;ACC loaded with the counting register
		ADD	FREQSTEP2		;Counting Register increased by specific step
		SACL	MODREG2		;Store the updated the counter value
		LACC	MODREG2,8		;Reload the new counter value but shift left by 8 bits
		SACH	TABLE			;Store the high bit into the TABLE as pointer to lookup table
		SFR				;Shift the value to the right convert to Q15
		AND	#07FFFh		;Make sure the Q15 value is positive
		SACL 	REMAINDER		;Store the fractional value of the counting register

		LACC	TABLE			;Load the accumulator with the proper index value
		ADD	TOPTABLE		;Displace the ACC with the starting address
		TBLR	VALUE			;Read the value from the table and store into VALUE
		ADD	#1			;Increment the ACC to the next address
		TBLR	NEXTVALUE		;Read the next value from the table and store into NEXTVALUE

		LACC	NEXTVALUE		;Load the ACC with NEXTVALUE
		SUB	VALUE			;Subtract the previous value
		SACL	DIFFERENCE		;Store the difference between the values into DIFFERENCE	
		
		LT	DIFFERENCE		;Load the TREG with DIFFERENCE
		MPY	REMAINDER		;Multiply the DIFFERENCE with REMAINDER
		PAC				;Move the product to the ACC
		SACH	REMAINDER,1		;Store the upper byte to REMAINER and shift left by 1, Q15

		LACC	REMAINDER		;Load ACC with new REMAINDER
		ADD	VALUE			;Add VALUE to get the new interpolated value
		SACL	VALUE			;Store the interpolated value into VALUE

		LT	VALUE			;Load the TREG with the new interpolated VALUE
		MPY	MAG2			;Multiply VALUE by a magnitude 
		PAC				;Move the product to ACC
		SACH	DAC2VAL,1		;Store the new value to DAC0VAL to output, shift to get Q15

;The following section performs the necessary calculations for the fourth sine wave

		LACC	MODREG3		;ACC loaded with the counting register
		ADD	FREQSTEP3		;Counting Register increased by specific step
		SACL	MODREG3		;Store the updated the counter value
		LACC	MODREG3,8		;Reload the new counter value but shift left by 8 bits
		SACH	TABLE			;Store the high bit into the TABLE as pointer to lookup table
		SFR				;Shift the value to the right convert to Q15
		AND	#07FFFh		;Make sure the Q15 value is positive
		SACL 	REMAINDER		;Store the fractional value of the counting register

		LACC	TABLE			;Load the accumulator with the proper index value
		ADD	TOPTABLE		;Displace the ACC with the starting address
		TBLR	VALUE			;Read the value from the table and store into VALUE
		ADD	#1			;Increment the ACC to the next address
		TBLR	NEXTVALUE		;Read the next value from the table and store into NEXTVALUE

		LACC	NEXTVALUE		;Load the ACC with NEXTVALUE
		SUB	VALUE			;Subtract the previous value
		SACL	DIFFERENCE		;Store the difference between the values into DIFFERENCE	
		
		LT	DIFFERENCE		;Load the TREG with DIFFERENCE
		MPY	REMAINDER		;Multiply the DIFFERENCE with REMAINDER
		PAC				;Move the product to the ACC
		SACH	REMAINDER,1		;Store the upper byte to REMAINER and shift left by 1, Q15

		LACC	REMAINDER		;Load ACC with new REMAINDER
		ADD	VALUE			;Add VALUE to get the new interpolated value
		SACL	VALUE			;Store the interpolated value into VALUE

		LT	VALUE			;Load the TREG with the new interpolated VALUE
		MPY	MAG3			;Multiply VALUE by a magnitude 
		PAC				;Move the product to ACC
		SACH	DAC3VAL,1		;Store the new value to DAC0VAL to output, shift to get Q15

;Sets the values to 12 bits

		LDP	#0			;This section outputs the SINE wave to the DAC
		LACC	DAC0VAL		;ACC = DAC0VAL - entry from the lookup table
		ADD	#8000h		;Displace the value half the maximum
		SFR				;Shift over 4 places since the DAC is 12bits
		SFR
		SFR
		SFR		
		SACL	DAC0VAL		;Store the new 12 bit value into DAC0VAL

		LACC	DAC1VAL		;ACC = DAC0VAL - entry from the lookup table
		ADD	#8000h		;Displace the value half the maximum
		SFR				;Shift over 4 places since the DAC is 12bits
		SFR
		SFR
		SFR		
		SACL	DAC1VAL		;Store the new 12 bit value into DAC1VAL

		LACC	DAC2VAL		;ACC = DAC0VAL - entry from the lookup table
		ADD	#8000h		;Displace the value half the maximum
		SFR				;Shift over 4 places since the DAC is 12bits
		SFR
		SFR
		SFR		
		SACL	DAC2VAL		;Store the new 12 bit value into DAC2VAL

		LACC	DAC3VAL		;ACC = DAC0VAL - entry from the lookup table
		ADD	#8000h		;Displace the value half the maximum
		SFR				;Shift over 4 places since the DAC is 12bits
		SFR
		SFR
		SFR		
		SACL	DAC3VAL		;Store the new 12 bit value into DAC3VAL

		OUT 	DAC0VAL,DAC0	;Stores the 12 bit value into DAC0 register
		OUT	DAC1VAL,DAC1	;Stores the 12 bit value into DAC1 register
		OUT 	DAC2VAL,DAC2	;Stores the 12 bit value into DAC2 register
		OUT	DAC3VAL,DAC3	;Stores the 12 bit value into DAC3 register
		OUT 	DAC0VAL,DAC_UPDATE ;Causes the DAC to output the value

		B	SINE

;-------------------------------------------------------
; Sine look-up table
; No. Entries	: 256
; Angle Range	: 360 deg
; Number format : Q15 with range -1 < N < +1
;-------------------------------------------------------
		      ;SINVAL	     ;	      Index	Angle	Sin(Angle)
STABLE	.word	  	0	     	 ;		0	  	0	0.0000
            .word        804         ;          1        1.41     0.0245
            .word       1608         ;          2        2.81     0.0491
            .word       2410         ;          3        4.22     0.0736
            .word       3212         ;          4        5.63     0.0980
            .word       4011         ;          5        7.03     0.1224
            .word       4808         ;          6        8.44     0.1467
            .word       5602         ;          7        9.84     0.1710
            .word       6393         ;          8       11.25     0.1951
            .word       7179         ;          9       12.66     0.2191
            .word       7962         ;         10       14.06     0.2430
            .word       8739         ;         11       15.47     0.2667
            .word       9512         ;         12       16.88     0.2903
            .word       10278        ;         13       18.28     0.3137
            .word       11039        ;         14       19.69     0.3369
            .word       11793        ;         15       21.09     0.3599
            .word       12539        ;         16       22.50     0.3827
            .word       13279        ;         17       23.91     0.4052
            .word       14010        ;         18       25.31     0.4276
            .word       14732        ;         19       26.72     0.4496
            .word       15446        ;         20       28.13     0.4714
            .word       16151        ;         21       29.53     0.4929
            .word       16846        ;         22       30.94     0.5141
            .word       17530        ;         23       32.34     0.5350
            .word       18204        ;         24       33.75     0.5556
            .word       18868        ;         25       35.16     0.5758
            .word       19519        ;         26       36.56     0.5957
            .word       20159        ;         27       37.97     0.6152
            .word       20787        ;         28       39.38     0.6344
            .word       21403        ;         29       40.78     0.6532
            .word       22005        ;         30       42.19     0.6716
            .word       22594        ;         31       43.59     0.6895
            .word       23170        ;         32       45.00     0.7071
            .word       23731        ;         33       46.41     0.7242
            .word       24279        ;         34       47.81     0.7410
            .word       24811        ;         35       49.22     0.7572
            .word       25329        ;         36       50.63     0.7730
            .word       25832        ;         37       52.03     0.7883
            .word       26319        ;         38       53.44     0.8032
            .word       26790        ;         39       54.84     0.8176
            .word       27245        ;         40       56.25     0.8315
            .word       27683        ;         41       57.66     0.8449
            .word       28105        ;         42       59.06     0.8577
            .word       28510        ;         43       60.47     0.8701
            .word       28898        ;         44       61.88     0.8819
            .word       29268        ;         45       63.28     0.8932
            .word       29621        ;         46       64.69     0.9040
            .word       29956        ;         47       66.09     0.9142
            .word       30273        ;         48       67.50     0.9239
            .word       30571        ;         49       68.91     0.9330
            .word       30852        ;         50       70.31     0.9415
            .word       31113        ;         51       71.72     0.9495
            .word       31356        ;         52       73.13     0.9569
            .word       31580        ;         53       74.53     0.9638
            .word       31785        ;         54       75.94     0.9700
            .word       31971        ;         55       77.34     0.9757
            .word       32137        ;         56       78.75     0.9808
            .word       32285        ;         57       80.16     0.9853
            .word       32412        ;         58       81.56     0.9892
            .word       32521        ;         59       82.97     0.9925
            .word       32609        ;         60       84.38     0.9952
            .word       32678        ;         61       85.78     0.9973
            .word       32728        ;         62       87.19     0.9988
            .word       32757        ;         63       88.59     0.9997
            .word       32767        ;         64       90.00     1.0000

⌨️ 快捷键说明

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