Content originally posted in LPCWare by rcontrol on Sun Aug 31 00:02:15 MST 2014
Ha,Ha..... My wondering begins ceasing...
My mistake was that I put the GPIO port & bit value into the SCU setting function (enabling input buffer).
After studying NGX's example, I found that they used SCU port/bit values to set GPIO's properties.
As rocketdawg suggested, I add Chip_SCU_PinMuxSet function with SCU port&bit values.
Now even pGPIO-B[xx] values can be read well. Maybe in this aspect LPC43xx are different from LPC1769.
So all the test code works fine.
Many thanks to rocketdawg !!!
board.c =============================================================================
// In the original code, port&bit values are hard coded.
// but they defined the LED1_GPIO_PORT_NUM symbols in the board.h file.
static void Board_LED_Init()
{
Chip_SCU_PinMuxSet(LED1_SCU_PORT_NUM, LED1_SCU_BIT_NUM, SCU_MODE_INBUFF_EN); // I add this line
Chip_SCU_PinMuxSet(LED2_SCU_PORT_NUM, LED2_SCU_BIT_NUM, SCU_MODE_INBUFF_EN); // I add this line
/* P2.12 : LED D2 as output */
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED1_GPIO_PORT_NUM, LED1_GPIO_BIT_NUM);
/* P2.11 : LED D3 as output */
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, LED2_GPIO_PORT_NUM, LED2_GPIO_BIT_NUM);
/* Set initial states to off (true to disable) */
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED1_GPIO_PORT_NUM, LED1_GPIO_BIT_NUM, (bool) true);
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED2_GPIO_PORT_NUM, LED2_GPIO_BIT_NUM, (bool) true);
}
board.h ==============================================================================================
#define LED1_GPIO_PORT_NUM 2 // I am using the WaveShare' Open43xxB1 board. So this numbers are different from NGX board.
#define LED1_GPIO_BIT_NUM 8
#define LED1_SCU_PORT_NUM6
#define LED1_SCU_BIT_NUM12
#define LED2_GPIO_PORT_NUM 3
#define LED2_GPIO_BIT_NUM 7
#define LED2_SCU_PORT_NUM6
#define LED2_SCU_BIT_NUM11