Hello Guys.
Debugging this code I encountered strange behaviour
CODE:
#include <stdint.h> #include <stdbool.h> #include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.c" #include "driverlib/sysctl.h" #include "driverlib/gpio.c" #include "driverlib/gpio.h" #define LED_PERIPH SYSCTL_PERIPH_GPIOF #define LED_BASE GPIO_PORTF_BASE #define RED_LED GPIO_PIN_1 #define Button_PERIPH SYSCTL_PERIPH_GPIOF #define ButtonBase GPIO_PORTF_BASE #define Button GPIO_PIN_4 #define Button2 GPIO_PIN_0 int main(void) { //Set the clock to 80Mhz SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); HWREG(GPIO_PORTF_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTF_BASE+GPIO_O_CR) |= GPIO_PIN_0; SysCtlPeripheralEnable(LED_PERIPH); SysCtlDelay(9); GPIOPinTypeGPIOInput(ButtonBase, Button); GPIOPinTypeGPIOInput(ButtonBase, Button2); GPIOPadConfigSet(ButtonBase ,Button,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); GPIOPadConfigSet(ButtonBase ,Button2,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); //When I comment out this line the LED blinks faster GPIOPinTypeGPIOOutput(LED_BASE, RED_LED); uint32_t value=0; uint8_t state=0; while(1){ value= GPIOPinRead(ButtonBase,Button); if( (value & GPIO_PIN_4)==0) state^=RED_LED; GPIOPinWrite(LED_BASE,RED_LED, state); SysCtlDelay(7000000); } }
When I comment out this line:
GPIOPadConfigSet(ButtonBase ,Button2,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
The LED is blinking faster then when the line is not commented.
Another think that bothers me - When I press the reset button of the Target Board the code crashes and never runs properly again. What might cause this? With the blinking led I don't have such a problem.
Thank you.