标题:
LPC1768 GPIO中断实验 八个LED轮流点亮100毫秒
[打印本页]
作者:
wxy幻灭
时间:
2017-6-12 20:20
标题:
LPC1768 GPIO中断实验 八个LED轮流点亮100毫秒
路虎LPC1768开发板 GPIO实验
这个例程是将路虎开发板上的八个LED轮流点亮100毫秒,
采用SYStick 定时器中断方式做延时 系统时钟设置在100MHZ
使用时,短路JP8跳线使能LED。
单片机源程序如下:
/**************************************************************************//**
* @file main.c
* @brief CMSIS Cortex-M3 GPIO example
* a LED using CM3 SysTick
* @version V1.30
* @date 24. Jan 2010
*
* @note
* Copyright (C) 2009 ARM Limited. All rights reserved.
*
* @par
* ARM Limited (ARM) is supplying this software for use with Cortex-M
* processor based microcontrollers. This file can be freely distributed
* within development tools that are supporting such ARM based processors.
*
* @par
* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
* ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*
******************************************************************************/
#include "LPC17xx.h"
volatile uint32_t msTicks; /* counts 1ms timeTicks */
/*----------------------------------------------------------------------------
SysTick_Handler
*----------------------------------------------------------------------------*/
void SysTick_Handler(void) {
msTicks++; /* increment counter necessary in Delay() */
}
/*------------------------------------------------------------------------------
delays number of tick Systicks (happens every 1 ms)
*------------------------------------------------------------------------------*/
__INLINE static void Delay (uint32_t dlyTicks) {
uint32_t curTicks;
curTicks = msTicks;
while ((msTicks - curTicks) < dlyTicks);
}
/*------------------------------------------------------------------------------
configer LED pins
*------------------------------------------------------------------------------*/
__INLINE static void LED_Config(void) {
LPC_GPIO2->FIODIR = 0x000000ff; /* LEDs PORT2 are Output */
LPC_GPIO0->FIODIR = 0x00200000;
LPC_GPIO0->FIOPIN |= 0x00200000;
}
/*------------------------------------------------------------------------------
Switch on LEDs
*------------------------------------------------------------------------------*/
__INLINE static void LED_On (uint32_t led) {
LPC_GPIO2->FIOPIN |= (led); /* Turn On LED */
}
/*------------------------------------------------------------------------------
Switch off LEDs
*------------------------------------------------------------------------------*/
__INLINE static void LED_Off (uint32_t led) {
LPC_GPIO2->FIOPIN &= ~(led); /* Turn Off LED */
}
/*----------------------------------------------------------------------------
MAIN function
*----------------------------------------------------------------------------*/
int main (void) {
uint8_t location;
if (SysTick_Config(SystemCoreClock / 1000)) { /* Setup SysTick Timer for 1 msec interrupts */
while (1); /* Capture error */
}
LED_Config();
while(1)
{
LED_On (0xff);
Delay (500);
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
0.png
(64.84 KB, 下载次数: 156)
下载附件
2017-6-13 02:39 上传
所有资料51hei提供下载:
GPIO.rar
(163.57 KB, 下载次数: 18)
2017-6-12 20:20 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1