PP1_KWP1_PWM1_IRQ rising edge not working!

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

PP1_KWP1_PWM1_IRQ rising edge not working!

Jump to solution
1,358 Views
manishsangram
Contributor IV

Hi,

We are using S12ZVMC128 

The documentation is very confusing and probably misleading in that it does not state in any of usual reference places that PP1_KWP1_PWM1_IRQ does not support rising edge interrupt. 

We have selected this pin for Interrupt IO and used processor expert to generate code. Already our hardware is designed and the board has this pin mapped to a port that is used as a switch so we can't change this.

We found that we were only getting falling edge and not getting rising edge interrupt so we checked the code by PE and found the code be different from usual code. It had generated a SetEdge function, which we use to switch from falling to rising edge but here is switching from falling to low edge.

All the reference does not highlight this except when you look at the IRQCR which is the last thing we looked at.

Now we want to know is it possible to get the rising edge interrupt on this PP1 pin or NOT??? This will require us to make new boards!!!

References we looked at MC9S12ZVM Family Reference Manual Rev. 2.5

Page 56

60 PP1 KWP1 PWM1_1 PWM0_1 IRQ — — — VDDX PPRP/PPSPOff

Page 110 Table 2-7 Port P Pin Functions and Priorities

PTP[1]/KWP[1] I/O General-purpose; with interrupt and wakeup

This is critical and urgent issue for us now.

0 Kudos
1 Solution
1,052 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

Following simple code will show you it is working correctly. I can catch both falling and rising edge. The pin PTS.4 follows edge at PTP.1. As you can see I toggle edge type setup in the interrupt to be able to get bot edges. Note; it is normal to be not possible to set interrupt on both edge types because this pin does not provide such a feature. If you want to be able both types you have to solve it by SW.

Entire project is attached.

/*******************************************************************************

Port PTP.1 ISR - mirror edge type from PTP.1 to PTS.4

- the edge type setup is toggled to be able to get both edge types interrupt at

  one pin.

 *******************************************************************************/

#pragma CODE_SEG NON_BANKED

interrupt void PORTP_ISR( void ) // vector defined in the prm file and removed from InterruptVectorTable.c

{

  // either this line

  //  PTS_PTS4   = PPSP_PPSP1;  // show edge  I’ve just caught

  // or this line

  PTS_PTS4   = PTP_PTP1;  // show edge  I’ve just caught

  PPSP_PPSP1 = !PPSP_PPSP1; // 0/1 = pull up/down = falling/rising edge selected

  PIFP       = 0x02;        // clear PP1         interrupt flag only

}

#pragma CODE_SEG DEFAULT

/*******************************************************************************

 * Main function

 *******************************************************************************/

void main( void )

{

  //=== CLOCK and COP INIT =======

  CPMU_Init();                    //BUSCLK for 30MHz from internal oscillator

  //=== PORT PTS.4 SETUP =========

  DDRS_DDRS4 = 1; // an output port

  PTS_PTS4   = 0; // diode off

  //=== PORT PTP.1 SETUP =========

  DDRP_DDRP1 = 0;           // an input port

  PPSP_PPSP1 = 0;           // 0/1 = pull up/down = falling/rising edge selected

  PIEP_PIEP1 = 1;           // interrupt is enabled

  PIFP       = 0x02;        // clear PP1         interrupt flag only

  //=== ENABLE INTERRUPTS ========

  EnableInterrupts;

  // DisableInterrupts;

  //=== NEVERENDIG LOOP ==========

  for(;;)

   {

    asm nop;

   }

  //==============================

}

pastedImage_1.jpg

yellow: input signal from a pulse generator to PTP.1.

blue: PTS.4... mirror signal PTP.1 in the interrupt routine from PTP.1. Edge recognition is changed in the interrupt subroutine.

Best regards,

Ladislav

View solution in original post

7 Replies
1,052 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

Finally, I have presented this issue to a CodeWarrior application team. It looks like bug in the CW.

However you still have possibility to program it yourself out of the Processor Expert.

Best regards,

Ladislav

0 Kudos
1,053 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

Following simple code will show you it is working correctly. I can catch both falling and rising edge. The pin PTS.4 follows edge at PTP.1. As you can see I toggle edge type setup in the interrupt to be able to get bot edges. Note; it is normal to be not possible to set interrupt on both edge types because this pin does not provide such a feature. If you want to be able both types you have to solve it by SW.

Entire project is attached.

/*******************************************************************************

Port PTP.1 ISR - mirror edge type from PTP.1 to PTS.4

- the edge type setup is toggled to be able to get both edge types interrupt at

  one pin.

 *******************************************************************************/

