Hi Guys,
I had some new issues with the current Basic Micro Studio (2.0.0.5) in combination with the phoenix code. Kurt was happy to help me out on this and we found the issue.
There is a little change in how the compiler handles the assembly code. So make sure you've got the
ASM{},
BEGINASMSUB and
ENDASMSUB on the correct locations.
The timer functions should look like this.
Code:
;--------------------------------------------------------------------
;[Handle TimerW interrupt]
BEGINASMSUB
HANDLE_TIMERW
ASM{
push.w r1 ; save away register we will use
bclr #7,@TSRW:8 ; clear the overflow bit in the Timer status word
mov.w @WTIMERWOVERFLOWCNT:16,r1 ; We will increment the word that is the highword for a clock timer
inc.w #1,r1
mov.w r1, @WTIMERWOVERFLOWCNT:16
pop.w r1 ; restore our registers
rte ; and return
}
ENDASMSUB
return
;-------------------------------------------------------------------------------------
;[Simple function to get the current time and verify that no overflow happened]
GetCurrentTime
ASM{
nop ; probably not needed, but to make sure we are in assembly mode
mov.w @WTIMERWOVERFLOWCNT:16, e1
mov.w @TCNT:16, r1
mov.w @WTIMERWOVERFLOWCNT:16, r2
cmp.w r2,e1 ; make sure no overflow happened
beq _GCT_RETURN:8 ; no overflow, so return it
mov.w @WTIMERWOVERFLOWCNT:16, e1
mov.w @TCNT:16, r1
_GCT_RETURN:
mov.l er1, @LCURRENTTIME:16
}
return lCurrentTime ; switched back to basic
;--------------------------------------------------------------------
If you are also using the RC remote version you should also add the ASM{} brackets in the pulsin7 function
Code:
;-------------------------------------------------------------------
;[Pulsein7] Read in all 7 servo values in one pass.
Pulsein7:
ASM{
; Make sure all 7 IOs are set to input.
PMR5 = 0 ; all IO lines are general IO
PCR5 = 0 ; All are input (may want to leave bit 7 alone...
...
_P17_RETURN_STATUS:
mov.b r1l,@BPULSETIMEOUT
; finally transisition back to basic and return.
}
return
;--------------------------------------------------------------------
This solved the problem for me.
Kurt, Thanks again for solving this

Xan