LPC4357 QEI not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC4357 QEI not working

Jump to solution
1,191 Views
garyaltenberg
Contributor II

I am using an LPC4357s QEI peripheral. I cannot get it working. I have read the user manual and see that there is not much to do except configure the input pins. I am not using the index pin. Only the phase A and B pins on PA_3 and PA_2. I have configure the pins as:

// PA_2 Encoder B
{0xA, 2, SCU_MODE_INACT | SCU_MODE_FUNC1},

// PA_3 Encoder A
{0xA, 3, SCU_MODE_INACT | SCU_MODE_FUNC1},

This is in the pinmuxing array with all the other pins that are working.

I initialize the QEI like this:

// Setup the QEI interface.
// Reset the counter.
Chip_Clock_Enable(CLK_MX_QEI);
Chip_RGU_TriggerReset(RGU_QEI_RST);
while (Chip_RGU_InReset(RGU_QEI_RST));

LPC_QEI->CONF |= 0x00;
LPC_QEI->MAXPOS = 4000000000;
LPC_QEI->FILTERPHA = 10;
LPC_QEI->FILTERPHB = 10;
LPC_QEI->FILTERINX = 10;
LPC_QEI->CON = 0x0f;

I have tried lots of other things but I only get zero when I read EncoderCount = LPC_QEI->POS;

I can see my encoder signals on a scope and they look good.

Thank you for any input anyone has.

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,174 Views
garyaltenberg
Contributor II

Hi XiangJun Rong,

Thank you for your reply. I do have code that reads the position register and it was always zero. I could even use the debugger and it was always zero.

I got it working! I first attempted to read the pins as GPIO inputs by changing the entries in my pinmuxing array to set the pins as function 0. It still wasn't working. Then I added calls to Chip_SCU_PinMuxSet for each pin setting them to function 0 in my main code. Then I could read the pins. Then I changed them to function 1 and now the QEI is working.

Chip_SCU_PinMuxSet(0xA, 2, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1);
Chip_SCU_PinMuxSet(0xA, 3, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1);

I have no idea why my entries in my pinmuxing array do not work. All the other pins I setup in that array work for Ethernet, USB, I2C, GPIOS, etc. all work. This is when I call:

Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));

I have this in the board_sysinit.c file.

Here are the two entries for the encoder PHA and PHB on pins PA_3 and PA_2.

// PA_2 Encoder B GPIO4[9].
{0xA, 2, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1},

// PA_3 Encoder A GPIO4[10]
{0xA, 3, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1},

Any idea why this would not work when all the other pins I setup do?

Thank you,

Gary Altenberg

 

View solution in original post

0 Kudos
Reply
3 Replies
1,182 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think your code is correct. If you check the LPC_QEI->POS register in debugger with the PHA/PHB signal available, can you see if the LPC_QEI->POS register change or not?

BR

XiangJun Rong

0 Kudos
Reply
1,175 Views
garyaltenberg
Contributor II

Hi XiangJun Rong,

Thank you for your reply. I do have code that reads the position register and it was always zero. I could even use the debugger and it was always zero.

I got it working! I first attempted to read the pins as GPIO inputs by changing the entries in my pinmuxing array to set the pins as function 0. It still wasn't working. Then I added calls to Chip_SCU_PinMuxSet for each pin setting them to function 0 in my main code. Then I could read the pins. Then I changed them to function 1 and now the QEI is working.

Chip_SCU_PinMuxSet(0xA, 2, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1);
Chip_SCU_PinMuxSet(0xA, 3, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1);

I have no idea why my entries in my pinmuxing array do not work. All the other pins I setup in that array work for Ethernet, USB, I2C, GPIOS, etc. all work. This is when I call:

Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));

I have this in the board_sysinit.c file.

Here are the two entries for the encoder PHA and PHB on pins PA_3 and PA_2.

// PA_2 Encoder B GPIO4[9].
{0xA, 2, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1},

// PA_3 Encoder A GPIO4[10]
{0xA, 3, SCU_MODE_INBUFF_EN | SCU_MODE_ZIF_DIS | SCU_MODE_PULLUP | SCU_MODE_FUNC1},

Any idea why this would not work when all the other pins I setup do?

Thank you,

Gary Altenberg

 

0 Kudos
Reply
1,166 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Good news that you use the Chip_SCU_PinMuxSet() function to assign the pins as it's function successfully. For your array implementation, pls check the corresponding SPSPA_2 and SPSPA_3 register in debugger  if you have written them correctly.

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply