This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

external interrupt with F28035

Other Parts Discussed in Thread: CONTROLSUITE

Hi everybody..

i am using f28035 and i have tried to external inerrupt but i cant do it why i dont know..

i want to read rotary encoder and if i dont want to miss any encoder signal i have to connect it external interrupt.. but i can not do it...

i connect rotary encoder to GPIO0 and GPIO2..how can i set code?

can you help me???

  • The document SPRUGL8B tells you exactly what you need to do: http://www.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sprugl8b&fileType=pdf

    You need to configure one of the XINT interrupts. You have 3 to choose from, they can be connected to GPIO0-31 (see GPIOXINTnSEL register). Configure polarity and stuff in the XINTnCR configuration registers. Enable corresponding PIE group interrupts (1 or 12 depending on your setup) and add isr code.

    But why use XINT and do it manually when you have an eCAP module !?!!?!?!!?

    /Mikael

  • i will look documentaion which you give me link..

    how can i use eCAP module?? i have never used it...is it better ?

  • hi,

    Firstly thank you  ..

    i run encoder with eCAP.. but when i turned right or left value of counter is rising i can not seperate difference(right and left side)???

    on the other hand when i am looking i find feature of eQEP..this feature for encounter ...

    i connect one of rotary pi to GPIO20 (EQEP1A) the other pin of rotary  GPIO21 (EQEP1B)..so how can i set it?...

    or are there any exaple like this application?

  • Oh, sorry. Yeah the eQEP does exactly what you need. Found no example but there are detailed explanations in the documentation.

  • Ali,

     The eQEP module is exactly what you want. In order to configure it the way you want, a good start will be to have a look at one of the eQEP initialization files in motor control projects. 

    Look for f2803xqep.h and within this the QEP_INIT_MACRO. The module setup will be less daunting. 

  • Hi,

    I put here my setting of EQEP of F2803x (from TI\controlSUITE\device_support\f2803x\v125\DSP2803x_examples_ccsv4\eqep_pos_speed\Example_2803xEqep_pos_speed.c),

        EQep1Regs.QUPRD = 600000 ;         // Unit Timer for 100Hz at 60 MHz SYSCLKOUT

        EQep1Regs.QDECCTL.bit.QSRC = 0 ;      // QEP quadrature count mode

        EQep1Regs.QEPCTL.bit.FREE_SOFT = 2 ;

        EQep1Regs.QEPCTL.bit.PCRM = 1 ;        // PCRM  mode - QPOSCNT reset on max position
        EQep1Regs.QEPCTL.bit.UTE  = 1 ;        // Unit Timeout Enable
        EQep1Regs.QEPCTL.bit.QCLM = 1 ;        // Latch on unit time out

        EQep1Regs.QPOSMAX = 0xFFF ;            // max count for an encoder with 12-bits, 4096 counts
        EQep1Regs.QEPCTL.bit.QPEN = 1 ;        // QEP enable

        EQep1Regs.QCAPCTL.bit.UPPS = 5 ;       // 1/32 for unit position
        EQep1Regs.QCAPCTL.bit.CCPS = 6 ;       // 1/64 for CAP clock
        EQep1Regs.QCAPCTL.bit.CEN  = 1 ;       // QEP Capture Enable

        EQep1Regs.QPOSCTL.bit.PCE = 1 ; // enable position compare unit
       
       
        EQep1Regs.QEINT.bit.PCM = 1 ;   // enable pos compare interrupt
        EQep1Regs.QEINT.bit.UTO = 1 ;    // enable unit time out interrupt

    //////////////////////////////////

    To read values of EQEP, read EQep1Regs.QPOSCNT.

    Hop it helps.

    Jack

     

     

  • hi everybody..

    thank you for your interest..

    i run the eQEP but there are some problems..when i turn rotory to right, value of tt(EQep1Regs.QPOSCNT) increase 4 points(as 4-8-12-16-20) and when i turn rotary to  left, value of tt decrease 4 point (as 16-12-8-4)..

    what is the problem???

     

     

    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

    //#include "Example_posspeed.h"   // Example specific Include file

     

    int tt=0;

     

    interrupt void QEP_ISRCounterCompare(void)  {

     

     

     

        EQep1Regs.QCLR.bit.PCM = 1 ;         // clear PCM

     

        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;      

        EQep1Regs.QCLR.bit.INT = 1 ;        // clear global INT FLAG                 

     

    }

     

     

    void main(void)

    {

     

     InitSysCtrl();

     

       InitEQep1Gpio();

       DINT;

     

       InitPieCtrl();

     

    // Disable CPU interrupts and clear all CPU interrupt flags:

       IER = 0x0000;

       IFR = 0x0000;

     

       InitPieVectTable();

     

       EALLOW;  

       PieVectTable.EQEP1_INT = &QEP_ISRCounterCompare ;

       EDIS;    

     

       IER |= M_INT5 ;

     

       PieCtrlRegs.PIEIER5.bit.INTx1 = 1 ;

     

    // Enable global Interrupts and higher priority real-time debug events:

       EINT;   // Enable Global interrupt INTM

       ERTM;   // Enable Global realtime interrupt DBGM

     

     //  EQep1Regs.QPOSCNT = 78 ; // testest init

       EQep1Regs.QPOSCMP = 100 ;

     

    // =============== Init eQEP ============================================

     

     

        EQep1Regs.QUPRD=600000;             // Unit Timer for 100Hz at 60 MHz SYSCLKOUT

     

        EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

     

        EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;

        EQep1Regs.QEPCTL.bit.PCRM=1;       // PCRM=00 mode - QPOSCNT reset on index event

        EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout Enable

        EQep1Regs.QEPCTL.bit.QCLM=1;        // Latch on unit time out

     

        EQep1Regs.QPOSMAX = 0xFFF ;         // for an encoder with 12-bits

        EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

     

        EQep1Regs.QCAPCTL.bit.UPPS=5;       // 1/32 for unit position

        EQep1Regs.QCAPCTL.bit.CCPS=6;       // 1/64 for CAP clock

        EQep1Regs.QCAPCTL.bit.CEN=1;        // QEP Capture Enable

     

     

        EQep1Regs.QPOSCTL.bit.PCE = 1 ; // enable position compare unit

     

        EQep1Regs.QEINT.bit.PCM = 1 ;   // enable pos compare interrupt

    EQep1Regs.QEINT.bit.UTO = 1 ;    // enable unit time out interrupt

    // =============== Interrupt subroutine ===================================

    for(;;)

    {

    tt=EQep1Regs.QPOSCNT;

    }

    }

  • on the other hand i want to add something my comment...

    i insert something into interrupt routine for making sure doing interrupt routine...

     

    i added zz and every turning rotary should increase value of zz but when i turn rotary, value of EQep1Regs.QPOSCNT is changing ,but zz is not changing....

    is not it problem???

     

    interrupt void QEP_ISRCounterCompare(void)  {

      zz=zz+1;

        EQep1Regs.QCLR.bit.PCM = 1 ;         // clear PCM 

        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;      

        EQep1Regs.QCLR.bit.INT = 1 ;        // clear global INT FLAG                

    }

  • The ISR you have added zz to will only occur when your position (QPOSCNT) equals 100, which is why you do not see it increment.  To see zz increment/decrement, do it after you read the QPOSCNT register in the for loop.

    How are you determining that your position is jumping from 4-8-12 and not actually traversing the integers in between?

  • i have tried to turn rotary higher than 100 but zz was not increase again!!!?

     

    but if i can change zz to in for loop, it give me for loops count , it doesnt give me value of interrupt, does it?

    on the other hand how can it determine value of increments (4-8-12), i dont know:(.... but  when i try turn rotary value of increment or value of decremant is 4 point...why i dont know :(... 

  • Try getting rid of the position counter compare interrupt and unit timer interrupt. Check only whether your QEP module increments and decrements when you move your rotor. Verify this behaviour and then move to position compare etc.

  • ok i got rid of alot things you can see below...

    but again increment and decrent value is 4 point again:(

    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

    int tt=0,zz=0;

    void main(void)

    {

     InitSysCtrl();

       InitEQep1Gpio();

       DINT;

       InitPieCtrl(); 

       IER = 0x0000;

       IFR = 0x0000;

       InitPieVectTable();

          IER |= M_INT5 ;

       PieCtrlRegs.PIEIER5.bit.INTx1 = 1 ;   

       EINT;   // Enable Global interrupt INTM

       ERTM;   // Enable Global realtime interrupt DBGM

          EQep1Regs.QUPRD=600000;             // Unit Timer for 100Hz at 60 MHz SYSCLKOUT

        EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

        EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;

        EQep1Regs.QEPCTL.bit.PCRM=1;       // PCRM=00 mode - QPOSCNT reset on index event

        EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout Enable

        EQep1Regs.QEPCTL.bit.QCLM=1;        // Latch on unit time out

        EQep1Regs.QPOSMAX = 1000 ;         // for an encoder with 12-bits

        EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

        EQep1Regs.QCAPCTL.bit.UPPS=5;       // 1/32 for unit position

        EQep1Regs.QCAPCTL.bit.CCPS=6;       // 1/64 for CAP clock

        EQep1Regs.QCAPCTL.bit.CEN=1;        // QEP Capture Enable

        EQep1Regs.QPOSCTL.bit.PCE = 1 ; // enable position compare unit  

        EQep1Regs.QEINT.bit.PCM = 1 ;   // enable pos compare interrupt

    // =============== Interrupt subroutine ===================================

    for(;;)

    {

    tt=EQep1Regs.QPOSCNT;

    }

    }

  • Ali,

     If on a scope your encoder signals look fine, then I am not sure what may be causing these funny counts. In one revolution you should see QPOSCNT increment to 4*encoder lines with your current configuration. I'd also check the physical connection to the board, making sure that phase A is connected to GPIO20 and phase B is connected to GPIO21.  

  • i looked board and signals everything is ok..

    phase A is connected GPIO20 and PhaseB is connected to GPIO21 and also i changed my rotary encoder on board..but 4 counting is  same :(...

    i have tried strange way;

    when i did  tt=EQep1Regs.QPOSCNT*0.25 , tt value increase 1 point or decrease 1 point :):):):)...

     

    but it is trickery ...

  • Hi,

    Does your encoder enable to read absolute position? If it is, you  can use this absolute position to check EQep1Regs.QPOSCNT

     

    Jack

  • hi everybody,

    i have not solved this problem yet..i connect rotary encoder potentiometer to  GPIO20 and GPIO21 but i have never connected any index pin because i dont have index. so may  the reason of problem be this?

  • Hi Ali,

    The reason not in the index pin because  index is used as a zero mark for rotary encoders. All eQEP module necessary for the operation is two square waves shifted 90°. 

    Your situation is very strange. May be you can disconnect the encoder and connect two switches instead to try to simulate encoder manually and look how the eQEP module works.

    What is your encoder type?

     

  • Hi everybody,

    Thank you everybody for support..

    i have solved my problem..

    if you want to use rotary encoder potantiometer , you have to set  EQep1Regs.QDECCTL.bit.QSRC=01;    otherwise your counter will count 4 point every turn :)...