void FC81_Interrupt(void) { clrRegBit(TMR0_SCTRL,TCF); /* Reset interrupt request flag */ TTicks++; /* Increment counter of timer ticks */ if (TTicks == 0) { /* Testing counter overflow */ TOvf = TRUE; /* If yes then set overflow flag */ } }
void TI1_interrupt (void) { byte i; _count++; _wait = false; clrRegBit (TMRA3_SCR, TCF); /* Reset interrupt request flag */ }
/* ** =================================================================== ** Method : HWEnDi (component ADC) ** ** Description : ** Enables or disables the peripheral(s) associated with the ** component. The method is called automatically as a part of ** Enable, Disable and Init methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void HWEnDi(void) { if (AD1_ModeFlg) { /* Launch measurement? */ OutFlg = FALSE; /* Measured values are available */ setRegBits(ADC_ADSTAT,2048); /* Clear flag */ clrRegBit(ADC_ADCR1,STOP0); /* Normal operation mode */ setRegBit(ADC_ADCR1,START0); /* Launching of conversion */ } else { setRegBit(ADC_ADCR1,STOP0); /* Stop command issued */ } }
/* ** =================================================================== ** Method : HWEnDi (component SynchroMaster) ** ** Description : ** Enables or disables the peripheral(s) associated with the bean. ** The method is called automatically as a part of the Enable and ** Disable methods and several internal methods. ** This method is internal. It is used by Processor Expert only. ** =================================================================== */ static void HWEnDi(void) { if (EnUser) { /* Enable device? */ setRegBit(QSPI0_SCTRL,SPE); /* Enable device */ setRegBits(GPIO_C_PEREN,0x0200); /* Switch pin to peripheral */ if (SerFlag & FULL_TX) { /* Is any char in transmit buffer? */ setReg(QSPI0_DXMIT,BufferWrite); /* Store char to transmitter register */ SerFlag &= ~FULL_TX; /* Zeroize FULL_TX flag */ } } else { clrRegBits(GPIO_C_PEREN,0x0200); /* Switch pin to GPIO */ clrRegBit(QSPI0_SCTRL,SPE); /* Disable device */ } }
//////////////////////////////////////////////////////////////////////// // // comMainLoop() // // Communication loop. Wait for CAN frames and parses the messagge. // The loop ends when comContinue is false. // //////////////////////////////////////////////////////////////////////// void comMainLoop(void) { byte ReadCANState; byte i; comContinue = TRUE; comTimerEn = TRUE; while (comContinue) { /* wait CAN data or while timer expired, if set */ while (CAN1_getStateRX() == 0) { // Timer check if (comTimerEn) { if (getRegBit(TMRC1_SCR,TCF)) /* Is the interrupt request flag set? */ { clrRegBit(TMRC1_SCR,TCF); /* If yes then reset this flag */ if (--TmpXdataVar == 0) { setRegBitGroup(TMRC0_CTRL,CM,0); /* Stop counter */ return; } } } } if (CAN1_getStateRX() != 0) { /* Received CAN frame */ ReadCANState=CAN1_readFrame (&comBuffer.CAN_messID, &comBuffer.CAN_length, comBuffer.CAN_data); if ((ReadCANState != ERR_OK) && (ReadCANState != ERR_RXEMPTY)) { userError(INDICATE_ERROR_RECEIVE); } sprsReady(&comBuffer); /* call CAN protocol parser */ } } /* while */ }
/** * starts the acquisition on channel A. * **************************************************************************************/ static void HWEnDiA(void) { if (ad_ModeFlgA) /* Launch measurement? */ { OutFlgA = FALSE; /* Measured values are available */ /* Trigger mode? */ if (getRegBit (ADCA_ADCR1, SMODE2)) { setRegBit (ADCA_ADCR1, SYNC); /* Use sync input to initiate a conversion */ clrRegBit (ADCA_ADCR1, STOP); /* Normal operation mode */ } else { /* Set normal operation mode and sync input disabled */ clrRegBits (ADCA_ADCR1, ADCA_ADCR1_SYNC_MASK | ADCA_ADCR1_STOP_MASK); setRegBit (ADCA_ADCR1, START); /* Launching of conversion */ } } else { setRegBit (ADCA_ADCR1, STOP); /* Stop command issued */ } }
void PWM_B_outputPadDisable (word mask) { clrRegBit(PWMB_PMOUT,PAD_EN); }
void COUNTER1_Interrupt(void) { clrRegBit(TMR0_SCR,TOF); /* Clear overflow interrupt flag */ Overflow = TRUE; /* Set an internal overflow flag */ }
void PIT_1ms_Interrupt(void) { clrRegBit(PIT0_CTRL,PRF); /* Reset interrupt request flag */ PIT_1ms_OnInterrupt(); /* Invoke user event */ }
void TD0_interrupt(void) { static Int16 counter = 0; if (counter == 20) { //saves the number of commutations occurred during this period comm_count[0]=comm_enc[0]; comm_count[1]=comm_enc[1]; //zero the commutation econder comm_enc[0]=0; comm_enc[1]=0; counter = 0; } else counter++; if (DutyCycleReq[0].Dir != DutyCycle[0].Dir) { if (DutyCycle[0].Duty <= (MIN_DUTY)) { if (DutyCycleReq[0].Dir) pTable0 = bldcCommutationTableCompInv; else pTable0 = bldcCommutationTableComp; DutyCycle[0].Dir = DutyCycleReq[0].Dir; } else { DutyCycle[0].Duty=DutyCycle[0].Duty-STEP; } } else { if (DutyCycleReq[0].Duty > DutyCycle[0].Duty) { if (DutyCycleReq[0].Duty-DutyCycle[0].Duty>=STEP) DutyCycle[0].Duty=DutyCycle[0].Duty+STEP; else DutyCycle[0].Duty=DutyCycleReq[0].Duty; } else if (DutyCycleReq[0].Duty < DutyCycle[0].Duty) { if (DutyCycle[0].Duty-DutyCycleReq[0].Duty>=STEP) DutyCycle[0].Duty=DutyCycle[0].Duty-STEP; else DutyCycle[0].Duty=DutyCycleReq[0].Duty; } // else TD0_Disable(); } //++++++ if (DutyCycleReq[1].Dir != DutyCycle[1].Dir) { if (DutyCycle[1].Duty <= (MIN_DUTY)) { if (DutyCycleReq[1].Dir) pTable1 = bldcCommutationTableCompInv; else pTable1 = bldcCommutationTableComp; DutyCycle[1].Dir = DutyCycleReq[1].Dir; } else { DutyCycle[1].Duty=DutyCycle[1].Duty-STEP; } } else { if (DutyCycleReq[1].Duty > DutyCycle[1].Duty) { if (DutyCycleReq[1].Duty-DutyCycle[1].Duty>=STEP) DutyCycle[1].Duty=DutyCycle[1].Duty+STEP; else DutyCycle[1].Duty=DutyCycleReq[1].Duty; } else if (DutyCycleReq[1].Duty < DutyCycle[1].Duty) { if (DutyCycle[1].Duty-DutyCycleReq[1].Duty>=STEP) DutyCycle[1].Duty=DutyCycle[1].Duty-STEP; else DutyCycle[1].Duty=DutyCycleReq[1].Duty; } // else TD0_Disable(); } PWM_generate_BLL(0, DutyCycle[0].Duty); PWM_generate_BLL(1, DutyCycle[1].Duty); clrRegBit (TMRD0_SCR, TCF); /* Reset interrupt request flag */ }
void TI1_Interrupt(void) { clrRegBit(TMR2_SCR,TCF); /* Reset interrupt request flag */ TI1_OnInterrupt(); /* Invoke user event */ }