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

📄 at90s2313controlplllmx1601_asm.txt

📁 lmx1601频率合成器用AT90S2313芯片控制源程序
💻 TXT
📖 第 1 页 / 共 2 页
字号:
		mov		temp,channel
		cpi		temp,55
		breq	DontDecrement			;Skip if channel value is already 55 
										;(corresponds to 88 MHz).
		dec		channel					
		rcall	SendAUX_N
DontDecrement:
		rcall	on						;Assure that the oscillator is on while being adjusted.
		rjmp	Buttonack				

delay:									;Delay for button debounce and noise 
										;filtering.
		ldi		delayone,200 			;Count of 200 @ 4 MHz should cuase about 
										;39 ms for electrical noise..
outerloop:								
		ldi		delaytwo,0	
innerloop:
		dec		delaytwo
		brne	innerloop

		dec		delayone
		brne	outerloop
		ret

writeEE:								;Write data in channel to location 
										;EEPROMpntr points to.
		cli								;Disable interrupts.
		sbic	EECR,EEWE				;If EEWE not clear,
		rjmp	writeEE					;Wait.
		out		EEAR,EEPROMpntr			;Output address
		out		EEDR,channel			;Output data
		sbi 	EECR,EEMWE 				;Set master write enable.
		sbi		EECR,EEWE				;Set EEPROM Write strobe,
		ldi		temp,100				;Set number of beep cycles,
		rcall	Buzzloop				;Beep the beeper.
		sei								;Enable interrupts.
		ret


ReadEE:									;Read from EERPOM. Enter with address in 
										;EEPROMpntr. Returns with data in 
										;channel.
		sbic	EECR,EEWE				;If EEWE not clear
		rjmp	ReadEE					;Wait more
		out		EEAR,EEPROMpntr			;Output address
		sbi		EECR,EERE				;Set EEPROM Read strobe
		in		channel,EEDR			;Get data
		ret




Buttonack:								;Emit a keyclick, set EEPROM write flag 
										;& timer, output PORTD, then wait for 
										;button up.
		ldi		ZL,		waitL			;Set waiting time until programming the 
										;EEPROM			
		ldi		ZH,		waitH			
		ori		flagreg,0b10000000		;Set flag to write to EEPROM after time 
										;is up.
		ldi		temp,50					;Atart keyclick code.
Buzzloop:								;Emit a tone out of D6, the number of 
		cbi		PORTD,5					;Turn the status LED off.										;cycles = contents of temp.	
		sbi		PORTD,6
		rcall	delay2
		cbi		PORTD,6
		rcall	delay2
		dec		temp
		brne	Buzzloop				;end keyclick code.

		out		PORTD,	dreg			;Output PORTD data to the output port.
		sbrs	dreg,	7				;Set DDRD,0 according to dreg,7
		rjmp	D0Low2				
		sbi		DDRD	,0			
		rjmp	D0Done2
D0Low2:
		cbi		DDRD,	0	
D0Done2:
		sbi		PORTD,5					;Turn the status LED on (if it beeped, it must be on).

Wait4ButtonsUp:
		in		temp,	PINB			;Wait for all buttons to be up before 
										;proceeding.
		andi	temp,0b00001100			;Buttons are only connected to bits 2 
 										;and 3.
		cpi		temp,0
		breq	Bothbuttons				;If both buttons are down, go interpret 
										;this special case.
		rcall	delay					;Debounce
		in		temp2,	PINB
		andi	temp2,0b00001100		;Buttons are only connected to bits 						
										;2 and 3.
		cp		temp,	temp2
		brne	Wait4ButtonsUp
		cpi		temp,0b00001100			;Both buttons up?
		brne	Wait4ButtonsUp;
		ret

Bothbuttons:
		rcall	on						;Assure that the oscillator is on while being adjusted.
		ldi		temp,nominalchannel		;Set channel number to nominal 
										;(Channel 175 gets 100 MHz 
										;operation)
		mov		channel,temp
		rcall	SendAUX_N
		rjmp	Buttonack				;Reset channel number to default and 
										;send new AUX_N value.
	

delay2:									;Setts the frequency for the beeps.
		ldi		delayone,1 				;Delay for 1/2 cycle of button click.
outerloop2:
		ldi		delaytwo,150	
innerloop2:
		dec		delaytwo
		brne	innerloop2

		dec		delayone
		brne	outerloop2
		ret



