void initLCD() { //No commands for 40ms OpenTimer2( T2_PS_1_256 | T2_ON, delay( 40 ) ); //Start Reset mPORTAClearBits( 1 << 3 ); mPORTASetPinsDigitalOut( 1 << 3 ); //Prep mPMPOpen( PMP_ON | PMP_TTL | PMP_READ_WRITE_EN | PMP_WRITE_POL_LO | PMP_READ_POL_LO, PMP_MODE_MASTER1 | PMP_WAIT_BEG_4 | PMP_WAIT_MID_15 | PMP_WAIT_END_4, PMP_PEN_0, PMP_INT_OFF ); //Wake Up! while( !mT2GetIntFlag() ); CloseTimer2(); mT2ClearIntFlag(); //End Reset mPORTASetBits( 1 << 3 ); //No Commands for 39us OpenTimer2( T2_PS_1_256 | T2_ON, delay( 40 ) ); //Wake Up! while( !mT2GetIntFlag() ); CloseTimer2(); mT2ClearIntFlag(); lcdCommand(LCD_ON); //Best boot 5-1-05 lcdCommand(0xA3); //LCD Bias (A2 A3) - First Choice lcdCommand(0x2F); //Turn on internal power control lcdCommand(0x26); //Pseudo-Contrast 7 = dark 6 = OK - First Choice lcdCommand(0x81); //Set contrast lcdCommand(40);//The Contrast (30 to 54 - Recommeneded) lcdCommand(0xC8); //Flip screen on the horizontal to match with the vertical software invertion lcdClear(); }
void __ISR(_TIMER_2_VECTOR, ipl3) _InterruptHandler_TMR2(void) { //if(current_block->direction_bits[X_AXIS]) // PORTSetBits(xAxis.directionPin.port, xAxis.directionPin.pin); //else // PORTClearBits(xAxis.directionPin.port, xAxis.directionPin.pin); if(steps_Y) { if(!(mPORTEReadBits(yAxis.enablePin.pin))) steps_Y--; } else if (current_block != Null) { if( (current_block->steps_y)) { if(!(mPORTEReadBits(yAxis.enablePin.pin))) current_block->steps_y--; } else { //CloseOC1(); BSP_AxisDisable(Y_AXIS); BSP_Timer2Stop(); } } else { //CloseOC1(); BSP_AxisDisable(Y_AXIS); BSP_Timer2Stop(); } // clear the interrupt flag mT2ClearIntFlag(); }
void __ISR(_TIMER_2_VECTOR, ipl2) interruptForCheckingIRSignals(void) { if (IFS0bits.T2IF) { if (!processIRCommand) { //IFS0bits.T2IF = 0; //printf("i\r\n"); irDurationCounter10us++; BOOL status = IR_INPUT_READ; if (portD != status) { handlePortStatus(status); if (status) { //mPORTBClearBits(BIT_12); mPORTDClearBits(BIT_1); } else { //mPORTBSetBits(BIT_12); mPORTDSetBits(BIT_1); } portD = status; } } mT2ClearIntFlag(); } }
void __ISR(_TIMER_2_VECTOR, ipl6) TMR2_Handler(void) { // clear the interrupt flag mT2ClearIntFlag(); // QUAD LATCH position_manager_timer_handler(); }
//* // Timer2 Interrupt Service Routine void __ISR(_TIMER_2_VECTOR, ipl2) handlesTimer2Ints(void) { if (!flag_writingScreen && (IMU_counter++ > IMU_MAXCOUNT)) { mympu_update(&mympu); IMU_counter = 0; } mT2ClearIntFlag(); // Clears the interrupt flag so that the program returns to the main loop } // END Timer2 ISR
// This is called at PLAYBACK_RATE Hz to load the next sample. extern "C" void __ISR(_TIMER_2_VECTOR, ipl6) T2_IntHandler (void) { // Clear interrupt. By clearing the IF *before* handling the // interrupt we can test for overruns (the IF would turn back on). mT2ClearIntFlag(); modem_playback(); }
//Interrupt handler for PWM void __ISR(_TIMER_2_VECTOR, ipl1) _Timer2Handler(void) { //Reset the flag mT2ClearIntFlag(); //Put code here }
__ISR(_TIMER_2_VECTOR, IPL(TICK_IPL)) OSTickInt( void ) { mT2ClearIntFlag(); OS_TimerHook(); if (0 == --OneSecPrescaler) { OneSecPrescaler = SYSTICKHZ; OSTickSeconds++; } }
// Timer2 Interrupt Service Routine void __ISR(_TIMER_2_VECTOR, ipl2) handlesTimer2Ints(void){ // **make sure iplx matches the timer’s interrupt priority level //LATDINV = 0x0200; // This statement looks at pin RD9, and latches RD9 the inverse of the current state. // In other words, it toggles the LED that is attached to RD9 pin_xclk_inv(); mT2ClearIntFlag(); // Clears the interrupt flag so that the program returns to the main loop } // END Timer2 ISR
void TMR2_Init(void) { #ifdef _TARGET_440H #else // STEP 1. configure the Timer2 OpenTimer2(T2_ON | T2_SOURCE_INT | T2_IDLE_CON | T2_PS_1_256, TMR2_RELOAD); // STEP 2. set the timer interrupt to prioirty level 6 ConfigIntTimer2(T2_INT_ON | T2_INT_PRIOR_6); mT2ClearIntFlag(); #endif }
/* Specify Interrupt Priority Level = 2 */ void __ISR(_TIMER_2_VECTOR, IPL3) _Timer2Handler(void) { numberOfMillis--; if( 0 >= numberOfMillis) { #ifdef DEBUG sendDataBuffer("timeout reached\n"); #endif setState(STATE_ERROR); ConfigIntTimer2(T2_INT_OFF); int i; for(i=0; i < 5000;i++) {} } mT2ClearIntFlag(); }
void __ISR(_TIMER_2_VECTOR, ipl3) Timer2Isr(void) { timerTicks++; //reset timerTicks every 20ms if (timerTicks > 200) timerTicks = 0; //uncomment this and set the port to any digital out porto enable the servo if (timerTicks < servoPulseWidth[1]) PORTDbits.RD0 = 1; else PORTDbits.RD0 = 0; mT2ClearIntFlag(); }
/* TIMER 2 Interrupt Handler - configured to 50us periods */ void __ISR(_TIMER_2_VECTOR, ipl3) Timer2Handler(void) { // clear the interrupt flag mT2ClearIntFlag(); counterTrigger--; if(counterTrigger==5){ mPORTBSetBits(BIT_8 | BIT_9| BIT_10 | BIT_11); //Sends trigger signal to the four sensors } if(counterTrigger == 0){ mPORTBClearBits(BIT_8 | BIT_9| BIT_10 | BIT_11); //Shut down trigger signal } delayFront++; delayBack++; delayRight++; delayLeft++; }
void InterruptHandler( void) { sec1000++; dir = readRotary(); // the rotary encoder is read state = state + dir; //the state is changed depending on the returned value r1 = r1 + dir; //total number of adjustments updated if (state == 15) //state 14 rolls over to state 0 state = 0; if (state == -1) //state 0 rolls over to state 14 state = 14; if (dir != 0) //if the direction is not zero (rotart moved) { //then the code in main runs. go = 1; } if ((r1 <= -30) && (lock == 0) && (state == 11)) //the rotary needs to be moved { //30 times clockwise and be in state 11 lock++; //in order to increment lock the first time r1 = 0; //the count is reset } if ((r1 >= 15) && (lock == 1) && (state == 2) && (r1 <= 30 )) //the rotary needs to be moved { //15 times counterclockwise but less //than 30 times and be in lock++; //state 2 to increment lock a second time r1 = 0; } if ((r1 < 0) && (lock == 2) && (state == 13) && (r1 > -15)) //the rotary needs to be moved less than { //15 times clockwise to increment lock lock = 3; // to 3 } if ((lock == 3) && getRotary(3)) //once lock is incremented to 3 and { //the rotary pushbutton is pressed, unlocked = 1; //then the status becomes unlocked lock = 0; } mT2ClearIntFlag(); }
/* Timer 2 ISR */ void __ISR(_TIMER_2_VECTOR, ipl6) Timer2Handler(void) { /** * Handle interrupts for timer2 * General purpose 1 ms timer controls a lot of the IO on the device */ // clear the interrupt flag mT2ClearIntFlag(); TMR2_ticks++; ENC_elapsed++; SMP_LAST_TRANSMISSION++; if(SMP_LAST_TRANSMISSION > 100) { SMP_gotoDemonstrationMode(); } if(TONE_play == TRUE) { if(note_stop == -1) { note_stop = TMR2_ticks + TONE_beats[note_count]*TEMPO_MULTIPLER; } if(TMR2_ticks == note_stop) { note_stop = TMR2_ticks + TONE_beats[note_count]*TEMPO_MULTIPLER; TONE_playNote(TONE_notes[note_count]); note_count++; if(note_count >= TONE_count) { TONE_play = FALSE; note_count = 0; note_stop = -1; TONE_playNote(' '); DisableIntT1; } } } }
void configureTimeout(int secondes) { numberOfMillis = secondes * 1000; mT2ClearIntFlag(); OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_64, 625); ConfigIntTimer2(T2_INT_ON | T2_INT_PRIOR_2); }
//============================================= // Configure the Timer 2 interrupt handler //============================================= void __ISR(_TIMER_2_VECTOR, T2_INTERRUPT_PRIORITY) Timer2InterruptHandler(void) { /* * Following code performs a smooth stop. It goes from 30% speed to 0 in order * to have a smooth curve. Used in manual mode and for emergency stops in * automatic mode (if the mast is too far). */ if (oEnableMastStopProcedure) { if (iMastStop == 0) { mastDir = SignFloat(mastCurrentSpeed); } if (iMastStop < 16) { DRVB_SLEEP = 1; if (mastDir == MAST_DIR_LEFT) { // DRIVE B //========================================================== if (USE_DRIVE_B == 1) { Pwm.SetDutyCycle(PWM_2, 500 + (150 - iMastStop*10)); Pwm.SetDutyCycle(PWM_3, 500 - (150 - iMastStop*10)); } //========================================================== // DRIVE A //========================================================== if (USE_DRIVE_A == 1) { Pwm.SetDutyCycle(PWM_4, 500 + (150 - iMastStop*10)); Pwm.SetDutyCycle(PWM_5, 500 - (150 - iMastStop*10)); //========================================================== } } else if (mastDir == MAST_DIR_RIGHT) { // DRIVE B //========================================================== if (USE_DRIVE_B == 1) { Pwm.SetDutyCycle(PWM_2, 500 - (150 - iMastStop*10)); Pwm.SetDutyCycle(PWM_3, 500 + (150 - iMastStop*10)); } //========================================================== // DRIVE A //========================================================== if (USE_DRIVE_A == 1) { Pwm.SetDutyCycle(PWM_4, 500 - (150 - iMastStop*10)); Pwm.SetDutyCycle(PWM_5, 500 + (150 - iMastStop*10)); } //========================================================== } iMastStop++; } else { // if (!oWaitAfterStop) // { // DRIVE B //========================================================== if (USE_DRIVE_B == 1) { Pwm.SetDutyCycle(PWM_2, 500); Pwm.SetDutyCycle(PWM_3, 500); DRVB_SLEEP = 0; } //========================================================== // DRIVE A //========================================================== if (USE_DRIVE_A == 1) { Pwm.SetDutyCycle(PWM_4, 500); Pwm.SetDutyCycle(PWM_5, 500); DRVA_SLEEP = 0; } //========================================================== //#ifdef USE_POTENTIOMETER // oWaitAfterStop = 1; //#else mastCurrentSpeed = 0; oEnableMastStopProcedure = 0; iMastStop = 0; mastDir = 0; //#endif // } // else // { // if (waitAfterStopCounter < 10) // { // waitAfterStopCounter++; // } // else // { // waitAfterStopCounter = 0; // oWaitAfterStop = 0; // oEnableMastStopProcedure = 0; // iMastStop = 0; // mastDir = 0; // } // } } } // Increment the number of overflows from this timer. Used primarily by Input Capture Timer.Var.nOverflows[1]++; mT2ClearIntFlag(); }
// Timer 2 interrupt handler /////// // ipl2 means "interrupt priority level 2" // ASM output is 47 instructions for the ISR void __ISR(_TIMER_2_VECTOR, ipl2) Timer2Handler(void) { mT2ClearIntFlag(); }
void MSTimerIntHandler(void) { mT2ClearIntFlag(); _MSTimer++; _MSTimer32++; }
/********************************************************************** * Function: Timer2IntHandler * @return none * @remark This is the interrupt handler used by the LCD module to update * the display by calling an update function every time this interrupt * occurs. **********************************************************************/ void __ISR(_TIMER_2_VECTOR, ipl3) Timer2IntHandler(void) { timerCallback(); // Reset Timer 2 interrupt flag mT2ClearIntFlag(); }
void __ISR(_TIMER_2_VECTOR, ipl2) Timer3Handler(void) { //empty ISR mT2ClearIntFlag();//clear interrupt flag, if you forget to do this, the microcontroller will interrupt continuously }
void __ISR(_TIMER_2_VECTOR, IPL5) T2Handle(void){ mT2ClearIntFlag(); timer += 1; }
void __ISR(_TIMER_2_VECTOR, IPL2SOFT) Timer2Handler(void) { static unsigned char sendOne = 0; static unsigned char sendZero = 0; static unsigned char lowHalf = 1; static unsigned char highHalf = 1; // clear the interrupt flag mT2ClearIntFlag(); // LATBbits.LATB8 == DBG pin shake sensor near LCD pins // each timer interrupt is 1/38khz if (G_IRrecv) { if (G_bitCnt > 7) { G_IRrecv = 2; G_bitCnt = 0; G_halfCount = 0; } else { G_halfCount++; // 32 interrupts for each half of bit send // for 64 total per bit if (G_halfCount == 16) G_firstHalf = !PORTCbits.RC0; if (G_halfCount == 48) G_lastHalf = !PORTCbits.RC0; if (G_halfCount > 63) { G_IRrecvVal <<= 1 ; G_IRrecvVal |= G_lastHalf; // should check proper manchester low->high, high->low LATBbits.LATB8 = G_lastHalf; // DBG output G_bitCnt++; G_halfCount = 0; if (G_firstHalf == G_lastHalf) //check for error { G_IRrecvVal = 0; G_IRrecv = 0; return; } } } return; } if (G_IRsend) { // 3 sections for IR send: // -init and looping vars // -send a zero // -send a one // break byte into bits to send // init, and looping. is the one or zero is done? if ((sendOne == 0) && (sendZero == 0)) { if (G_bitCnt < 8) { // high order bit first sendOne = (G_IRsendVal & (0b10000000 >> G_bitCnt)); sendZero = (sendOne == 0); G_bitCnt++; } else { G_IRsend = 0; G_bitCnt = 0; } }