| Electronic Components Datasheet Search |
|
AN1324 Datasheet(PDF) 10 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN1324 Datasheet(HTML) 10 Page - STMicroelectronics |
|
10 / 15 page ![]() 10/15 CALIBRATING THE RC OSCILLATOR OF THE ST7FLITE0 MCU USING THE MAINS jrnc nocarry ;this equation is calculated with 16 bits inc X ; nocarry sub A, capture1 ;MSB are in register X jrnc noneg ; dec X ;and LSB in register A. noneg cp X, #$01 ;if mains frequency is 50Hz the reference value is $138 jrmi minus ;if it is 60Hz the reference is $104.the program first jreq compare ;compares MSB with $01 and then compare LSB with jp plus ;$38 for 50Hz and $04 for 60Hz. if the calculated compare cp A, #$38 ;value is smaller than the reference the program jump to jrmi minus ;minus to decrease RCCR else it increase RCCR plus ld A, RCCR add A, value ;add value if counted value is greater than ref jp new minus ld A, RCCR sub A, value ;subtract value if Y is smaller new ld RCCR,A ;enter the new value in RCCR btjf value, #0, next;stop after 7 rounds loop jp loop 4.1.2 input capture interrupt ld A, LTICR ;load captured value in A btjt LTCSR, #4, finish ;test if it is first or second capture bset LTCSR, #4 ;allow timebase interrupt in order to count the number of overflows ld capture1, A ;captured value is stored in capture1 jp endit1 finish ld capture2, A ;if it is the second capture, captured value is stored in capture2 clr cr ;clear cr to end the count endit1 iret 4.1.3 timebase interrupt ld A, LTCSR ;clear TB bit inc nbover ;increment number of overflows endit2 iret 4.1.4 writing in eeprom To store final value of RCCR in EEPROM, add theses lines after disabling the timer interrupts in the main program. ld RCCR, A bset EECSR,#1 ;start to enter value in the EEPROM ld $1003,A ;load value of the RCCR in EEPROM bset EECSR,#0 ;start to write in the EEPROM wait btjt EECSR,#0,wait ;wait for the end of writing in EEPROM |
|
|
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 |
| 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 |