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 22.214.171.124 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.
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 result = false;
if (_PTIT.Bits.PTIT2 == 1 && 0 == digitalStatus)
result = true;
digitalStatus = _PTIT.Bits.PTIT2;
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.