ADC 6015 Specifiche Pagina 6

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 14
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 5
dsPIC30F6010A/6015
DS80258G-page 6 © 2008 Microchip Technology Inc.
7. Module: QEI Interrupt Generation
The Quadrature Encoder Interface (QEI) module
does not generate an interrupt when MAXCNT is
set to 0xFFFF and the following events occur:
1. POSCNT underflows from 0x0000 to 0xFFFF.
2. POSCNT stops.
3. POSCNT overflows from 0xFFFF to 0x0000.
This sequence of events occurs when the motor is
running in one direction, which causes POSCNT to
underflow to 0xFFFF. Once this happens, the
motor stops and starts to run in the opposite
direction, which generates an overflow from
0xFFFF to 0x0000. The QEI module does not
generate an interrupt when this condition occurs.
Work around
To prevent this condition from occurring, set
MAXCNT to 0x7FFF, which will cause an interrupt
to be generated by the QEI module.
In addition, a global variable could be used to keep
track of bit 15, so that when an overflow or
underflow condition is present on POSCNT, the
variable will toggle bit 15. Example 1 shows the
code required for this global variable.
EXAMPLE 1:
unsigned int POSCNT_b15 = 0;
unsigned int Motor_Position = 0;
int main(void)
{
// ... User's code
MAXCNT = 0x7FFF; // Instead of 0xFFFF
Motor_Position = POSCNT_b15 + POSCNT;
// ... User's code
}
void __attribute__((__interrupt__)) _QEIInterrupt(void)
{
IFSxbits.QEIIF = 0; // Clear QEI interrupt flag
// x=2 for dsPIC30F
// x=3 for dsPIC33F
POSCNT_b15 ^= 0x8000; // Overflow or Underflow
}
Vedere la pagina 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14

Commenti su questo manuale

Nessun commento