CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using QEI with dsPIC30F2010

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
link555



Joined: 29 Jul 2010
Posts: 14
Location: North Vancouver

View user's profile Send private message

Using QEI with dsPIC30F2010
PostPosted: Tue Nov 01, 2016 8:57 am     Reply with quote

When you call the setup_qei( ) routine, does it auto assign 3 pins (QEA,QEB and INDX)?

I have an encoder that does not have a Index output, I would like to use this the INDX(Pin5) on the dsPIC30F2010 for something else.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Tue Nov 01, 2016 9:54 am     Reply with quote

Start by looking at the data sheet. QEA, and QEB, are required, so 'yes' these will be allocated. However the index, can be used to reset the count based on the setting in the QEIM bits. If you then look at the CCS defines for the QEI settings, you will see that QEI_RESET_WHEN_IDX_PULSE, is an option.
Obviously you have to work out your own way of resetting the counter (you can do this on a count, or from another source), but the index pin should be available if you don't select this option.
link555



Joined: 29 Jul 2010
Posts: 14
Location: North Vancouver

View user's profile Send private message

PostPosted: Tue Nov 01, 2016 1:20 pm     Reply with quote

Thank you, I was just wondering where in the set_up routine it sets the ADPCFG to a digital input for the index pin. My suspicion is that it sets all three as (QEA, QEB and Index) as inputs. As your advice indicates, I avoided using any references with the IDX pin, but pin 5(IDX) still got affected. I have a LCD being driven from that pin....

Thank you for your input.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Tue Nov 01, 2016 2:36 pm     Reply with quote

I've never had any problem, but on a port used for something like QEI, I'd generally use 'FAST_IO', and make sure I have setup the TRIS myself. I'd suggest you do this.
link555



Joined: 29 Jul 2010
Posts: 14
Location: North Vancouver

View user's profile Send private message

PostPosted: Tue Nov 01, 2016 3:30 pm     Reply with quote

I will do that. thanks again.
link555



Joined: 29 Jul 2010
Posts: 14
Location: North Vancouver

View user's profile Send private message

PostPosted: Tue Nov 01, 2016 10:41 pm     Reply with quote

I checked I used fixed I/o...no dice.....so I moved the LCD off of that Idx pin for now. Otherwise the qei function works great.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Wed Nov 02, 2016 1:19 am     Reply with quote

FIXED_IO, is _not_ the same as FAST_IO.

With FIXED_IO, though you specify the I/O you want, the compiler will still set the TRIS on every I/O occasion, and will override this with it's own settings. With FAST_IO, no compiler overriding is done, and it becomes your responsibility to set everything.

Tell us your compiler version?. I'll check what your compiler does for the index pin on your version.
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Wed Nov 02, 2016 4:03 am     Reply with quote

Just tested on a PIC30F3011 (nearest chip I have to yours), and I can merrily output to the INDX pin.

Was running:
Code:

setup_qei(QEI_MODE_X4 | QEI_RESET_WHEN_MAXCOUNT, QEI_FILTER_DIV_4, 40000);

and simply 'output_toggle(PIN_B3);', happily toggles the pin.

What setup are you using for the QEI?. What does your LCD driver try to do to the pin?.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group