// * svm_pwm_gen_ISR ********************************************************** // * ISR for our svm pwm generator * // **************************************************************************** void svm_pwm_gen_ISR(void) { static unsigned char toggle = 0; // test code // for now the only thing that can get us here // is the timer load interrupt ROM_PWMGenIntClear(SVM_PWM_BASE, SVM_PWM_GEN, PWM_INT_CNT_LOAD); // clear timer load interrupt or else nothiing else will run // do things here }
//***************************************************************************** // // This function is called each time the ADC sample sequence completes. // //***************************************************************************** void ADCIntHandler(void) { unsigned short pusADCData[8]; unsigned long ulIdx; // // Clear the ADC interrupt. // ROM_ADCIntClear(ADC0_BASE, 0); // // If running on Rev A0 silicon, clear the PWM trigger interrupt sources. // This is a workaround to allow them to retrigger the ADC. Since this // workaround is otherwise harmless, it is done unconditionally (to avoid // checking the silicon revision within this interrupt handler). // ROM_PWMGenIntClear(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_BD); // // Call the H-bridge update function. // HBridgeTick(); // // Drain the ADC of conversions. // if(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY) { return; } pusADCData[0] = HWREG(ADC0_BASE + ADC_O_SSFIFO0); if(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY) { return; } pusADCData[1] = HWREG(ADC0_BASE + ADC_O_SSFIFO0); if(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY) { return; } pusADCData[2] = HWREG(ADC0_BASE + ADC_O_SSFIFO0); if(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY) { return; } pusADCData[3] = HWREG(ADC0_BASE + ADC_O_SSFIFO0); if(!(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY)) { while(!(HWREG(ADC0_BASE + ADC_O_SSFSTAT0) & ADC_SSFSTAT0_EMPTY)) { HWREG(ADC0_BASE + ADC_O_SSFIFO0); } return; } g_pusADCData[0] = pusADCData[0]; g_pusADCData[1] = pusADCData[1]; g_pusADCData[2] = pusADCData[2]; g_pusADCData[3] = pusADCData[3]; // // Put this winding current reading into the current bucket. // g_pusBuckets[g_ulBucket >> 16] += g_pusADCData[WINDING_CURRENT]; g_ulBucket++; // // See if this bucket is full. // if((g_ulBucket & 0xffff) == 16) { // // Compute the new averaged winding current reading. // g_usCurrent = ((g_pusBuckets[0] + g_pusBuckets[1] + g_pusBuckets[2] + g_pusBuckets[3] + g_pusBuckets[4] + g_pusBuckets[5] + g_pusBuckets[6] + g_pusBuckets[7]) / (8 * 16)); // // Advance to the next bucket. // g_ulBucket = (g_ulBucket + 0x10000) & 0x00070000; g_pusBuckets[g_ulBucket >> 16] = 0; }