summaryrefslogtreecommitdiff
path: root/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90
diff options
context:
space:
mode:
Diffstat (limited to 'digital/beacon/src/Bitcloud_stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90')
-rw-r--r--digital/beacon/src/Bitcloud_stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s9080
1 files changed, 80 insertions, 0 deletions
diff --git a/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90 b/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90
new file mode 100644
index 00000000..cbdb8d13
--- /dev/null
+++ b/digital/beacon/src/Bitcloud_stack/Components/HAL/avr/atmega1281/common/src/halCalibration.s90
@@ -0,0 +1,80 @@
+/**************************************************************************//**
+ \file halCalibration.s90
+
+ \brief Implementation of measurement of mcu clock.
+
+ \author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+ \internal
+ History:
+ 1/10/08 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+/*=============================================================
+Calculates number of cycles during EXTERNAL_TICKS period.
+Parameters:
+ none
+Returns:
+ number of the cycles (r17:r16).
+===============================================================*/
+PUBLIC halMeasurement
+RSEG CODE
+halMeasurement:
+ push r21
+
+ ; Store SREG
+ push r23
+ in r23, 0x3F
+ ; Disable interrupts
+ cli
+
+ ; local copy cnt
+ push r28
+ push r29
+ ldi r28, 0 ; cnt = 0
+ ldi r29, 0 ; cnt = 0
+
+ ; r21 = TCNT2
+ push r23 ; save SREG to stack, to clear r23
+ lds r21, 0x00B2
+ ; while(TCNT2 == r21);
+ __l0:
+ lds r23, 0x00B2
+ cp r23, r21
+ breq __l0
+
+ ; r23++
+ inc r23
+
+ ; measurement
+ __l1:
+ adiw r28, 0x01 ; cnt ++ (2 cycle)
+ lds r21, 0x00B2 ; read TCNT2
+ cp r21, r23 ; if (TCNT2 == TCNT2old)
+ brne __l1 ;
+
+ pop r23 ; load SREG from stack
+
+ ; return cnt
+ movw r16, r28
+
+ pop r29
+ pop r28
+
+ ; Restore SREG
+ out 0x3F, r23
+ pop r23
+ pop r21
+ ret
+
+; eof halCalibration.s90
+END