Hi,
I am using this board: LPCXpresso board for LPC1769 with CMSIS DAP probe | NXP
and MCUXpresso. Currently I try to let the LED blink. I can connect with the board and debugging, but nothing happens, even when ein use the "Board_LED_Set" funktion. MCUXpresso and the Debugger are showing, that values in the GPIO Registers are changed. Anyone a suggestion?
Best Regards
Michael
Hello xiangjun.rong
I allready tried to activate just pin 22 port 0, but it did not work. Your code is working, but when I remove this part from the while-loop-body:
LPC_GPIO[0].SET |= 1<<22;
delay();
LPC_GPIO[0].CLR |= 1<<22;
delay();
The LED is not set on, but this code part, bevor the while-loop should do this:
LPC_GPIO[0].MASK = 0x00000000;
LPC_GPIO[0].DIR |= 1<<22;
LPC_GPIO[0].SET = 1<<22;
Any ideas why the LED is not set on for once and keeps on?
Hi, Ben,
for the following code:
while(1) {
LPC_GPIO[0].SET = 1<<22;
delay();
//LPC_GPIO[0].CLR = 1<<22;
delay();
i++ ;
}
If you comment one LPC_GPIO[0].SET = 1<<22; or LPC_GPIO[0].CLR = 1<<22;, the LED will keep ONE state for example on or off forever.
BR
XiangJun Rong
Hi, Michael,
I think it is okay to put the line LPC_GPIO[0].SET = 1<<22; out of while loop, after the line is executed, the GPIO pin will be high. You can set a break point, and run the line step by step.
BR
XiangJun Rong
Hello Michael Petersen,
You can first try the demo "periph_blinky" under LPCopen, I have test it on my side ,it can work well.
Then compare the configuration with yours.
LPCOpen Software for LPC17XX | NXP
Hope it helps,
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hi, Michael,
From your following code, it appears that the LED is connected to P0_22(GPIO0_22), if it is the case, pls use the code.
anyway, pls check which pin is connected to LED.
BR
XiangJun Rong
int main(void) {
#if defined (__USE_LPCOPEN)
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
#if !defined(NO_BOARD_LIB)
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
// Set the LED to the state of "On"
Board_LED_Set(0, true);
#endif
#endif
// Chip_GPIO_WriteDirBit(LPC_GPIO, 3, 26, true);
// Chip_GPIO_WritePortBit(LPC_GPIO, 3, 26, true);
LPC_IOCON->PINSEL[1] &= !(1 << 12);
LPC_IOCON->PINSEL[1] &= !(1 << 13);
LPC_IOCON->PINMODE[1] &= !(1 << 12);
LPC_IOCON->PINMODE[1] &= !(1 << 13);
LPC_GPIO[0].MASK = 0x00000000;
LPC_GPIO[0].DIR |= 1<<22;
LPC_GPIO[0].SET = 1<<22;
// LPC_GPIO[3].MASK = 0x00000000;
// LPC_GPIO[3].DIR = 0xFFFFFFFF;
// LPC_GPIO[3].SET = 0xFFFFFFFF;
volatile uint32_t check = LPC_GPIO[0].PIN & 0x00400000;
// Force the counter to be placed into memory
volatile static int i = 0 ;
// Enter an infinite loop, just incrementing a counter
while(1) {
LPC_GPIO[0].SET = 1<<22;
delay();
LPC_GPIO[0].CLR = 1<<22;
delay();
i++ ;
}
return 0 ;
}
void delay(void)
{
unsigned int j;
j=0;
for(unsigned int i=0; i<100000;i++)
{
j++;
}
}