Good Day Encoder! I have just the solution for you.
Go to www.amqrp.org/kits/micro908/index.html
There you will find a product description for the "Micro908". Download the software labeled "aav5.1a and af1.2d" in the "drivers.asm" routines you will find all the peripheral i/o routines you can think of!
Best regards Bob
Hello Encoder,
I assume that by "differential encoder" you actually mean a rotary encoder or quadrature encoder. If so there has been considerable recent discussion on the following thread in the 16-bit forum.
http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&message.id=398
Regards,
Mac
Hello, Encoder
Here is some code i have used once for the JL3.
Sungam
; Theese bits are in ram-variable flags:
new equ 0 ;indicates that rotationalencoder has changed
direction equ 1 ;moving direction for the encoder
oldstate equ 3 ;stores the oldstate for the encoderinput
;so the ISR can determine if it has changed state
org flash
main
....
jsr init_timer
cli
....
**************************************************************
; example that changes var when encoder has changed
brclr new,flags,done
bclr new,flags ; indicate that we have picked up the change
brclr direction,flags,decvar
inc var
bra done
decvar
dec var
done
**************************************************************
Init_Timer:
mov #%00110110,TSC ; Timer 1 - Cleared + Stopped.
; Clicks once every 64 BUS Cycle
clr tmodh
mov #93,tmodl ; tof after 94*64 cykles = 1.0027ms
mov #%01000110,TSC ; Start the timer, tof aktiv
rts
**************************************************************
; TOF interrupt happens every 1ms
T_ISR:
pshh
lda tsc
and #%01111111
sta tsc ;clear tof
lda ddra
psha
bclr 0,ddra ;encoder connected to PTA0, PTA1
bclr 1,ddra
nop
nop
brclr 0,porta,enc_low
brset oldstate,flags,done_encoder ;no change since last time?
;if so we're done
bset oldstate,flags ;position has changed
bset new,flags ;new indicates new position,
;main program must clear this flag
brset 1,porta,setdir ;after it has read it
bclr direction,flags
bra done_encoder
setdir
bset direction,flags
bra done_encoder
enc_low
bclr oldstate,flags
done_encoder
pula
sta ddra
done_tisr:
pulh
rti
Thanks a lot Sungam and Mac.
Encoder