Tool/software: Code Composer Studio
Hello. I have next task. I receive 2 signals from compactors which looks like 50% PWM 100Hz and shifted by 90 degrees to each other. I need to make ADC sample each time than signals switched (4 times per period or 400hz). I wrote next code for this task.
static void adcInterruptHandler(){ unsigned int state = ADCIntStatus(ADC0_BASE, 0, true); ADCIntClear(ADC0_BASE, 0); int32_t tmp[2]; ADCSequenceDataGet(ADC0_BASE, 0, (uint32_t *)tmp); ADCSequenceDataGet(ADC0_BASE, 0, (uint32_t *)tmp+1); } static void initAdc(){ SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0)); ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_EXTERNAL, 0); //set up sequence ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH1); ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); //interrupt settings ADCIntRegister(ADC0_BASE, 0, adcInterruptHandler); ADCIntEnable(ADC0_BASE, 0); ADCSequenceEnable(ADC0_BASE, 0); ADCIntClear(ADC0_BASE, 0); } static void initGpioInterrupt(){ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_0,GPIO_BOTH_EDGES); GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_BOTH_EDGES); GPIOADCTriggerEnable(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOADCTriggerEnable(GPIO_PORTF_BASE, GPIO_PIN_4); }
This code run good while i emulate event using button, but at real enviroment it goes to FaultISR. Look like signals has gitter and triggering happend several times in one moment. I need to fix this fault by skipping redundant events but how to do it?