Identify interrupt source from Input Capture XORed pins

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

Identify interrupt source from Input Capture XORed pins

892 Views
denis_dantas
Contributor II

Hi, I'm using the MC9S12ZVM256 MCU. I'm trying to use the input capture with ports PT1, PT2 and PT3 XORed (as explained in chapter 1.13.5.1 of the Datasheet MC9S12ZVM-Family Reference Manual and Datasheet). The difference is that instead of using the MCU to control a BLDC, I'm using it to control two brushed DC motors.

I'd like to know if by having the PT1-3 ports XORed would it be possible to identify which pin generated a rising (or following) edge interrupt? Since I'm connecting each motor hall sensor to each of those pins, I need to know which hall signal generated the interrupt.

My first attempt was reading the PTT data register inside the interrupt, but it seems that the interrupt service is so fast that the PTT register is not updated in time to make a comparison between last state of the pins and the current state.

Best Regards,

Denis

0 Kudos
3 Replies

667 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Denis,
Could you read PTIT input register instead of PTT data register?
3-Phase Hall Sensor BLDC S12ZVM Application reads PTIT in TIMch1_ISR.

Regards,
Daniel

0 Kudos

667 Views
denis_dantas
Contributor II

Hi Daniel, it still doesn't work. Bellow is a summirized version of my code. Basically result is never true, it's only true when I play with the debugger and put breakpoints on this function.

uint8 digitalStatus = 0;

uint8 IdentifySource(void)
{
    uint8 result = false;
    if (_PTIT.Bits.PTIT2 == 1 && 0 == digitalStatus)
    {

        result = true;
    }

    digitalStatus = _PTIT.Bits.PTIT2;
 

    return result;
}

0 Kudos

667 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

The PTIT register gives the current state of the pins.

There is only delay between the IC1 event and the PTIT reading.   

I think the only explanation is that the states of the pins have already changed.

I would set high priority of the commutation interrupt.

 

Regards,

Daniel

0 Kudos