Exemple #1
0
//*	not done yet
//************************************************************************
void __ISR(_TIMER_1_VECTOR, _T1_IPL_ISR) Timer1Handler(void)
{

	if (timer1_toggle_count != 0)
	{
		// toggle the pin
		// The PORTxINV register is at offset +3 from the PORTx register
		//*(tone_pin_port+3)	=	tone_pin_mask;
		tone_pin_port->lat.inv = tone_pin_mask;

		if (timer1_toggle_count > 0)
		{
			timer1_toggle_count--;
		}
	}
	else
	{
		disableTimer(1);
		// The PORTxCLR register is at offset +1 from the PORTx register
		//*(tone_pin_port+1)	=	tone_pin_mask;	// keep pin low after stop
		tone_pin_port->lat.clr = tone_pin_mask;
	}

	// clear the interrupt flag
	mT1ClearIntFlag();
}
void __ISR(_TIMER_1_VECTOR, ipl2) _Timer1Handler(void)
{
  // this interrupt should fire every 1 ms
  static int blinkRemainingUs = 0;
  static int adcRemainingUs = 0;
  static int stepRemainingUs = 0;
  static int printRemainingUs = PRINT_INTERVAL_MS * 1000;

  blinkRemainingUs -= clock_interrupt_period_us;
  if (blinkRemainingUs <= 0) {
    LED = 1 - LED;
    blinkRemainingUs = LED_BLINK_PERIOD_MS * 1000;
  }
 
  adcRemainingUs -= clock_interrupt_period_us;
  if (adcRemainingUs <= 0) {
    enableADC = 1;
    AD1CON1bits.ASAM = 1;
    adcRemainingUs = ADC_INTERVAL_MS * 1000;
  }
  
  stepRemainingUs -= clock_interrupt_period_us;
  if (stepRemainingUs <= 0) {
    enableStep = 1;
    stepRemainingUs = stepper_interval_us;
  }

  printRemainingUs -= clock_interrupt_period_us;
  if (printRemainingUs <= 0) {
    enablePrint = 1;
    printRemainingUs = PRINT_INTERVAL_MS * 1000;
  }

  mT1ClearIntFlag(); // clear the interrupt flag
}
void init_interrup1(void){
    // init interrupts,
    mT1SetIntPriority( 1);
    mT1ClearIntFlag();
    INTEnableSystemSingleVectoredInt();
    mT1IntEnable( 1);
}
Exemple #4
0
void InterruptHandler( void)
{
    if(count>29)// test effectué 30 fois -> 30 fois sec = ~5mn
    {
        PORTA=0x00; // led4 off
        count=1;    // reset du compteur
        mT1ClearIntFlag();
    }
    else
    {
        count ++;
        mT1ClearIntFlag();
    }

// interrupt service routine code here. . .
} // interrupt handler
Exemple #5
0
/* Specify Interrupt Priority Level = 2 */
void __ISR(_TIMER_1_VECTOR, IPL2) _Timer1Handler(void) {

    mT1ClearIntFlag();
    if(bitIndex == 0)
    {
        
        OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, (getEtu()/5));
        write(PIN_IO);
        bitIndex++;
    }
    else if(bitIndex == 39)
    {
        write(PIN_IO);
        bitIndex++;
        setFlag();
    }
    else if(bitIndex == 40)
    {
        bitIndex =0;
        ConfigINT2(EXT_INT_ENABLE | FALLING_EDGE_INT | EXT_INT_PRI_1);
        ConfigIntTimer1(T1_INT_OFF);
    }
    else
    {
        write(PIN_IO);
        bitIndex++;
    }
}
Exemple #6
0
void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
{
    // clear the interrupt flag
    mT1ClearIntFlag();

    // .. things to do
    rt_hw_timer_handler();
}
Exemple #7
0
//void __ISR(_TIMER_1_VECTOR, TICKIPL) Timer1Handler(void)
void __ISR(_TIMER_1_VECTOR, IPL7AUTO) Timer1Handler(void)
{
        //mPORTDToggleBits(BIT_3);
	uint32_t before = TickGetLower();
	dwInternalTicks+=TICKS_PER_SECOND/TOGGLES_PER_SEC;
	if(TickGetLower()<before){
		dwInternalTicks=0;
		dwInternalTicksUpper++;
	}
	mT1ClearIntFlag();
	//println("@%@%@%@%Tick");
}
Exemple #8
0
//************************************************************************
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
{
uint32_t tonePeriod;
uint8_t port;

	// Should have an error check here for pin number out of range.
	//*	there is no standard on the number of pins. Since we want this to work on all versions of the PIC32
	//*	I have set it to 112 for now which is the largest I/O pin count on a pic32
	if ((frequency > 0) && (_pin < 112))
	{
			
		// If a tone is currently playing on a different pin, the function is
		// documented to have no effect. If playing on the same pin, change
		// the frequency. If not currently playing, initialize the timer.
		// This is currently hard coded to use timer1.
		if (tone_pin == 255)
		{
			// No tone currently playing. Init the timer.
			T1CON	=	T1_PS_1_256;
			mT1ClearIntFlag();
			ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_3 | T1_INT_SUB_PRIOR_1);
		}
		else if (_pin != tone_pin)
		{
			// Tone currently playing on another pin. ignore this call.
			return;
		}

		// Determine which port and bit are requested.
		tone_pin		=	_pin; 
		port			=	digitalPinToPort(_pin);
		tone_pin_port	=	portOutputRegister(port);
		tone_pin_mask	=	digitalPinToBitMask(_pin);

		// Ensure that the pin is a digital output
		pinMode(_pin, OUTPUT);

		// Duration 0 means to play forever until stopped. Other values
		// mean to play for that many milliseconds.
		if (duration > 0)
		{
			timer1_toggle_count	=	(2 * frequency * duration) / 1000;
		}
		else
		{
			timer1_toggle_count	=	-1;
		}

		TMR1		=	0;
		PR1			=	((F_CPU / 256) / 2 / frequency);
		T1CONSET	=	T1_ON;
	}
}
Exemple #9
0
/**********************************************************************
 * Function: Timer1IntHandler
 * @return none
 * @remark This is the interrupt handler to support the timer module.
     It will increment time, to maintain the functionality of the
     GetTime() timer and it will check through the active timers,
     decrementing each active timers count, if the count goes to 0, it
     will set the associated event flag and clear the active flag to
     prevent further counting.
 **********************************************************************/
