Which Atom Pro are you using?
If it is the Arc32, you can initialize and use the HServoTime function. It is described in the data sheet for the Arc32.
If you are using a Basic Atom Pro 24/28 you can setup and use TimerA or TimerV and if you are not using HSERVO or the like TimerW. If you are on a BAP40/BAP64 /(Arc32 and don't wish to use HSERVO), you can setup and use TimerB1, or TimverV or TimerZ.
Example using TimerA (Code extracted from Lynxmotion Phoenix code... :
Code:
;====================================================================
lTimerCnt var long
;--------------------------------------------------------------------
;[TIMER INTERRUPT INIT]
TIMERINT con TIMERAINT
ONASMINTERRUPT TIMERAINT, HANDLE_TIMERA_ASM
;--------------------------------------------------------------------
;[InitServoDriver] - Initializes the servo driver including the main timer used in the phoenix code
InitTimer:
;Timer
; Timer A init, used for timing of messages and some times for timing code...
TIMERINT con TIMERAINT
WTIMERTICSPERMSMUL con 64 ; BAP28 is 16mhz need a multiplier and divider to make the conversion with /8192
WTIMERTICSPERMSDIV con 125 ;
TMA = 0 ; clock / 8192 ; Low resolution clock - used for timeouts...
ENABLE TIMERINT
return
;==============================================================================
;[Handle_Timer_asm] - Handle timer A overflow in assembly language. Currently only
;used for timings for debugging the speed of the code
;Now used to time how long since we received a message from the remote.
;this is important when we are in the NEW message mode, as we could be hung
;out with the robot walking and no new commands coming in.
;==============================================================================
BEGINASMSUB
HANDLE_TIMERA_ASM
push.l er1 ; first save away ER1 as we will mess with it.
bclr #6,@IRR1:8 ; clear the corresponding bit in the interrupt pending mask
mov.l @LTIMERCNT:16,er1 ; Add 256 to our counter
add.l #256,er1
mov.l er1, @LTIMERCNT:16
pop.l er1
rte
ENDASMSUB
return ; Put a basic statement before...
;==============================================================================
;[GetCurrentTime] - Gets the Timer value from our overflow counter as well as the TCA counter. It
; makes sure of consistency. That is it is very possible that
; after we grabbed the timers value it overflows, before we grab the other part
; so we check to make sure it is correct and if necessary regrab things.
;==============================================================================
GetCurrentTime:
lCurrentTime = lTimerCnt + TCA
; handle wrap
if lTimerCnt <> (lCurrentTime & 0xffffff00) then
lCurrentTime = lTimerCnt + TCA
endif
return lCurrentTime
;-------------------------------------------------------------------------------------
;[ConvertTimeMS]
_ttconv var long
ConvertTimeMS[_ttconv]:
return (_ttconv * WTIMERTICSPERMSMUL)/WTIMERTICSPERMSDIV
The code for the Bap40 using TimerB1 is almost identical. Except the names of the registers and interrupt, and the conversion factor to milliseconds as the Bap28 runs at 16mhz and the Bap40/Arc32 run at 20mhz.
Hope that helps
Kurt