eTPU QD, what is the purpose of the two pc parameters in fs_etpu_qd_set_pc_interrupts(chan, pc1, pc2)?

cancel
Showing results for 
Search instead for 
Did you mean: 

eTPU QD, what is the purpose of the two pc parameters in fs_etpu_qd_set_pc_interrupts(chan, pc1, pc2)?

400 Views
sambartlett
Contributor I

I'm using the MCF5234 on a Netburner board.  I'm using the eTPU QD quadrature Encoder function.  I can get fs_etpu_qd_set_pc_interrupts(chan, pc1, pc2) to send interrupts, and I can service them, but I'm having trouble getting it to work in both directions (I'm going back and forth on a linear encoder, so the revolution counter doesn't apply).  I've tried setting both pcs the same, or setting one for my target and one for (either the far or near) extreme of travel, and I cannot figure the point of the second pc2.  Looking at the code doesn't help me and I've found no documentation that says more than that they are for the first and second position counter settings, but no explanation of why you want a second pc setting.

Thanks,

Sam

Labels (1)
Tags (3)
0 Kudos
3 Replies

140 Views
TomE
Specialist I

I assume you're looking at AN2842. It isn't very helpful, is it? It lists the functions without saying anything about how they work.

> Looking at the code doesn't help me

What code is that, and can you provide a link so I can read it?

Have you checked all if the "References" listed in AN2842?

7 References

1. “The Essential of Enhanced Time Processing Unit,” AN2353.

2. “General C Functions for the eTPU,” AN2864.

3. “Using the DC Motor Control eTPU Function Set (set3),” AN2958.

4. “Using the AC Motor Control eTPU Function Set (set4),” AN2968

5. Enhanced Time Processing Unit Reference Manual, ETPURM/D.

6. eTPU Graphical Configuration Tool, http://www.freescale.com/etpu, ETPUGCT.

7. “BLDC Motor with Quadrature Encoder and Speed Closed Loop,

    driven by eTPU on MCF523x,” AN2957.


This one documents twoqd_pc_interrupt parameters, but it seems to use different functions to set them in this code:


http://cache.freescale.com/files/32bit/doc/app_note/AN2957.pdf


Tom


140 Views
sambartlett
Contributor I

Thanks Tom,

Here is the code, which came with my Netburner IDE:

/*******************************************************************************

*FUNCTION     : fs_etpu_qd_set_pc_interrupts

*PURPOSE      : This function changes the pc_interrupt values.

*INPUTS NOTES : This function has 3 parameters:

*  channel_primary - This is the Primary channel number (Phase A).

*                    0-31 for ETPU_A and 64-95 for ETPU_B.

*  pc_interrupt1   - This is the pc_interrupt1 value to be set.

*  pc_interrupt2   - This is the pc_interrupt2 value to be set.

*

*RETURNS NOTES: Error code that can be returned is: FS_ETPU_ERROR_VALUE.

*******************************************************************************/

int32_t fs_etpu_qd_set_pc_interrupts(uint8_t channel_primary,

                                     int24_t pc_interrupt1,

                                     int24_t pc_interrupt2)

{

   /* Parameters bounds check */

   #ifdef FS_ETPU_MC_PARAM_CHECK

   if(((channel_primary>31)&&(channel_primary<64))||(channel_primary>95))

   {

      return(FS_ETPU_ERROR_VALUE);

   }

   #endif

   fs_etpu_set_chan_local_24(channel_primary, FS_ETPU_QD_PCINTERRUPT1_OFFSET,

                             (uint24_t)pc_interrupt1);

   fs_etpu_set_chan_local_24(channel_primary, FS_ETPU_QD_PCINTERRUPT2_OFFSET,

                             (uint24_t)pc_interrupt2);

   return(0);

}

I've looked at the other ANs, they haven't shed any light.  I'm pretty sure that most of them are outdated, as they reference the eTPU function sets, which I don't think are used in the current code. 

My code is working, I've just set both pc1 and pc2 to the same value.

The other thing I'm puzzling over is whether I need to check interrupts from both the primary and the secondary channels.  Right now I am, and it seems that, while moving in the same direction, sometimes one channel interrupts, and sometimes the other. 

0 Kudos

140 Views
sambartlett
Contributor I

Freescale Tech support says that if the QD sees either pc1 or pc2 it will set an interrupt.  I guess this could be useful if you didn't know which way you were going.  I guess I can use it as a fall back value, set it to 4 steps beyond my desired target in case it misses the first one.

0 Kudos