LPC4357 开箱并体验

/ 0评 / 0

其实说开箱并不对,这是我自己Layout的板子,不过参考了不少人的例子.下载一下官方的例子.因为有很多个文件,所以... 提供链接:https://www.element14.com/community/docs/DOC-62633/l/element14-core-peripheral-drivers-for-lpc4357-evb-example-1
其他例子,也在附近的连接找的到.
QQ截图20160130160721
解压Examples1和Examples2两个文件,其中Examples1解压到当前文件夹,Examples2解压到下层文件夹.打开Gpio LedBlinky的例子.轻松看到直接执行c_entry程序:

/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
    return c_entry();
}

因为我是自己Layout的板子,所以需要修改才能用.我自己的用的是P9_4这个IO,高电平点亮.因为LPC这个MCU,P9_4并不等于GPIO9[4]的,所以还要查手册.这一点非常不友好.对应关系如图,查手册:
QQ截图20160130162345
所以设置scu时候,使用第四个复用,就GPIO功能,具体实现.

#define LED1_BIT			17 //LEDUSB
#define LED1_PORT			5
int c_entry (void) {                       /* Main Program                       */
	SystemInit();
	CGU_Init();
	scu_pinmux(0x9 ,4 , MD_PDN, FUNC4); 	// P8.1 : USB0_IND1 LED
	GPIO_SetDir(LED1_PORT,(1<<LED1_BIT), 1);
	// M3Frequency is automatically set when SetClock(BASE_M3_CLK... was called.
	SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE)/1000);  				// Generate interrupt @ 1000 Hz
	GPIO_ClearValue(LED1_PORT,(1<<LED1_BIT));
	while (1)
	{                           					// Loop forever
		msec = 100;
		while(msec);
		GPIO_ClearValue(LED1_PORT,(1<<LED1_BIT));
		msec = 100;
		while(msec);
		GPIO_SetValue(LED1_PORT,(1<<LED1_BIT));
	}
}

在下载时候,默认下载到M4内核,然后看到LED在闪烁.初次体验到此为止.一直想试试双核,不过比较难,而且各种限制,所以先学一下单核操作.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注