AnsweredAssumed Answered

Rotary mode with GPT of MPC5121e don't work

Question asked by David ALVES DE SOUSA on Apr 20, 2016
Latest reply on Apr 26, 2016 by David ALVES DE SOUSA

Hello,

 

I develop an application whose need to interface an rotary sensor that generate these signals bellow:

 

These signals are used to determinate the RPM and the direction of rotation of wheel. So on MPC5121e I want to use one pair of GPT timer: GPT2 and GPT3, respectively on PSC10_4 and PSC11_4 pins.

 

for the first test I generate the two signals with simple push button and deglitching circuit connected on PSC10_4 and PSC11_4.

 

From reference manual I write a code that to do :

 

Define IOCONTROL_BASE = IMMRBAR + 0xA000

Define GPT_BASE = IMMRBAR + 0x0B00

CONFIGURE I/O

Write 0x0000_0183 into STD_PSC10_4 @(IOCONTROL_BASE + 0x2E4)

Write 0x0000_0183 into STD_PSC11_4 @(IOCONTROL_BASE + 0x2F8)

Set timer mode

Write 0x000D_0400 into GPT2_MODE @(GPT_BASE + 0x20)

Write 0x000C_0400 into GPT3_MODE @(GPT_BASE + 0x30)

Set COUNTER

Write 0x0001_0000 into GPT2_COUNTER @(GPT_BASE + 0x24)

Write 0x0001_0000 into GPT3_COUNTER @(GPT_BASE + 0x34)

Set PWM

Write 0x0000_0000 into GPT2_PWM @(GPT_BASE + x028)

Write 0x0000_0000 into GPT3_PWM @(GPT_BASE + x038)

Clear STATUS

Write 0x0000_001F into GPT2_STATUS @(GPT_BASE + 0x2C)

Write 0x0000_001F into GPT3_STATUS @(GPT_BASE + 0x3C)

Enable timers

Write 0x000D_1401 into GPT2_MODE @(GPT_BASE + 0x20)

Write 0x000C_1401 into GPT3_MODE (GPT_BASE + 0x20)

 

At this point my program is in pause, and I generate 1~10 pulses on ODO_1 with ODO_2 at 0.

 

And when with my program I want to read CAPTURE into GPT2_STATUS (CAPTURE = (@(GPT_BASE+0x2C) >> 16) &0xFFFF), I have CAPTURE randomly equal to 0~65535 instead of to have CAPTURE equal to 1~10.

 

David

Outcomes