Interrupt with button

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Interrupt with button

1,054件の閲覧回数
437000534
Contributor I

How to do a button interrupt based on S12ZVML12EVB .Is there a isr vector for key or button?Because I can not find it.And I want to apply this to change the duty cycle.I would appreciate it if anyone can give me some tipps.

0 件の賞賛
返信
2 返答(返信)

963件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

There are two push buttons on the oard connected to PP1 and PP2 via  jumpers J19 and J20. they are pulled up so interrupt you should implement should be low level value or falling edge.

Port P has interrrupt has interrupt vector 0xFFFF0C [hex] or vector number 60 [dec].

The routine can look, for axample:

 

 

* Copyright 2019 NXP

*

* Redistribution and use in source and binary forms, with or without

* modification, are permitted provided that the following conditions are met:

*

* * Redistributions of source code must retain the above copyright notice,

* this list of conditions and the following disclaimer.

*

* * Redistributions in binary form must reproduce the above copyright notice,

* this list of conditions and the following disclaimer in the documentation

* and/or other materials provided with the distribution.

*

* Neither the name of NXP nor the names of its contributors may be used

* to endorse or promote products derived from this software without

* specific prior written permission.

*

*

* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND

* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.

* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,

* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,

* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF

* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE

* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF

* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 

 

#pragma CODE_SEG NON_BANKED

interrupt void PORTP_ISR( void ) // vector defined in the prm file

{

  unsigned int i, j;

  unsigned char status;

 

  status = PIFP;                              // store PIFP

  PIFP = 0xFF;                              // clear all port P flags

 

  if( ( PIEP & PIEP_PIEP1_MASK ) && ( status & PIFP_PIFP1_MASK ) )  // PTP1 interrupt

    {      // do something if necessary      

    }

  if( ( PIEP & PIEP_PIEP2_MASK ) && ( status & PIFP_PIFP2_MASK ) )  // PTP2 interrupt

    {

      // do something if necessary      

    }

 

}

#pragma CODE_SEG DEFAULT

 

….and setup for example:

 

//=== PORT P SETUP FOR FALLING EDGE INTERRUTP ===

DDRP_DDRP1 = 0;                 // input pin

PERP_PERP1 = 1;                  // pull device enabled

PPSP_PPSP1 = 0;                   // pull up device, falling edge selected

PIFP_PIFP1 = 1;                     // clear flag

PIEP_PIEP1 = 1;                    // enable interrupt

 

DDRP_DDRP2 = 0;                 // input pin

PERP_PERP2 = 1;                  // pull device enabled

PPSP_PPSP2 = 0;                   // pull up device, falling edge selected

PIFP_PIFP2 = 1;                     // clear flag

PIEP_PIEP2 = 1;                    // enable interrupt

 

 

…..and global enable of interrupts

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

EnableIinterrupts;   // or asm CLI

There are two possible ways of interrupt definition. Either by definition of vector function in the PRM file, which is used in above mentioned code....

VECTOR 0 _Startup /* reset vector: this is the default entry point for a C/C++ application. */
//VECTOR 0 Entry  /* reset vector: this is the default entry point for an Assembly application. */
//INIT Entry      /* for assembly applications: that this is as well the initialization entry point */

