路虎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);
……………………
上一篇:LPC2148的ADC多通道数据采集程序
下一篇:用ARM点亮一个led并闪烁
推荐阅读最新更新时间:2024-11-05 15:52
设计资源 培训 开发板 精华推荐
- AS15-USB-T3串口模块转接板
- 当 LTC2380HMS-16 中启用数字增益压缩时,使用 LT6350 的典型应用被配置为接受 ±10V 输入信号,同时运行一个 5.5V 单电源
- 带EV-VN7xxx连接器的盲点教育工具连接器板
- 用于汽车照明的 21-LED 通用 LED 驱动器
- OP184ESZ-REEL输出过载恢复运放测试电路典型应用
- AD9850 完整的直接数字合成器,125000KHz 晶体振荡器
- 使用 NXP Semiconductors 的 MPC5553 的参考设计
- ADR421 超精密、低噪声、2.048 Vout XFET 电压基准作为精密升压输出稳压器的典型应用
- MPC5748G安全以太网网关参考设计
- USB2.0扩展坞