interrupt void mainISR(void) { // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); if(FW_getFlag_enableFw(fwHandle) == true) { FW_incCounter(fwHandle); if(FW_getCounter(fwHandle) > FW_getNumIsrTicksPerFwTick(fwHandle)) { _iq refValue; _iq fbackValue; _iq output; FW_clearCounter(fwHandle); refValue = gMotorVars.VsRef; fbackValue = gMotorVars.Vs; FW_run(fwHandle, refValue, fbackValue, &output); CTRL_setId_ref_pu(ctrlHandle, output); gMotorVars.IdRef_A = _IQmpy(CTRL_getId_ref_pu(ctrlHandle), _IQ(USER_IQ_FULL_SCALE_CURRENT_A)); } } else { CTRL_setId_ref_pu(ctrlHandle, _IQmpy(gMotorVars.IdRef_A, _IQ(1.0/USER_IQ_FULL_SCALE_CURRENT_A))); } // setup the controller CTRL_setup(ctrlHandle); return; } // end of mainISR() function
interrupt void mainISR(void) { // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); // setup the controller CTRL_setup(ctrlHandle); return; } // end of mainISR() function
interrupt void mainISR(void) { uint32_t timer0Cnt; uint32_t timer1Cnt; // read the timer 1 value and update the CPU usage module timer1Cnt = HAL_readTimerCnt(halHandle,1); CPU_USAGE_updateCnts(cpu_usageHandle,timer1Cnt); // read the timer 0 value and update the FEM timer0Cnt = HAL_readTimerCnt(halHandle,0); FEM_updateCnts(femHandle,timer0Cnt); FEM_run(femHandle); // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); // setup the controller CTRL_setup(ctrlHandle); // read the timer 1 value and update the CPU usage module timer1Cnt = HAL_readTimerCnt(halHandle,1); CPU_USAGE_updateCnts(cpu_usageHandle,timer1Cnt); // run the CPU usage module CPU_USAGE_run(cpu_usageHandle); return; } // end of mainISR() function
interrupt void mainISR(void) { static uint16_t stCnt = 0; // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // Run the SpinTAC Components if(stCnt++ >= ISR_TICKS_PER_SPINTAC_TICK) { ST_runVelId(stHandle, ctrlHandle); stCnt = 1; } // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); // setup the controller CTRL_setup(ctrlHandle); if(CTRL_getMotorType(ctrlHandle) == MOTOR_Type_Pm) { // reset Ls Q format to a higher value when Ls identification starts CTRL_resetLs_qFmt(ctrlHandle, gMax_Ls_qFmt); } return; } // end of mainISR() function
interrupt void mainISR(void) { static uint16_t stCnt = 0; // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // Run the SpinTAC Components if(stCnt++ >= ISR_TICKS_PER_SPINTAC_TICK) { ST_runVelPlanTick(stHandle); ST_runVelPlan(stHandle, ctrlHandle); ST_runVelMove(stHandle, ctrlHandle); ST_runVelCtl(stHandle, ctrlHandle); stCnt = 1; } // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); // setup the controller CTRL_setup(ctrlHandle); return; } // end of mainISR() function
/**************************************************************************** * ADC ISR ***************************************************************************/ void isr_ADC1(void) { // acknowledge the ADC interrupt ADC_clearIntFlag(halHandle->adcHandle, ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle, &gAdcData); // run the controller CTRL_run(ctrlHandle, halHandle, &gAdcData, &gPwmData); // write the PWM compare values HAL_writePwmData(halHandle, &gPwmData); // setup the controller CTRL_setup(ctrlHandle); return; }
interrupt void mainISR(void) { // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // Check if speed reference signal is active // If more than 2000 service routine cycles pass without signal, disable motor if (gSpeedRef_Ok++ > 2000) { gSpeedRef_duty = _IQ(0); gMotorVars.Flag_Run_Identify = 0; gSpeedRef_Ok = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); // setup the controller CTRL_setup(ctrlHandle); return; } // end of mainISR() function
interrupt void mainISR(void) { static uint16_t stCnt = 0; // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // run the current reconstruction algorithm SVGENCURRENT_RunRegenCurrent(svgencurrentHandle, (MATH_vec3 *)(gAdcData.I.value)); // Run the SpinTAC Components if(stCnt++ >= ISR_TICKS_PER_SPINTAC_TICK) { ST_runVelMove(stHandle, ctrlHandle); ST_runVelCtl(stHandle, ctrlHandle); stCnt = 1; } // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); // run the current ignore algorithm { uint16_t pwmValue_1 = HAL_readPwmCmpA(halHandle,PWM_Number_1); uint16_t pwmValue_2 = HAL_readPwmCmpA(halHandle,PWM_Number_2); uint16_t pwmValue_3 = HAL_readPwmCmpA(halHandle,PWM_Number_3); // run the current ignore algorithm SVGENCURRENT_RunIgnoreShunt(svgencurrentHandle,pwmValue_1,pwmValue_2,pwmValue_3); } // Set trigger point in the middle of the low side pulse HAL_setTrigger(halHandle,SVGENCURRENT_getMinWidth(svgencurrentHandle)); if(FW_getFlag_enableFw(fwHandle) == true) { FW_incCounter(fwHandle); if(FW_getCounter(fwHandle) > FW_getNumIsrTicksPerFwTick(fwHandle)) { _iq refValue; _iq fbackValue; _iq output; FW_clearCounter(fwHandle); refValue = gMotorVars.VsRef; fbackValue = gMotorVars.Vs; FW_run(fwHandle, refValue, fbackValue, &output); CTRL_setId_ref_pu(ctrlHandle, output); gMotorVars.IdRef_A = _IQmpy(CTRL_getId_ref_pu(ctrlHandle), _IQ(USER_IQ_FULL_SCALE_CURRENT_A)); } } else { CTRL_setId_ref_pu(ctrlHandle, _IQmpy(gMotorVars.IdRef_A, _IQ(1.0/USER_IQ_FULL_SCALE_CURRENT_A))); } // setup the controller CTRL_setup(ctrlHandle); return; } // end of mainISR() function
interrupt void mainISR(void) { static uint16_t stCnt = 0; // toggle status LED if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz)) { HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2); gLEDcnt = 0; } // acknowledge the ADC interrupt HAL_acqAdcInt(halHandle,ADC_IntNumber_1); // convert the ADC data HAL_readAdcData(halHandle,&gAdcData); // Run the SpinTAC Components if(stCnt++ >= ISR_TICKS_PER_SPINTAC_TICK) { ST_runVelCtl(stHandle, ctrlHandle); stCnt = 1; } // run the controller CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData); // write the PWM compare values HAL_writePwmData(halHandle,&gPwmData); if (!(SpeedRef_krpm_previous == gMotorVars.SpeedRef_krpm)) { Graph_Flag_Enable_update = true; Graph_Counter = 0; SpeedRef_krpm_previous = gMotorVars.SpeedRef_krpm; } gMotorVars.Iq_A = _IQmpy(CTRL_getIq_in_pu(ctrlHandle), _IQ(USER_IQ_FULL_SCALE_CURRENT_A)); // store graph value if(Graph_Flag_Enable_update) { if(Graph_Counter >= GRAPH_SIZE) { Graph_Flag_Enable_update = false; } else { if(Graph_Tick_Counter == 0) { Graph_Data[Graph_Counter] = gMotorVars.Speed_krpm; Graph_Data2[Graph_Counter] = gMotorVars.Iq_A; Graph_Counter++; Graph_Tick_Counter = Graph_Tick_Counter_Value - 1; } else { Graph_Tick_Counter--; } } } // setup the controller CTRL_setup(ctrlHandle); return; } // end of mainISR() function