shiftout:								;Clock MSB of tempreg into LMX1601 
										;Microwire interface, exits with tempreg 		
										;shifted left one bit.
		cbi		PORTB,DataPin			;Clear PORTB,Datapin
		lsl		tempreg					;Get bit 7 into carry
		brcc		s1
		sbi		PORTB,DataPin			;If carry set, set PORTB,Datapin
s1:
		sbi		PORTB,ClockPin			;Toggle Clock high then low.
		nop
		cbi		PORTB,ClockPin
		nop
		ret

LoadData:
		sbi		PORTB,LEPin
		nop
		cbi		PORTB,LEPin
		ret



DelayLoader:							;Short delay routine
		clr		delayc					;used varioius places.
outerloop9:
		clr		secondelay	
innerloop9:
		dec		secondelay
		brne	innerloop9
		dec		delayc
		brne	outerloop9
ret





LoadLMX:								;Aux_N values are calculated in  SendAUX_N subroutine.			
	ldi		tempreg,AuxR2				;Load the values into AuxR into LMX1601
	rcall	shiftout
	rcall	shiftout

	ldi		tempreg,AuxR1
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	ldi		tempreg,AuxR0
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
		
	rcall	LoadData
		

	ldi		tempreg,Main_R2				;Load Main_R into LMX1601
	rcall	shiftout
	rcall	shiftout

	ldi		tempreg,Main_R1
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	ldi		tempreg,Main_R0
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	rcall	LoadData
	rcall	SendAUX_N


	ldi		tempreg,Main_N2				;Load AUX_N into LMX1601
	rcall	shiftout
	rcall	shiftout

	ldi		tempreg,Main_N1
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	ldi		tempreg,Main_N0
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	rcall	LoadData

	ret





SendAUX_N:								;Add counter to the offset then load 
										;into AUX_Nr2..AUX_Nr0, and then load 				
										;into LXM1601.
	ldi		XH,0
	mov		XL,channel
	ldi		YH,3
	ldi		YL,57
	clc
	adc		YL,XL						;Add the channel number to the constant 
										;offset (825)
	adc		YH,XH


	mov		temp,YH						;Get YH bits 3 and 4 into AUX_N2 bits 7 
										;and 6 respecitively. 
	lsl		YH
	lsl		YH
	lsl		YH
	lsl		YH
	andi	YH,0b11000000				;YH bits 0 and 1 are now in positions 7 
										;and 6 and other bits are zero.

	mov		tempreg,AUX_Nr2				;Get the current value of AUX_Nr2.
	andi	tempreg,0b00111111			;Clear bits 7 and 6.
	or		tempreg,YH					;Or new bits into it.
	mov		AUX_Nr2,tempreg				;Save AUX_Nr2 value with new values for 
										;bits 7 and 6.

	lsl		temp						;Work with copy of YH data. Move bits 1 
										;and 0 into positions 7 and 6.
	lsl		temp
	lsl		temp
	lsl		temp
	lsl		temp
	lsl		temp
	andi	temp,0b11000000				;Bits are now in poistions 7 and 6, and 
										;all other bits are zero.
	clr		AUX_Nr1						;Clear AUX_Nr1 because all bits for ;										
										;AUX_Nr1 will be replaced by oring in.	
	or		AUX_Nr1,temp				;YL bits 1 and 0 have been moved to 				
										;AUX_Nr1 bits 7 and 6					

										;Get the six upper bits of YL into the 
										;lower six bits of AUX_Nr1.
	mov		temp,YL						;Save a copy of YL in temp.
	lsr		temp
	lsr		temp
	andi	temp,0b00111111
	or		AUX_Nr1,temp				;Not the upper six bits of YL have been 
										;placed in the lower six bit positions 
										;of AUX_Nr1.
	
	lsl		YL							;Get two lower bits from YL into the two 
	lsl		YL							;uppper bits of AUX_Nr0.	
	lsl		YL
	lsl		YL
	lsl		YL
	lsl		YL
	andi	YL,0b11000000				;Bits are now in poistions 7 and 6, and 
										;all other bits are zero.
	mov		temp,AUX_Nr0				;Clear AUX_Nro bits 7 and 6 in 	
										;preparation to or new values into the 
										;register.	
	andi	temp,0b00111111
	or		temp,YL
	mov		AUX_Nr0,temp								
	

	mov		tempreg,AUX_Nr2		
	rcall	shiftout
	rcall	shiftout

	mov		tempreg,AUX_Nr1
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	mov		tempreg,AUX_Nr0
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout
	rcall	shiftout

	rcall	LoadData
	ret									;Finished calculating data and loading 
										;AUX_N register in LMX1601
	
	
.exit									;Assembler will stop at this line.

⌨️ 快捷键说明

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