View previous topic :: View next topic |
Author |
Message |
link555
Joined: 29 Jul 2010 Posts: 14 Location: North Vancouver
|
Using QEI with dsPIC30F2010 |
Posted: Tue Nov 01, 2016 8:57 am |
|
|
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: 19552
|
|
Posted: Tue Nov 01, 2016 9:54 am |
|
|
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
|
|
Posted: Tue Nov 01, 2016 1:20 pm |
|
|
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: 19552
|
|
Posted: Tue Nov 01, 2016 2:36 pm |
|
|
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
|
|
Posted: Tue Nov 01, 2016 3:30 pm |
|
|
I will do that. thanks again. |
|
|
link555
Joined: 29 Jul 2010 Posts: 14 Location: North Vancouver
|
|
Posted: Tue Nov 01, 2016 10:41 pm |
|
|
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: 19552
|
|
Posted: Wed Nov 02, 2016 1:19 am |
|
|
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: 19552
|
|
Posted: Wed Nov 02, 2016 4:03 am |
|
|
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?. |
|
|
|