Quadrature input with the eTPU

Discussion to talk about software related topics only.
Post Reply
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Quadrature input with the eTPU

Post by v8dave »

Has anyone here worked with the quadrature input on the eTPU of the MOD5234?

I have a panel mounted rotary encoder that generates 30 pulse per rev and I can see the input pins on the device clocking as I turn the knob.

The issue I have is in setting up and reading the eTPU for QD input.

I use the following to init the eTPU for QD input.

fs_etpu_qd_init(GPIO_ENC_A,
0,
0,
FS_ETPU_QD_PRIM_SEC,
FS_ETPU_PRIORITY_MIDDLE,
0,
FS_ETPU_TCR1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

I then call this function to read the value and it hangs from this point and never returns.

Count = fs_etpu_qd_get_pc(GPIO_ENC_A);

Any ideas what else I need to do to get this to work as there are no examples of using the eTPU or quadrature inputs?

Cheers,
Dave...
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Quadrature input with the eTPU

Post by v8dave »

OK, been doing some debugging and getting something strange in this function call.

int24_t fs_etpu_qd_get_pc( uint8_t channel_primary)
{
return(fs_etpu_get_chan_local_24s(channel_primary, FS_ETPU_QD_PC_OFFSET));
}

The call to fs_etpu_get_chan_local_24s does return, but when this function goes to return it hangs!!

I thought it was a stack issue and increased the size in the task that this call is made to 1024 in size but still same issue.

Need to delve a little more into the stack before and after this call.!!

Dave...
Walter
Posts: 2
Joined: Thu Apr 29, 2010 9:26 am

Re: Quadrature input with the eTPU

Post by Walter »

I can probably help. We created the tools that generated teh frescale libraries.

Walter@bytecraft.com

Send me more details for the question or post them here.

Thanks
w..
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Quadrature input with the eTPU

Post by v8dave »

Hi Walter,

I sorted the crash. I made the usual mistake with pointers and passed in the value instead of a pointer to it. Oops.

Still not getting any counts but that might be the configuration. Maybe you can help with this. This is what I have for config. The encoder is 30ppr.

fs_etpu_qd_init(GPIO_ENC_A,
0,
0,
FS_ETPU_QD_PRIM_SEC,
FS_ETPU_PRIORITY_MIDDLE,
0,
FS_ETPU_TCR1,
0, 0, 0, 0, 0,
0x733333,
0x8CCCCC, 0, 0, 0,
1000,
30);

fs_etpu_qd_set_pc(GPIO_ENC_A, 0);

fs_etpu_qd_disable(GPIO_ENC_A, 0, 0, 0);

fs_etpu_qd_enable(GPIO_ENC_A,
0,
0,
FS_ETPU_QD_PRIM_SEC,
FS_ETPU_PRIORITY_MIDDLE);

fs_etpu_qd_set_slow_mode(GPIO_ENC_A);


GPIO_ENC_A is set to 8 and I am using channels 8 & 9 for the inputs. I can see them toggling with the scope.

Cheers,
Dave...
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Quadrature input with the eTPU

Post by v8dave »

It would appear that the Quadrature decoder is not included with the NNDK set that gets loaded into the eTPU.

There is another set for this but I see that it does not support UART and I need both UART and QD in the same set.!!


Off to do some more digging.

Dave...
v8dave
Posts: 333
Joined: Thu Dec 31, 2009 8:31 pm

Re: Quadrature input with the eTPU

Post by v8dave »

It's working.

I finally figured out that the standard build does not include quadrature as part of the eTPU so I went to the Freescale website and created my own custom eTPU build and now it works!!

Excellent!

Dave...
Post Reply