Using the DS87C530/DS5250 Real

[09-13 17:03:26]   来源:http://www.88dzw.com  控制技术   阅读:8357

文章摘要:;***;Program RTC_CALB.ASM;;This program configures the DS87C530 so that the internal RTC frequency can;be measured. A 4kHz signal, derived by dividing the 32.768kHz RTC by 8,;will be asserted on pin P1.7. The device will step through the 8 settings of;the RTC trim bits, displaying the current conten

Using the DS87C530/DS5250 Real,标签:计算机控制技术,工厂电气控制技术,http://www.88dzw.com

;***************************************************************************
;Program RTC_CALB.ASM
;
;This program configures the DS87C530 so that the internal RTC frequency can
;be measured. A 4kHz signal, derived by dividing the 32.768kHz RTC by 8,
;will be asserted on pin P1.7. The device will step through the 8 settings of
;the RTC trim bits, displaying the current contents of the trim register on
;port 3. A delay of approximately 15 seconds (at 25MHz) is inserted between
;each setting to allow time to record the frequency.
;
;To calibrate the RTC capacitance, connect a frequency counter to pin P1.7 and
;execute this program. Record the frequency from the counter and the trim bit
;settings as shown on port 3 as it steps through the 8 possible trim settings.
;The setting that produces a frequency closest to 4096Hz is the most accurate
;setting of RTC capacitance.
;***************************************************************************
RTCC equ 0F9h ;Real-time Clock Control
TA equ 0C7h ;Timed Access Register
TRIM equ 96h ;RTC Trim Register
P3 equ 0B0h ;Port 3 Latch

;These definitions are for 6pF crystal calibration.
TRIM0 equ 95h ;First trim bit setting (6pF)
TRIM1 equ 96h ;Second trim bit setting (6pF)
TRIM2 equ 99h ;Third trim bit setting (6pF)
TRIM3 equ 9Ah ;Fourth trim bit setting (6pF)
TRIM4 equ 0A5h ;Fifth trim bit setting (6pF)
TRIM5 equ 0A6h ;Sixth trim bit setting (6pF)
TRIM6 equ 0A9h ;Seventh trim bit setting (6pF)
TRIM7 equ 0AAh ;Eighth trim bit setting (6pF)

;These definitions are for 12.5pF crystal calibration.
;TRIM0 equ 0D5h ;First trim bit setting (12.5pF)
;TRIM1 equ 0D6h ;Second trim bit setting (12.5pF)
;TRIM2 equ 0D9h ;Third trim bit setting (12.5pF)
;TRIM3 equ 0DAh ;Fourth trim bit setting (12.5pF)
;TRIM4 equ 0E5h ;Fifth trim bit setting (12.5pF)
;TRIM5 equ 0E6h ;Sixth trim bit setting (12.5pF)
;TRIM6 equ 0E9h ;Seventh trim bit setting (12.5pF)
;TRIM7 equ 0EAh ;Eighth trim bit setting (12.5pF)
;
cseg at 0 ;Reset vector.
LJMP START

cseg at 100H ;Start of program
;
START: MOV P3, #0AAh ;I'm alive message.

MOV TA, #0AAh ;Timed access.
MOV TA, #55h
MOV RTCC, #01h ;Start RTC and clear RTC interrupt flag.

LCALL HALFSEC ;Delay to give RTC oscillator time to
; warm up.
; End of initialization. Now step through all the settings of the trim bits.
MOV R0, #TRIM0 ;Trim setting 0
LCALL NEXT_SETTING

MOV R0, #TRIM1 ;Trim setting 1
LCALL NEXT_SETTING

MOV R0, #TRIM2 ;Trim setting 2
LCALL NEXT_SETTING

MOV R0, #TRIM3 ;Trim setting 3
LCALL NEXT_SETTING

MOV R0, #TRIM4 ;Trim setting 4
LCALL NEXT_SETTING

MOV R0, #TRIM5 ;Trim setting 5
LCALL NEXT_SETTING

MOV R0, #TRIM6 ;Trim setting 6
LCALL NEXT_SETTING

MOV R0, #TRIM7 ;Trim setting 7
LCALL NEXT_SETTING

MOV P3, #0FFh ;Turn on all port 3 pins to signal
DONE: JMP DONE ; we're done.

;***************************************************************************
;NEXT_SETTING - This subroutine writes the new setting to the RTC trim register,
; displays the value of the trim register on port 3 for reference,
; and delays for a period to give time to record the data
;***************************************************************************
NEXT_SETTING:
MOV TA, #0AAH ;Timed access.
MOV TA, #55h
MOV TRIM, R0 ;Set E4K and new trim setting.
NOP
MOV P3, TRIM ;Output value of trim register.

SEC30: MOV R3, #30 ;15 second delay with 25MHz crystal.
SECLOOP: LCALL HALFSEC
DJNZ R3,SECLOOP
RET

;***************************************************************************
;HALFSEC - This subroutine generates a delay of approximately 0.5 second with
; a 25MHz crystal.
;***************************************************************************
HALFSEC: MOV R0,#25
OUTER: MOV R1,#125
MIDDLE: MOV R2,#249
INNER: NOP
DJNZ R2,INNER
DJNZ R1,MIDDLE
DJNZ R0,OUTER
RET

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  下一页


Tag:控制技术计算机控制技术,工厂电气控制技术控制技术

《Using the DS87C530/DS5250 Real》相关文章