Hi,
LPC chip is a new thing to me. I want to trig interrupt by a pin and interrupt will output wave from another pin. But I am stuck. The code is too different between LPC4370 and the MCU I used before.
I can't find an example code about GPIO interrupt. I did try Google but unfortunately, the codes I googled can't work on my board.
Can anyone please help me point out which documents should I read or where can I get an example code that can work on LPC4370?
Hello JiaAn,
Please download LPCopen for lpc4370, there is GPIO interrupt demo, you can directly run it on your chip.
Download from:
It support MCUXpresso IDE, KEIL, IAR, recommend the first one, it is free and support by NXP. After download , you can find the gpio demo.
Download IDE from: https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-i...
And in fact, if you install MCUxpresso IDE, the lpcopen is inside it by default, I take a video about how to open it under MCXUpresso IDE for you,
please see my attachment.
Hope it helps.
BR
Alice
@Alice_Yang Thank you so much. I found the example code and it really helped me!
But I still have two questions for that example code.
#define TEST_BUTTON_PORT 0
#define TEST_BUTTON_BIT 7
#define TEST_BUTTON_PIN_PORT 2
#define TEST_BUTTON_PIN_BIT 7
#define TEST_BUTTON_MODE_FUNC SCU_MODE_FUNC0
I found PIN_PORT and PIN_BIT on the datasheet. but I can't figure out what is TEST_BUTTON_PORT and TEST_BUTTON_BIT? And which document should I read for TEST_BUTTON_MODE_FUNC?
So I still need your help. And thank you for helping me
Hello JiaAn,
This just a defined name in the code, it is the same with PIN_PORT and PIN_BIT.
For example
#define TEST_BUTTON_PORT 0 ,
this means PORT0 .
#define TEST_BUTTON_MODE_FUNC SCU_MODE_FUNC0
This means config this pin as FUNC0. You can find
#define SCU_MODE_FUNC0 0x0 /*!< Selects pin function 0 */
BR
Alice
I just figure out that I can output GPIO by using these code:
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 3, 4); //Set pin direction
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 3, 4, false); // Output low
Chip_GPIO_SetPinState(LPC_GPIO_PORT, 3, 4, true); // Output high
But I still don't know how to use GPIO to trig interrupt. Still need help. Thanks.