Hi, I'm currently studying in electrical engineering at Polytechnique Montreal and I have a problem configuring the analog comparators. I want interrupts to be triggered on the rising edge of the comparator signal, and vref should be 1.65V. Here's my code:
int32_t main(void) { uint8_t sig; sig = 0; zero1_reached = 1; zeros_index = 0; SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP0); SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP1); SysTickPeriodSet(0xFFFFFF); __asm { NOP NOP NOP }; GPIOPinTypeComparator(GPIO_PORTC_BASE,GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); GPIOPinConfigure(GPIO_PF0_C0O); GPIOPinConfigure(GPIO_PF1_C1O); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_1); ComparatorRefSet(COMP_BASE,COMP_REF_1_65V); ComparatorConfigure(COMP_BASE,0, COMP_TRIG_NONE|COMP_INT_RISE|COMP_ASRCP_REF|COMP_OUTPUT_NORMAL); ComparatorConfigure(COMP_BASE,1, COMP_TRIG_NONE|COMP_INT_RISE|COMP_ASRCP_REF|COMP_OUTPUT_NORMAL); ComparatorIntEnable(COMP_BASE,0); ComparatorIntEnable(COMP_BASE,1); EnableInterrupts(); IntEnable(25); IntEnable(26); while(zeros_index < MAX_ZEROS) WaitForInterrupt(); DisableInterrupts(); return 0; }
I can't seem to get it working since the program never get in the interrupt handler of the comparator 0 or 1 even when a full 0-3.3V AC signal enters any of the port C pins (4-5-6-7). Also, I've noticed that PF0 is high and that I needed to unlock it somehow.
Thanks.
Lucas Malo Bélanger