void __ISR(_TIMER_1_VECTOR, ipl3) Timer1IntHandler(void) {
    mT1ClearIntFlag();
    freeRunningTimer++;
    char curTimer = 0;
    if (timerActiveFlags != 0) {
        for (curTimer = 0; curTimer < TIMER_NUMBER_MAX; curTimer++) {
            if ((timerActiveFlags & (1 << curTimer)) != 0) {
                if (--timerArray[curTimer] == 0) {
                    timerEventFlags |= (1 << curTimer);
                    timerActiveFlags &= ~(1 << curTimer);
                }
            }
        }
    }
} // ISR
Exemple #10
0
void __ISR(_TIMER_1_VECTOR, ipl3) Timer1IntHandler(void) {
    mT1ClearIntFlag();
    FreeRunningTimer++;
    char CurTimer = 0;
    if (TimerActiveFlags != 0) {
        for (CurTimer = 0; CurTimer < NUM_TIMERS; CurTimer++) {
            if ((TimerActiveFlags & (1 << CurTimer)) != 0) {
                if (--Timer_Array[CurTimer] == 0) {
                    TimerEventFlags |= (1 << CurTimer);
                    TimerActiveFlags &= ~(1 << CurTimer);
                }
            }
        }
    }
}
Exemple #11
0
void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void) {
  // clear the interrupt flag
  mT1ClearIntFlag();
  
  #ifdef DEBUG
//Detect overruns
 if (sysTickEvent) // main loop did not notice the last sysTickEvent
   missedMilliseconds++;
//or,
// sysTickEvent++; 
// in main loop, if sysTickEvent >1 then we missed milliseconds
//or,
// at end of main loop, assert sysTickEvent == 0
#endif
  sysTickEvent = 1;
}
Exemple #12
0
//Interrupt handler to read IR sensors
void __ISR(_TIMER_1_VECTOR, ipl2) _Timer1Handler(void)
{
    //Reset the flag
    mT1ClearIntFlag();

    if(readpins(0) > 700)   //left
		{
                    if(leftspeed < 305)
                        leftspeed++;
                    if(rightspeed > 285)
                        rightspeed--;
                    setpwmR(rightspeed);
                    setpwmL(leftspeed);
                    motorRfwd();
                    motorLfwd();
                }
                //for(i = 0; i < 500; i++){};

                //if (channel13 < 600)
                if(readpins(2) > 700) //right
		{
                    if(leftspeed > 275)
                        leftspeed--;
                    if(rightspeed < 315)
                        rightspeed++;
                    setpwmR(rightspeed);
                    setpwmL(leftspeed);
                    motorRfwd();
                    motorLfwd();
                }
                //for(i = 0; i < 500; i++){};

                //if (channel13 < 900)
                if(readpins(1) > 900) //middle
		{
                    setpwmR(0);
                    setpwmL(0);
                    motorRstop();
                    motorLstop();
                    turnright();

                }
                for(i = 0; i < 5000; i++){};


}
Exemple #13
0
void vPortIncrementTick( void )
{
unsigned portBASE_TYPE uxSavedStatus;

	uxSavedStatus = uxPortSetInterruptMaskFromISR();
		vTaskIncrementTick();
	vPortClearInterruptMaskFromISR( uxSavedStatus );
	
	/* If we are using the preemptive scheduler then we might want to select
	a different task to execute. */
	#if configUSE_PREEMPTION == 1
		SetCoreSW0();
	#endif /* configUSE_PREEMPTION */

	/* Clear timer 0 interrupt. */
	mT1ClearIntFlag();
}
Exemple #14
0
//*********************************************
//********* TIMER 1 interrupt handler *********
// Action: Test if RTC crystall is runing, like
// 		   Toglle LEDx with frequency 1Hz. 
//*********************************************
void __ISR(_TIMER_1_VECTOR, ipl3) Timer1Handler(void)
{
    // clear the interrupt flag
    mT1ClearIntFlag();
	LED0_IO ^= 1;	
	
	// Check and display LEDs status into Terminal
	USART_Test_Menu_Begin();
	if(PORTDbits.RD0){	
		USART_Send_String("\n\r        | LED1 |   ON   |  :)   ");
		USART_Send_Data(0X01);	// emoticon ASCII code
		USART_Send_String("  |");	
	}
	else{
		USART_Send_String("\n\r        | LED1 |   OFF  |  :(   ");
		USART_Send_Data(0X02);	// emoticon ASCII code
		USART_Send_String("  |");	
	}
	if(PORTDbits.RD1){	
		USART_Send_String("\n\r        | LED2 |   ON   |  :)   ");
		USART_Send_Data(0X01);	// emoticon ASCII code
		USART_Send_String("  |");	
	}
	else{
		USART_Send_String("\n\r        | LED2 |   OFF  |  :(   ");
		USART_Send_Data(0X02);	// emoticon ASCII code
		USART_Send_String("  |");	
	}
	if(PORTDbits.RD2){	
		USART_Send_String("\n\r        | LED3 |   ON   |  :)   ");
		USART_Send_Data(0X01);	// emoticon ASCII code
		USART_Send_String("  |");	
	}
	else{
		USART_Send_String("\n\r        | LED3 |   OFF  |  :(   ");
		USART_Send_Data(0X02);	// emoticon ASCII code
		USART_Send_String("  |");	
	}
	USART_Send_String("\n\r         ------ -------- ---------- \n\r");
}
Exemple #15
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();
}
Exemple #16
0
//=============================================
// Configure the Timer 1 interrupt handler
//=============================================
void __ISR(_TIMER_1_VECTOR, T1_INTERRUPT_PRIORITY) Timer1InterruptHandler(void)
{
  oTimerReg = 1;
  
  if (oTimerSetZero)
  {
    setZeroCounter++;
    if (setZeroCounter >= 21)
    {
      oSetZeroCounterOccured = 1;
    }
  }
  else
  {
    setZeroCounter = 0;
    oSetZeroCounterOccured = 0;
  }

  // Increment the number of overflows from this timer. Used primarily by Input Capture
  Timer.Var.nOverflows[0]++;

  mT1ClearIntFlag();
}
/* TIMER 1 Interrupt Handler - configured to 100us periods */
void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
{
    // clear the interrupt flag
    mT1ClearIntFlag();

	if (M1_counter != 0)
		M1_counter--;
	if (M2_counter != 0)
		M2_counter--;
	if (M3_counter != 0)
		M3_counter--;
	if (M4_counter != 0)
		M4_counter--;
	
	if (servo1_period != 0) {
		servo1_period--;
		if (servo1_period == (SERVOMAXPERIOD - servo1_counter))
			mPORTAClearBits(BIT_2);
	}
	if (servo2_period != 0) {
		servo2_period--;
		if (servo2_period == (SERVOMAXPERIOD - servo2_counter))
			mPORTAClearBits(BIT_3);
	}

	if(counterDistanceMeasure !=0)
		counterDistanceMeasure--;
	else {
		counterTrigger = 6;
		counterDistanceMeasure = 600;
	}


	if (auxcounter != 0)
		auxcounter--;
}
Exemple #18
0
/**
 * @function TmrLaunch
 * @brief enable a given timer, if this one is correctly configured
 * @param tmr_t tmr_id: timer id
 * @return none
 */
