Electronic Components Datasheet Search
  English  ▼
ALLDATASHEET.NET

X  

AN1324 Datasheet(PDF) 12 Page - STMicroelectronics

Part # AN1324
Description  CALIBRATING THE RC OSCILLATOR OF THE ST7FLITE0 MCU USING THE MAINS
PDF  15 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
Manufacturer  STMICROELECTRONICS [STMicroelectronics]
Direct Link  http://www.st.com
Logo STMICROELECTRONICS - STMicroelectronics

AN1324 Datasheet(HTML) 12 Page - STMicroelectronics

Back Button AN1324 Datasheet HTML 7Page - STMicroelectronics AN1324 Datasheet HTML 8Page - STMicroelectronics AN1324 Datasheet HTML 9Page - STMicroelectronics AN1324 Datasheet HTML 10Page - STMicroelectronics AN1324 Datasheet HTML 11Page - STMicroelectronics AN1324 Datasheet HTML 12Page - STMicroelectronics AN1324 Datasheet HTML 13Page - STMicroelectronics AN1324 Datasheet HTML 14Page - STMicroelectronics AN1324 Datasheet HTML 15Page - STMicroelectronics  
Zoom Inzoom in Zoom Outzoom out
 12 / 15 page
background image
12/15
CALIBRATING THE RC OSCILLATOR OF THE ST7FLITE0 MCU USING THE MAINS
4.2 AVERAGE VERSION
This version perform the count between two edges four times and changes the value of the
RCCR according to the average of these measurements. This method allows to perform a
better tune of the RC oscillator.
4.2.1 main program
;All the bytes from locations 80h to 8Bh are used by this software to store values or as control
registers but they can be reused safely after the clock has been set.
;dichotomy value
.value
equ
$81
;this byte contains the value which will be added
or subtracted to/from the RCCR last value at the end of each round
;capture values
.capture1
equ
$82
.capture2
equ
$86
;these bytes contain the values of the counter captured
on the edge of the mains, they are used to calculate the time elapsed between the two edges
;number of overflows
.nbover
equ
$8A
;this byte contains the number of counter overflows
during the measurement
;control register
.cr
equ
$8B
;this byte is used as a control register for the measure-
ment. Its bits allow or not the interrupts and show which step of the count is the current one.
.strtstp
equ
1
;this is set to start the count and reset to stop it
.overflow
equ
2
;this bit is set when the first capture has occurred. It
allows the overflows to be counted
.main
bset
MCCSR, #1
;output clock enable. You can remove this line if you do
not want to check the clock frequency
ld
A, #$80
;value containing the value which will be
ld
value, A
;add or subs to/from RCCR during the dichotomy
ld
RCCR, A
;RCCR is set to the middle of its range of value
next
clr
nbover
;clear the byte containing the number of timer overflow
clr
cr
;clear the byte use as control register for the count
ld
A, LTICR
;clear the ICF bit
clr
Y
capture rim
;interrupts enable
bset
LTCSR, #7
;enable input capture interrupt
bset
cr,#strtstp
;set the start-stop bit of cr: count can start
count
btjt
cr, #strtstp, count; wait for the end of count
clr
LTCSR
;lite timer interrupts disable
inc
Y
cp
Y,#$4
;repeat the capture four time to make an average
jrne
capture
srl
value
;dichotomy value divided by 2
clr
Y
ld
A,#$F9
;these lines calculate this equation for the four
ld
X,nbover
;measures:
mul
X,A
;(nbover*$F9)+ capture2 - capture1
calcul add
A, (capture2,Y);
jrnc
nocarry
;this equation is calculated with 16 bits
inc
X
;



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Datasheet Download

Go To PDF Page


Link URL



Does ALLDATASHEET help your business so far?  [ DONATE ] 

About Alldatasheet   |   Advertisement   |   Contact us   |   Privacy Policy   |   Link to Datasheet    |   Link Exchange   |   Manufacturer List
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com