Hi TI:
Brief Problem Description:
A GPIO Interrupt seems to 1) fire continuously or 2) fire way too many times (IE. somewhat like a debounce issue)
Setup:
Tiva TM4C123GXL using later versions of TI-RTOS and Code Composer.
Backgroud:
This is a simple circuit with a 2 wire anemometer, an LED, a 10K pull down resistor using 3.3V power supply.
Spin the anemometer and the LED briefly lights up once per revolution.
I attached PIN F0 to the circuit and slowly spun the anemometer. I used GPIO_read and validated correct reults.
Next, I wrote the Interrupt code to detect each revolution.
Code:
const GPIO_Callbacks EK_TM4C123GXL_gpioPortFCallbacks =
{
GPIO_PORTF_BASE, INT_GPIOF,
{gpio_PF0_WindSpeedCalculate, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
};
// skipped code here
//***********************************************************************************************************
// Wind Speed Detector / Unlock First
HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x1;
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0); // PF0 - PIN 28 - Wind Speed Detector - PIN Must Be Unlocked First
//HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M; // seems to have no affect.
//GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_BOTH_EDGES | GPIO_DISCRETE_INT);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE | GPIO_DISCRETE_INT); // <- Falling Edge hangs the processor.
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0);
GPIO_init();
// skipped code here
Void gpio_PF0_WindSpeedCalculate(Void)
{
//GPIOIntClear(GPIO_PORTF_BASE, GPIO_BOTH_EDGES | GPIO_DISCRETE_INT);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_FALLING_EDGE | GPIO_DISCRETE_INT); // <- Falling Edge hangs the processor.
iHitIt++; // tracking # times the Interrupt fires.
}
Observations/Issues:
1.
//GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_BOTH_EDGES | GPIO_DISCRETE_INT);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE | GPIO_DISCRETE_INT);
If I use GPIO_FALLING_EDGE, the processor seems to hang at startup. It will not do anything.
GPIO_BOTH_EDGES allows the code to "run" to full execution.
This is very odd to me.
2.
The current set of code causes the Interrupt to fire continuously. The anemometer is not spinning.
With small code variations, the Interrupt will only fire as the anemometer is spinning; but, the Interrupt
fires hundres of times per revolution. Once the spin stops, the Interrupt stops firing. This
reminds me of a debounce issue.
Since I have the pull-down resistor in the circuit, I "thought" I could generally deal with the
"debounce" issue. Guess not.
3.
What does the following line of code do?
//HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M; // seems to have no affect.
I'm still new to this environment and the processor.
Any insight would be greatly appreciated.
Thank you.