#pragma CODE_SEG NON_BANKED

interrupt void PORTP_ISR( void ) // vector defined in the prm file and removed from InterruptVectorTable.c

{

  // either this line

  //  PTS_PTS4   = PPSP_PPSP1;  // show edge  I’ve just caught

  // or this line

  PTS_PTS4   = PTP_PTP1;  // show edge  I’ve just caught

  PPSP_PPSP1 = !PPSP_PPSP1; // 0/1 = pull up/down = falling/rising edge selected

  PIFP       = 0x02;        // clear PP1         interrupt flag only

}

#pragma CODE_SEG DEFAULT

/*******************************************************************************

 * Main function

 *******************************************************************************/

void main( void )

{

  //=== CLOCK and COP INIT =======

  CPMU_Init();                    //BUSCLK for 30MHz from internal oscillator

  //=== PORT PTS.4 SETUP =========

  DDRS_DDRS4 = 1; // an output port

  PTS_PTS4   = 0; // diode off

  //=== PORT PTP.1 SETUP =========

  DDRP_DDRP1 = 0;           // an input port

  PPSP_PPSP1 = 0;           // 0/1 = pull up/down = falling/rising edge selected

  PIEP_PIEP1 = 1;           // interrupt is enabled

  PIFP       = 0x02;        // clear PP1         interrupt flag only

  //=== ENABLE INTERRUPTS ========

  EnableInterrupts;

  // DisableInterrupts;

  //=== NEVERENDIG LOOP ==========

  for(;;)

   {

    asm nop;

   }

  //==============================

}

pastedImage_1.jpg

yellow: input signal from a pulse generator to PTP.1.

blue: PTS.4... mirror signal PTP.1 in the interrupt routine from PTP.1. Edge recognition is changed in the interrupt subroutine.

Best regards,

Ladislav

1,052 Views
manishsangram
Contributor IV

We got it to work now. The reason our previous attempt to code it manually had failed is because we did not realise that PE had mapped Virq instead of Vportp for this and thus our attempts at changing code externally was not having any effect. After your reply we carefully analysed and found this problem which we further manually modified. 

0 Kudos
1,052 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

I am really happy you found the issue. This is standard issue if something is enabled out of our control. Because of this I, as an old school engineer/programmer prefer my own setup and routines. It is easier to debug own code.

Best regards,

Ladislav

0 Kudos
1,052 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

I would like to ask you to do not take following as offensive expression but I am not absolutely sure I understand what is confusing in the description. If you think it could be adjusted or change I would like to ask you for suggestion to be able to provide it to a documentation team.

The data sheet states:

2.3.3.5 Polarity Select Register

PPSx7-0....Pull Polarity Select — Configure pull device and pin interrupt edge polarity on input pin
This bit selects a pullup or a pulldown device if enabled on the associated port input pin.
If a port has interrupt functionality this bit also selects the polarity of the active edge.
If MSCAN is active a pullup device can be activated on the RXCAN input; attempting to select a pulldown disables
the pull-device.
1 Pulldown device selected; rising edge selected
0 Pullup device selected; falling edge selected

So, if you want to get rising and falling edges you have to:

- either toggle polarity select bit in the interrupt considering the the period between the two edges.....I mean whether some of them will not be lost before leaving the interrupt routine. You can also check the status of the bit before leaving the interrupt to check whether the status is the same,...I do not want to think about all things which could happen because I do not know frequency of input pulse changes.

- or split input signal and connect it also to another input pin when one is set for rising and the second one for falling edge.

- you can also use timer to get both edges in input capture mode if it is not used for another purpose. You will ignore captured value, just will use interrupt response.

Best regards,

Ladislav

0 Kudos
1,052 Views
manishsangram
Contributor IV

Dear Ladislav,

No offence taken at all but please understand that we are not that naive to not have read or understand already what you have pointed out above!!!

We are already using rising and falling edges on various other pins so we know what we are talking about !

PP1 does NOT seem to have rising edge as an option. PPS is giving us a PULL UP and PULL DOWN, but the rising edge interrupt is not available. Please check this practically and let us know if you succeed.

For your convenience I am attaching the PE screenshot AND we tried without PE also by directly coding the registers.

 

PP1-Rising.jpg

0 Kudos
1,052 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

I'll check tomorrow. I do not use processor expert when testing the device.

I am suspicious to any tool which provides final solutions because I have met a lot of mistakes in such a tools. However, I hope we will find the root cause.

Best regards,

Ladislav

0 Kudos