I am trying to read input PA2 on the TIVA device every 100ms, using a SW timer, storing the 1/0 value in a 16-bit shift register. I am sending in a 5Hz square wave from a frequency generator. The shift register toggles between 0xAAAA and 0x5555, but every so often a string of 0's is read and the shift register changes to 0x0000. I've logged a max of 22 consecutive 0's from the read. The consecutive 0's occur randomly, sometimes only 7 seconds apart, and sometimes 65 seconds apart.
The PA2 pin is defined this way in file pin_mux.c
// Enable pin PA2, PA3, PA4, PA5, PA6 for GPIOInput
MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE,
(GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6));
The pin is read this way
BT_stat_val = ((GPIOPinRead(GPIO_PORTA_BASE, PA2_BLUETOOTH_STAT) & PA2_BLUETOOTH_STAT) >> 2);
if (BT_stat_val == 0)
consecutive_0s++;
else
consecutive_0s = 0;
I'm looking for a reason why GPIOPinRead is reading the sequence of 0's. I've verified the input signal on a scope and it's a continuous square wave. Is it possible I'm trying to read the input too fast?