Hi All,
I am new to using LPC812.
I am thinking of a program that blinks an LED when a button is pressed.
LEDs are connected to PIO0_0 and buttons are connected to PIO0_14.
This is the program I came up with.
int main(void) {
SystemCoreClockUpdate();
SysTick_Config( SYSTICK_DELAY );
GPIOInit();
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
LPC_GPIO_PORT->DIR0 |= (1<<0);
LPC_GPIO_PORT->DIR0 &=~ (1<<14);
volatile int8_t SW1 = 1;
while(1) {
SW1 = (LPC_GPIO_PORT->PIN0 & (1<<14));
if(SW1 == 0){
LPC_GPIO_PORT->SET0 |= (1<<0);
delaySysTick(100);
LPC_GPIO_PORT->CLR0 |= (1<<0);
delaySysTick(100);
}
else{
LPC_GPIO_PORT->CLR0 |= (1<<0);
}
}
return 0 ;
}
However, this program did not work.
I think the pin is not set up correctly, but I would like to know.
Hello ,
Recommend you refer to the gpio demo under LPC824 SDK.
Also set breakpoint to while function, check whether it can enter while when press button.
BR
Alice