在线时间1127 小时
UID1694538
注册时间2018-5-21
NXP金币5784
TA的每日心情 | 奋斗 昨天 12:29 |
---|
签到天数: 2492 天 连续签到: 117 天 [LV.Master]伴坛终老
金牌会员
 
- 积分
- 15022
- 最后登录
- 2025-8-30
|
下载完“开发板资料打包.rar”后解压,里头有丰富的demo实例,有针对Keil编译环境的工程,也有针对IAR集成开发环境的工程,在这里本人搭建的是基于Keil编译的集成开发环境,进入“.\lpcopen_3_03_keil_iar_lpcxpresso_11u68\lpc11u6x\prj_xpresso11u68\keil”我们可以发现有多个Keil工程,打开进入,激活工程后才能加载库文件,在这里不再赘述有关如何设置编译环境的详细细节,只是简单的截了几张图,供大家参考。
部分稍调后的代码:
void SysTick_Handler(void)
{
static unsigned char cnt = 0;
static unsigned char quickCnt = 0;
quickCnt++;
if (quickCnt > 100) {
quickCnt = 0;
if (ledCnt == true) {
switch (cnt) {
case 0:
Board_LED_Set(0, false);
Board_LED_Set(1, false);
Board_LED_Set(2, false);
break;
case 1:
Board_LED_Set(1, false);
Board_LED_Set(0, false);
Board_LED_Set(2, false);
break;
case 2:
Board_LED_Set(2, true);
Board_LED_Set(1, false);
Board_LED_Set(1, false);
break;
default:
cnt = 0;
break;
}
cnt++;
if (cnt > 2) {
cnt = 0;
}
}
}
}
int main(void)
{
SystemCoreClockUpdate();
Board_Init();
Chip_GPIO_SetPinDIRInput(LPC_GPIO, BLINK_SWITCH_PORT, BLINK_SWITCH_BIT);
Chip_GPIO_SetPinDIRInput(LPC_GPIO, CYCLE_SWITCH_PORT, CYCLE_SWITCH_BIT);
ledCnt = true;
/* Enable and setup SysTick Timer at a periodic rate */
SysTick_Config(SystemCoreClock / TICKRATE_HZ1 / 10);
/* Enable the RTC oscillator, oscillator rate can be determined by
calling Chip_Clock_GetRTCOscRate() */
Chip_Clock_EnableRTCOsc();
/* Initialize RTC driver (enables RTC clocking) */
Chip_RTC_Init(LPC_RTC);
/* Enable RTC as a peripheral wakeup event */
Chip_SYSCTL_EnablePeriphWakeup(SYSCTL_WAKEUP_RTCINT);
/* RTC reset */
Chip_RTC_Reset(LPC_RTC);
/* Start RTC at a count of 0 when RTC is disabled. If the RTC is enabled, you
need to disable it before setting the initial RTC count. */
Chip_RTC_Disable(LPC_RTC);
Chip_RTC_SetCount(LPC_RTC, 0);
/* Set a long alarm time so the interrupt won't trigger */
Chip_RTC_SetAlarm(LPC_RTC, 3000);
/* Enable RTC and high resolution timer - this can be done in a single
call with Chip_RTC_EnableOptions(LPC_RTC, (RTC_CTRL_RTC1KHZ_EN | RTC_CTRL_RTC_EN)); */
Chip_RTC_Enable1KHZ(LPC_RTC);
Chip_RTC_Enable(LPC_RTC);
/* Clear latched RTC interrupt statuses */
Chip_RTC_ClearStatus(LPC_RTC, (RTC_CTRL_OFD | RTC_CTRL_ALARM1HZ | RTC_CTRL_WAKE1KHZ));
/* Enable RTC interrupt */
NVIC_EnableIRQ(RTC_IRQn);
/* Enable RTC alarm interrupt */
Chip_RTC_EnableWakeup(LPC_RTC, (RTC_CTRL_ALARMDPD_EN | RTC_CTRL_WAKEDPD_EN));
while (1) {
rtcWake = rtcAlarm = false;
/* If blink switch is pressed... */
if ((Chip_GPIO_GetPinState(LPC_GPIO, BLINK_SWITCH_PORT, BLINK_SWITCH_BIT)) == false) {
/* If currently cycling... */
if (ledCnt != false) {
/* Turn off all LEDs. */
Board_LED_Set(0, false);
Board_LED_Set(1, false);
Board_LED_Set(2, false);
/* Set RTC to wake in one second. */
Chip_RTC_SetWake(LPC_RTC, 1000);
}
/* Stop cycling... */
ledCnt = false;
}
/* If cycle switch is pressed... */
if ((Chip_GPIO_GetPinState(LPC_GPIO, CYCLE_SWITCH_PORT, CYCLE_SWITCH_BIT)) == false) {
/* Start cycling... */
ledCnt = true;
}
__WFI();
}
return 0;
}
|
-
-
-
-
-
-
小测视频.zip
622.2 KB, 下载次数: 0, 下载积分: 威望 1
暂时没有注册优酷账号,将就以附件的形式上传了
|