void TmrLaunch(tmr_t tmr_id) {
  switch(tmr_id) {
    case TMR_1:
      if(timer1Configured == 1 && tmr1PtrCallback != NULL) {
        mT1ClearIntFlag();
        T1CONSET = 0x8000;
      }
      break;
    case TMR_4:
      if(timer4Configured == 1 && tmr4PtrCallback != NULL) {
        mT4ClearIntFlag();
        T4CONSET = 0x8000;
      }
      break;
    case TMR_5:
      if(timer5Configured == 1 && tmr5PtrCallback != NULL) {
        mT5ClearIntFlag();
        T5CONSET = 0x8000;
      }
      break;
    default:
      break;
  }
}
Exemple #19
0
void __ISR(_TIMER_1_VECTOR, ipl2) _Timer1Handler(void)
{
    //Reset the flag
    mT1ClearIntFlag();

}
Exemple #20
0
/**
 * @function Timer1Handler
 * @brief Timer1 interruption handler
 * @param none
 * @return none
 */
void __ISR(_TIMER_1_VECTOR, ipl1) Timer1Handler(void) {
  tmr1PtrCallback();
  mT1ClearIntFlag();
}
Exemple #21
0
/**
 * @function TmrSetFrequency
 * @brief configure a given timer with a desired frequency
 * @param tmr_t tmr_id: timer id
 * @param uint32_t desiredFrequency: desired frequency, in Hz
 * @return int8_t: 0 sucess, otherwise error
 */
