Beispiel #1
0
// perform the counting functions for pin 12
void __ISR( _EXTERNAL_2_VECTOR , ipl2) INT2Interrupt( void) {
	if (ExtCurrentConfig[12] == EXT_PER_IN) {
		INT2Value = INT2Count;
		INT2Count = 0;
	} else INT2Count++;
	mINT2ClearIntFlag();    										// Clear the interrupt flag
	return;
}
Beispiel #2
0
/* Specify interupt priority 1, but stop the interupt once detected */
void __ISR(_EXTERNAL_2_VECTOR, IPL1) _Int2Handler(void) {

    uint state = getState();
    if(STATE_BEGINING == state)
    {
        /* STEP 1. configure the Timer1*/
        mT1ClearIntFlag();
        OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, 64000);
        /* STEP 2. set the timer interrupt to prioirty level 2 */
        ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
        writeBit(1);
        writeBit(1);
        setState(STATE_FIRST_EDGE);
    }
    else if( STATE_FIRST_EDGE == state)
    {
          ConfigIntTimer1(T1_INT_OFF);
          setEtu(ReadTimer1()/3);
          OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, getEtu()/5);
          /* STEP 2. set the timer interrupt to prioirty level 2 */
          ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
          /*Stopping the timer 1 and reading the value*/
          DisableINT2;
          
          /*the two first bits of ts are sets*/
          setState(STATE_TS);
          bitIndex = 10 ;
    }
    else
    {
        /* state == normal processing or no atr but an etu value is set*/
          DisableINT2;
          OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, getEtu());
          ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
    }
     /* The flag is cleared at the end to avoid stack overflow
    * PORTDbits.RD0 is the EXTERNAL_0_VECTOR*/

    mINT2ClearIntFlag();
}
void __ISR(_EXTERNAL_2_VECTOR, ipl1) _Interrupt_XY_Limit(void)
{
    unsigned int temp;

    temp = mPORTCRead();
    
    if(temp & xLimitInput.pin)
    {
        xLimitDetected = TRUE;
        BSP_AxisDisable(X_AXIS);
        //BSP_Timer2Stop();
    }
    if(temp & yLimitInput.pin)
    {
        yLimitDetected = TRUE;
        BSP_AxisDisable(Y_AXIS);
        //BSP_Timer2Stop();
    }

    /* Clear the interrupt flag */
    mINT2ClearIntFlag();


}