Hi P,Almost. One thing you need to remember is that when reading a value from two separate registers you need to make sure the process is not disturbed by an interrupt. In any piece of code, which is not an interrupt service routine, you need to disable interrupts before you read the two register and you need to enable interrupts when you finish reading the pair of registers.
Maybe it would be helpful if you can describe the setup of the QEI module, and what should happen when the module generates an interrupt.
Here is the set-up:
I think I understand the need for sequencial OFF/ON of each interrupt.
C.
'************************ ADDED QEI **********************************
qeicon = %00011011 'QEI enabled in 4x Update mode; position TIME is reset on period match (POSCNT = MAXCNT)MOVED TEST&
''QEICON VELM=0 Velocity mode enabled, QERR=0 No over/underflo, UP/DOWN=0 REVERSE, QEIM=110 QEI EN POSCNT=MAXCNT), PDEC=11 1:64
ipr3.ic2qeip = 0 '& 1 'high pri intr QEI Interrupt priority bit
pie3.ic2qeie = 0 '& 1 'qei intr enb QEI Interrupt flag enable bit
pir3.ic2qeif = 0 'Has reached the MAXCNT value, INT QEI MODULE Interrupt flag bit
pir3.ic3drif = 0 'clr in s/w REG file motion feedback filter
PIE1.RCIE = 0 '0= Disables the EUSART receive interrupt
cap2bufl = 0x00
cap2bufh = 0x00
cap3bufl = 0x9f 'CAP3BUFL = 0x67
cap3bufh = 0x05 'CAP3BUFH = 0x01
'*************************************************************************
LOOP
s2m(0) = cap2bufl 'QEI
s2m(1) = cap2bufh 'QEI
Etc Etc.
GOTO LOOP