int8_t TmrSetFrequency(tmr_t tmr_id, uint32_t desiredFrequency) {

  uint16_t tmrValue = 0xFFFF;
  uint16_t prescale;
  uint32_t cfg;
  int8_t res = -1;

  
    switch(tmr_id) {
    
      case TMR_1:
        if(SetTimerFrequency(TMR_TYPE_A, desiredFrequency, &tmrValue, &prescale) == 0) {
          TmrStop(TMR_1);
          mT1ClearIntFlag();
          ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_1 | T1_INT_SUB_PRIOR_1);
          cfg = T1_SOURCE_INT | T1_IDLE_CON;
          if(prescale == 1) cfg |= T1_PS_1_1;
          else if(prescale == 8) cfg |= T1_PS_1_8;
          else if(prescale == 64) cfg |= T1_PS_1_64;
          else cfg |= T1_PS_1_256;
          OpenTimer1(cfg, tmrValue);
          timer1Configured = 1;
          res = 0;
        }
        break;
        
      case TMR_4:
        if(SetTimerFrequency(TMR_TYPE_B, desiredFrequency, &tmrValue, &prescale) == 0) {
          TmrStop(TMR_4);
          mT4ClearIntFlag();
          ConfigIntTimer4(T4_INT_ON | T4_INT_PRIOR_4 | T4_INT_SUB_PRIOR_1);
          cfg = T4_SOURCE_INT | T4_IDLE_CON;
          if(prescale == 1) cfg |= T4_PS_1_1;
          else if(prescale == 2) cfg |= T4_PS_1_2;
          else if(prescale == 4) cfg |= T4_PS_1_4;
          else if(prescale == 8) cfg |= T4_PS_1_8;
          else if(prescale == 16) cfg |= T4_PS_1_16;
          else if(prescale == 32) cfg |= T4_PS_1_32;
          else if(prescale == 64) cfg |= T4_PS_1_64;
          else cfg |= T4_PS_1_256;
          OpenTimer4(cfg, tmrValue);
          timer4Configured = 1;
          res = 0;
        }
        break;
        
      case TMR_5:
        if(SetTimerFrequency(TMR_TYPE_B, desiredFrequency, &tmrValue, &prescale) == 0) {
          TmrStop(TMR_5);
          mT5ClearIntFlag();
          ConfigIntTimer5(T5_INT_ON | T5_INT_PRIOR_5 | T5_INT_SUB_PRIOR_1);
          cfg = T5_SOURCE_INT | T5_IDLE_CON;
          if(prescale == 1) cfg |= T5_PS_1_1;
          else if(prescale == 2) cfg |= T5_PS_1_2;
          else if(prescale == 4) cfg |= T5_PS_1_4;
          else if(prescale == 8) cfg |= T5_PS_1_8;
          else if(prescale == 16) cfg |= T5_PS_1_16;
          else if(prescale == 32) cfg |= T5_PS_1_32;
          else if(prescale == 64) cfg |= T5_PS_1_64;
          else cfg |= T5_PS_1_256;
          OpenTimer5(cfg, tmrValue);
          timer5Configured = 1;
          res = 0;
        }
        break;
        
      default:
        break;
    }
  return res;
}
Exemple #22
0
void __ISR(4, ipl2) _Timer1Handler(void)
{
    mT1ClearIntFlag();
    counter++;
}
//Main Timer for total movement time and block handling
void __ISR(_TIMER_1_VECTOR, ipl3) _InterruptHandler_TMR1(void)
{
    // clear the interrupt flag
    mT1ClearIntFlag();

    if(current_block == Null)
    {
        current_block = plan_get_current_block();
        if(current_block != Null)
        {
            if(current_block->activeAxisCount == 3)
            {
                if(current_block->minStepAxis < N_AXIS) // If they are not all equal  // TODO:  If any of the step counts are equal we dont need Timer4
                {
                    switch(current_block->minStepAxis)  // Need to configure OC Module to be Single Pulse Output and other two OC modules to be continuous pulse
                    {
                        case X_AXIS:
                            BSP_Timer4Start((uint16_t)current_block->steppingFreq[X_AXIS]);// Use Timer4 Interrupt to trigger single output pulse
                            OpenOC2((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER3_SRC|OC_SINGLE_PULSE),  (ReadPeriod3()>>1), ReadPeriod3());   // X_AXIS = Single Pulse

                            BSP_Timer2Start((uint16_t)current_block->steppingFreq[Y_AXIS]);
                            OpenOC1((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER2_SRC|OC_CONTINUE_PULSE),  (ReadPeriod2()>>1), ReadPeriod2()); // Y_AXIS = Continuous Pulse

                            BSP_Timer3Start((uint16_t)current_block->steppingFreq[Z_AXIS]);
                            OpenOC3((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER3_SRC|OC_CONTINUE_PULSE),  (ReadPeriod3()>>1), ReadPeriod3()); // Z_AXIS = Continuous Pulse
                            break;

                        case Y_AXIS:
                            BSP_Timer4Start((uint16_t)current_block->steppingFreq[Y_AXIS]);// Use Timer4 Interrupt to trigger single output pulse
                            OpenOC1((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER3_SRC|OC_SINGLE_PULSE), (ReadPeriod3()>>1), ReadPeriod3());    // Y_AXIS = Single Pulse

                            BSP_Timer2Start((uint16_t)current_block->steppingFreq[X_AXIS]);
                            OpenOC2((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER2_SRC|OC_CONTINUE_PULSE),  (ReadPeriod2()>>1), ReadPeriod2());   // X_AXIS = Continuous Pulse

                            BSP_Timer3Start((uint16_t)current_block->steppingFreq[Z_AXIS]);
                            OpenOC3((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER3_SRC|OC_CONTINUE_PULSE),  (ReadPeriod3()>>1), ReadPeriod3()); // Z_AXIS = Continuous Pulse
                            break;

                        case Z_AXIS:
                            BSP_Timer4Start((uint16_t)current_block->steppingFreq[Z_AXIS]);// Use Timer4 Interrupt to trigger single output pulse
                            OpenOC3((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER3_SRC|OC_SINGLE_PULSE),  (ReadPeriod3()>>1), ReadPeriod3());    // Z_AXIS = Single Pulse

                            BSP_Timer3Start((uint16_t)current_block->steppingFreq[X_AXIS]);
                            OpenOC2((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER3_SRC|OC_CONTINUE_PULSE),  (ReadPeriod3()>>1), ReadPeriod3());   // X_AXIS = Continuous Pulse

                            BSP_Timer2Start((uint16_t)current_block->steppingFreq[Y_AXIS]);
                            OpenOC1((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER2_SRC|OC_CONTINUE_PULSE),  (ReadPeriod2()>>1), ReadPeriod2()); // Y_AXIS = Continuous Pulse
                            break;

                        default:
                            // error
                            break;
                    }
                }
                else
                {
                    BSP_Timer2Start((uint16_t)current_block->steppingFreq[X_AXIS]);     // All Steps Counts are equal so just use on timer
                    OpenOC1((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER2_SRC|OC_CONTINUE_PULSE),  (ReadPeriod2()>>1), ReadPeriod2()); // Y_AXIS = Continuous Pulse
                    OpenOC2((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER2_SRC|OC_CONTINUE_PULSE),  (ReadPeriod2()>>1), ReadPeriod2());   // X_AXIS = Continuous Pulse
                    OpenOC3((OC_ON|OC_IDLE_STOP|OC_TIMER_MODE16 \
                                |OC_TIMER2_SRC|OC_CONTINUE_PULSE),  (ReadPeriod2()>>1), ReadPeriod2()); // Z_AXIS = Continuous Pulse
                }
                BSP_AxisEnable(Y_AXIS, current_block->direction_bits[Y_AXIS]);
                BSP_AxisEnable(X_AXIS, current_block->direction_bits[X_AXIS]);
                BSP_AxisEnable(Z_AXIS, current_block->direction_bits[Z_AXIS]);
            }
            else if (current_block->activeAxisCount == 2)   // 2 Axis Enabled