• AVR Freaks

Hot!POSCNT REGISTER VALUE NOT CHANGED

Author
Manish kumar
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2020/01/26 23:43:47
  • Location: 0
  • Status: offline
2020/02/06 21:13:05 (permalink)
0

POSCNT REGISTER VALUE NOT CHANGED

hello every one
             
    Iam  using pic24ep512mc202 controller to interface qei module using incremental encoder ……..
    uart is working fine ...but my poscnt register values are not changing according to my pulses ….always it shows zero only in (ccm:oxoo)   quadrature encoder mode ...
suggest me where iam doing mistake ….
here is my code 
1.qei init:

ANSELB=0x0000;
    TRISBbits.TRISB12=1; //phase a
    TRISBbits.TRISB13=1; // phase b
    TRISBbits.TRISB14=1;// index pin
  
    __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS
    RPINR14bits.QEA1R=0x2C;//input
    RPINR14bits.QEB1R=0x2D;//input
    RPINR15bits.INDX1R=0x2E;//input
  
    __builtin_write_OSCCONL(OSCCON | 0x40); // lock PPS
       QEI1CONbits.QEISIDL = 0x00;         // Module operational in idle mode
           
            QEI1CONbits.PIMOD = 0x00;           // Index does not affect position counter
            //QEI1CONbits.PIMOD = 0x06;           // Count mode for position counter
            QEI1CONbits.IMV = 0x11;             // Index match QEB = 0 & QEB = 1
                                              
            QEI1CONbits.INTDIV = 0x00;          // Prescale 1:1
            QEI1CONbits.CNTPOL = 0x00;          // Positive count
            QEI1CONbits.GATEN = 0x00;           // External gate does not effect position
            QEI1CONbits.CCM = 0x00;             // Mode: quadrature
            QEI1IOCbits.QCAPEN = 0x00;          // Home triggers capture event
                                            // disabled
           
            QEI1IOCbits.FLTREN = 1;          // Digital filter off
            QEI1IOCbits.QFDIV = 0x00;           // 1:1 digital filter clock divide
            QEI1IOCbits.OUTFNC = 0x00;          // Output function disabled
            QEI1IOCbits.SWPAB = 0x00;           // Swap QEA and QEB no
            QEI1IOCbits.IDXPOL = 0x00;          // No Input invertion
            QEI1IOCbits.QEBPOL = 0x00;          // No QEB1 invertion
            QEI1IOCbits.QEAPOL = 0x00;          // No QEA1 invertion
            QEI1STATbits.PCHEQIEN = 0x01;       // Position counter > = int disabled
                                                                 // Enabled
           
            QEI1STATbits.PCLEQIEN = 0x00;       // Position counter < = int disabled
            QEI1STATbits.POSOVIEN = 0x00;       // Position counter overf int disabled
            QEI1STATbits.PCIIEN = 0x00;         // Position counter homing int disabled
            QEI1STATbits.VELOVIEN = 0x00;       // Velocity counter overf int disabled
            QEI1STATbits.HOMIEN = 0x00;         // Home input event int disabled
            QEI1STATbits.IDXIEN = 0x00;         // Index input event int disabled
            QEI1CONbits.QEIEN = 0x01;           // Enable QEI module
            POS1CNTL=0x0000;
            POS1CNTH=0x0000;
          //  POS1CNTHLD=0;
            IEC3bits.QEI1IE = 1;
//    IFS3bits.QEI1IF = 0;
 
 
thanks in advance
#1

1 Reply Related Threads

    Batgoy
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2004/06/15 04:33:51
    • Status: offline
    Re: POSCNT REGISTER VALUE NOT CHANGED 2020/02/27 02:00:26 (permalink)
    0
    Hardware problem!?
    What is the encoder interface? Open collector, RS422...
    How it is connected to the controller?
    #2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5