Part Number: TM4C123GH6PM
This is on the Tiva C LaunchPad.
I'm trying to use 1 pin as a Zero-crossing detection pin that I trigger an interrupt off of. I want the interrupt type to be high level detection type so that I get an interrupt immediately when the zero-crossing happens. However, the pin I'm trying to use is only functioning as a falling edge detection. Here is the configuration code for the pin and interrupt (the full Initialization routine is below):
//Configure pin 1 of Port E as input with a high level detection interrupt.
//This is for zero cross detection
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
IntEnable(INT_GPIOE);
GPIOIntEnable(GPIO_PORTE_BASE,GPIO_INT_PIN_1);
GPIOIntRegister(INT_GPIOE,ZeroCrossing);
GPIOIntTypeSet(INT_GPIOE,GPIO_INT_PIN_1,GPIO_HIGH_LEVEL);
dummie=GPIOIntTypeGet(INT_GPIOE,GPIO_INT_PIN_1);
I added the 'dummie' int to see what the actual value of the interrupt type was and it is always 65,536 in decimal regardless of what type I put in there (_LOW_LEVEL or _RISING_EDGE etc). I also have a multimeter hooked up to the pin to confirm when it is at 0V and when it goes to 3.3V (sourced from the LaunchPad pin). The interrupt portion is working correctly but only falling edge.
Any ideas as to what I might be doing wrong here?
int Initialize(void)
{
//Initialize System Clock to 40MHz
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
//enable Peripherals
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1);
//We must wait a few clock cycles for the peripherals to be enabled
//This while loop will allow for the peripherals to be enabled before continuing
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_ADC1))
{
}
//Configure Timer0 as a one-shot timer
TimerConfigure(TIMER0_BASE, TIMER_CFG_ONE_SHOT);
//Enable and configure Interrupt on Timer0 to be when it times out
IntEnable(INT_TIMER0A);
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
//initialize GPIO Port E Pin 2,3 as analog pins
GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_2|GPIO_PIN_3);
//Configure pin 1 of Port F as output. This is where the red LED is connected
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
//Configure pin 1 of Port E as input with a high level detection interrupt.
//This is for zero cross detection
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
IntEnable(INT_GPIOE);
GPIOIntEnable(GPIO_PORTE_BASE,GPIO_INT_PIN_1);
GPIOIntRegister(INT_GPIOE,ZeroCrossing);
GPIOIntTypeSet(INT_GPIOE,GPIO_INT_PIN_1,GPIO_LOW_LEVEL);
dummie=GPIOIntTypeGet(INT_GPIOE,GPIO_INT_PIN_1);
//Configure sequencer for ADC 0 & 1
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceConfigure(ADC1_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
//Configure the ADC step
ADCSequenceStepConfigure(ADC0_BASE,0,0,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
ADCSequenceStepConfigure(ADC1_BASE,0,0,ADC_CTL_CH1|ADC_CTL_IE|ADC_CTL_END);
//Enable ADC sequencer 0 & 1
ADCSequenceEnable(ADC0_BASE,0);
ADCSequenceEnable(ADC1_BASE,0);
//Enable interrupts
IntMasterEnable();
return(0);
}