Hi Nathan,
I am playing around with a modified Hitec RC receiver, that I have modified to get the clock signal from the receiver which with one IO line you can deduce all of the signals. I thought I would generate a quick and dirty RC input file for the phoenix code using this. I thought I would try it on the Arc32 as currently that is the only BAP I have running on a hex...
I thought I would try doing this in the background using interrupts. I am starting off with a version of the IRQ2 handler in basic. Once I think things are working well, will convert to asm...
On a Bap28 in a test program I used TimerA to time the pulses. My IRQ2 handler emulates my get clock time as I have not enabled interrupts. IE, it grabs the overrun count, TMA and checks to see if there is a pending timer interupt... Could do similar on Arc32 by using TimerB1, but...
You already have a timer running that you can get the time from using the command HSERVOTIME. But I assume I have the same problem with pending timer interrupt probably TimerZ? Suggestions? Also is the timer value associated with HSERVOTIME available in ASM?
Thanks
Kurt
P.S. - Beginning hacked up interrupt handler
Code:
Handle_IRQ2:
toggle p44 ; status LED on arc32...
; Use hservo
;gosub GetCurrentTime - don't want to enable interrupts yet so do inline
#ifdef USER_TIMERA ; BUGBUG: Convert to B1 if we go this way...
_lNewPulseTime = lTimerCnt + TCA
; see if timer is waiting to process interrupt.
if IRR1.bit6 then
_lNewPulseTime = lTimerCnt + 256 + TCA
endif
#else
_lNewPulseTime = HServoTime 0;
#endif
; calculate the pulse width and convert to us and save away the pulse time
_wPulseWidth = _lNewPulseTime - _lLastPulseTime ; not scaled yet
_wPulseWidth = _wPulseWidth / 20; 20mhz clock, convert to 1mhz
_lLastPulseTIme = _lNewPulseTime;
; See if the value appears to be OK.
if _wPulseWidth > 2500 then
; Where were we???
if _bNextChannel < CNT_PPM_SIGNALS then
; We got a long value when we did not expect it...???
fPPMsValid = 0;
endif
_bNextChannel = 0; // Ok lets assume the next value will be for our first channel
else
if _bNextChannel < CNT_PPM_SIGNALS then
awPPMs(_bNextChannel) = _wPulseWidth
_bNextChannel = _bNextChannel + 1
if _bNextChannel = CNT_PPM_SIGNALS then
fPPMsValid = 1 ; Let the main line know that we received a complete valid set of values
endif
endif
endif
resume