图6 下载界面
在下载后,按下复位键即可见到运行效果。遗憾的是只有绿灯在闪亮,而红灯和蓝灯都退出了工作状态,那这是为什么呢?
看一下例程对3个LED的引脚定义如下:
#define TARGET_BOARD 824 // For the LPC824 Max board
// LPC824 Max board
#elif TARGET_BOARD == 824
#define RED (1<<12)
#define BLUE (1<<27)
#define GREEN (1<<16)
#define red_led_port P0_12
#define blue_led_port P0_27
#define green_led_port P0_16
#define TARGET_TX P0_7 // For the MBED serial port
#define TARGET_RX P0_18 // For the MBED serial port
#define NUM_IOCON_P0_SLOTS 31 // For looping through the pad controls
也就是说:
红灯连的PIO0_12、蓝灯连的PIO0_27、绿灯连的PIO0_16,然而再看一下开发板的原理图,参见图7所示。
其连接情况却是:
红灯连的PIO0_15、蓝灯连的PIO0_17、绿灯连的PIO0_16,只有绿灯是与程序相符合的,所以单有它的工作是正常就不难理解了。
图7 LED连接线路
将程序中的定义重新修改为如下的内容:
#define TARGET_BOARD 824 // For the LPC824 Max board
// LPC824 Max board
#elif TARGET_BOARD == 824
#define RED (1<<15) // (1<<12)
#define BLUE (1<<17) // (1<<27)
#define GREEN (1<<16)
#define red_led_port P0_15 // P0_12
#define blue_led_port P0_17 // P0_27
#define green_led_port P0_16
#define TARGET_TX P0_7 // For the MBED serial port
#define TARGET_RX P0_18 // For the MBED serial port
#define NUM_IOCON_P0_SLOTS 31 // For looping through the pad controls
重新再编译和下载,则会见到3个LED可以轮流闪动了。之所以出现这个情况,就是因为该例程并不是为本开发板而配置的,其目标板应是LPC824-MAX !