VECTOR   1   SPARE_ISR                        
VECTOR   2   TRAP_ISR                         
VECTOR   3   SWI_ISR                          
VECTOR   4   SYS_ISR                          
VECTOR   5   MachineException_ISR             
VECTOR   6   Dummy_6_ISR                      
VECTOR   7   Dummy_7_ISR                      
VECTOR   8   Spurious_ISR                     
VECTOR   9   XIRQ_ISR                         
VECTOR  10   IRQ_ISR                          
VECTOR  11   RTI_TimeOut_ISR                  
VECTOR  12   TIM0_Channel0_ISR                
VECTOR  13   TIM0_Channel1_ISR                
VECTOR  14   TIM0_Channel2_ISR                
VECTOR  15   TIM0_Channel3_ISR                
VECTOR  16   Dummy_16_ISR                     
VECTOR  17   Dummy_17_ISR                     
VECTOR  18   Dummy_18_ISR                     
VECTOR  19   Dummy_19_ISR                     
VECTOR  20   TIM0_Overflow_ISR                
VECTOR  21   Dummy_21_ISR                     
VECTOR  22   Dummy_22_ISR                     
VECTOR  23   SPI0_ISR                         
VECTOR  24   SCI0_ISR                         
VECTOR  25   SCI1_ISR                         
VECTOR  26   Dummy_26_ISR                     
VECTOR  27   Dummy_27_ISR                     
VECTOR  28   ADC0_Error_ISR                   
VECTOR  29   ADC0_ConversionSequenceAbort_ISR
VECTOR  30   ADC0_ConversionComplete_ISR      
VECTOR  31   OSCILLATOR_Status_ISR            
VECTOR  32   PLL_Lock_ISR                     
VECTOR  33   Dummy_33_ISR                     
VECTOR  34   Dummy_34_ISR                     
VECTOR  35   RAM_Error_ISR                    
VECTOR  36   Dummy_36_ISR                     
VECTOR  37   Dummy_37_ISR                     
VECTOR  38   FLASH_Error_ISR                  
VECTOR  39   FLASH_Command_ISR                
VECTOR  40   CAN0_WakeUp_ISR                  
VECTOR  41   CAN0_Errors_ISR                  
VECTOR  42   CAN0_Receive_ISR                 
VECTOR  43   CAN0_Transmit_ISR                
VECTOR  44   Dummy_44_ISR                     
VECTOR  45   Dummy_45_ISR                     
VECTOR  46   LINPHY_OverCurrent_ISR           
VECTOR  47   BATS_SupplyVoltageMonitor_ISR    
VECTOR  48   GDU_DesaturationError_ISR        
VECTOR  49   GDU_VoltageLimitDetected_ISR     
VECTOR  50   Dummy_50_ISR                     
VECTOR  51   Dummy_51_ISR                     
VECTOR  52   Dummy_52_ISR                     
VECTOR  53   Dummy_53_ISR                     
VECTOR  54   PORTS_ISR                        
VECTOR  55   Dummy_55_ISR                     
VECTOR  56   ADC1_Error_ISR                   
VECTOR  57   ADC1_ConversionSequenceAbort_ISR
VECTOR  58   ADC1_ConversionComplete_ISR      
VECTOR  59   Dummy_59_ISR                     
VECTOR  60   PORTP_ISR                        
VECTOR  61   EVDD1_OverCurrent_ISR            
VECTOR  62   LVI_ISR                          
VECTOR  63   API_ISR                          
VECTOR  64   HighTemperature_ISR              
VECTOR  65   Dummy_65_ISR                     
VECTOR  66   PortAD_ISR                       
VECTOR  67   PTU_ReloadOverrun_ISR            
VECTOR  68   PTU_Trigger0Error_ISR            
VECTOR  69   PTU_Trigger1Error_ISR            
VECTOR  70   PTU_Trigger0Done_ISR             
VECTOR  71   PTU_Trigger1Done_ISR             
VECTOR  72   Dummy_72_ISR                     
VECTOR  73   Dummy_73_ISR                     
VECTOR  74   Dummy_74_ISR                     
VECTOR  75   PMF_ReloadA_ISR                  
VECTOR  76   PMF_ReloadB_ISR                  
VECTOR  77   PMF_ReloadC_ISR                  
VECTOR  78   PMF_Fault_ISR                    
VECTOR  79   PMF_Reload_overrun_ISR           

....or simply:

#pragma CODE_SEG NON_BANKED

interrupt 60 void PORTP_ISR( void ) //

{

  unsigned int i, j;

  unsigned char status;

 

  status = PIFP;                              // store PIFP

  PIFP = 0xFF;                              // clear all port P flags

 

  if( ( PIEP & PIEP_PIEP1_MASK ) && ( status & PIFP_PIFP1_MASK ) )  // PTP1 interrupt

    {      // do something if necessary      

    }

  if( ( PIEP & PIEP_PIEP2_MASK ) && ( status & PIFP_PIFP2_MASK ) )  // PTP2 interrupt

    {

      // do something if necessary      

    }

 

}

#pragma CODE_SEG DEFAULT

 

Best regards,

Ladislav

0 件の賞賛
返信

963件の閲覧回数
437000534
Contributor I

That ist really a big help for me.Thanks again!!!

0 件の賞賛
返信