微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 基于LPC1114的学习型红外遥控器

基于LPC1114的学习型红外遥控器

时间:08-10 来源:互联网 点击:

烁灯的程序。

#include

#include

//---------------------------------------------------------

void sysint(void);

//---------------------------------------------------------

main(void)

{

uint32_t i;

/* Enable AHB clock to the GPIO domain. */

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);

/* Set up NVIC when I/O pins are configured as external interrupts. */

NVIC_EnableIRQ(EINT0_IRQn);

NVIC_EnableIRQ(EINT1_IRQn);

NVIC_EnableIRQ(EINT2_IRQn);

NVIC_EnableIRQ(EINT3_IRQn);

LPC_GPIO0->DIR=0xFF;

while(1)

{

LPC_GPIO0->DATA=~LPC_GPIO0->DATA;

i=300000;

while(i--);

}

}

//---------------------------------------------------------

void sysint (void)

{

// uint32_t i;

#ifdef __DEBUG_RAM

LPC_SYSCON->SYSMEMREMAP = 0x1; /* remap to internal RAM */

#else

#ifdef __DEBUG_FLASH

LPC_SYSCON->SYSMEMREMAP = 0x2; /* remap to internal flash */

#endif

#endif

#if (CLOCK_SETUP) /* Clock Setup */

/* bit 0 default is crystal bypass,

bit1 0=0~20Mhz crystal input, 1=15~50Mhz crystal input. */

LPC_SYSCON->SYSOSCCTRL = 0x00;

/* main system OSC run is cleared, bit 5 in PDRUNCFG register */

LPC_SYSCON->PDRUNCFG &= ~(0x1<<5);

/* Wait 200us for OSC to be stablized, no status

indication, dummy wait. */

for ( i = 0; i < 0x100; i++ );

#if (MAIN_PLL_SETUP)

Main_PLL_Setup();

#endif

#endif /* endif CLOCK_SETUP */

/* System clock to the IOCON needs to be enabled or

most of the I/O related peripherals won't work. */

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);

return;

}

心情:利用了2天的业余时间,终于LED灯闪亮了,感觉LPC1114的功能真的很强大,比一般的51单片机复杂的多。以后要多努力学习了。

不知不觉已经11点多了。在喝一瓶,洗洗睡了。

GPIO"库"函数中文说明

NXP的LPC11XX功能很强大。"库"函数也非常多,功能也很强大,充分理解"库"函数能帮助我们快速学习LPC11XX,下面是英文和中文"库"函数的翻译,希望能帮助大家快速学习LPC11XX,以后我会抽出时间,翻译其他功能的"库"函数。

/*****************************************************************************

* gpio.c: GPIO C file for NXP LPC11xx Family Microprocessors

*

* Copyright(C) 2008, NXP Semiconductor

* All rights reserved.

*

* History

* 2008.07.20 ver 1.00 Prelimnary version, first Release

*

*****************************************************************************/

#include "LPC11xx.h" /* LPC11xx Peripheral Registers */

#include "gpio.h"

/* Shadow registers used to prevent chance of read-modify-write errors */

/* Ultra-conservative approach... */

volatile uint32_t GPIOShadowPort0;

volatile uint32_t GPIOShadowPort1;

volatile uint32_t GPIOShadowPort2;

volatile uint32_t GPIOShadowPort3;

volatile uint32_t gpio0_counter = 0;

volatile uint32_t gpio1_counter = 0;

volatile uint32_t gpio2_counter = 0;

volatile uint32_t gpio3_counter = 0;

volatile uint32_t p0_1_counter = 0;

volatile uint32_t p1_1_counter = 0;

volatile uint32_t p2_1_counter = 0;

volatile uint32_t p3_1_counter = 0;

/*****************************************************************************

** Function name: PIOINT0_IRQHandler

**

** Descriptions: Use one GPIO pin(port0 pin1) as interrupt source

**

** parameters: None

** Returned value: None

**

*****************************************************************************/

void PIOINT0_IRQHandler(void)

{

uint32_t regVal;

gpio0_counter++;

regVal = GPIOIntStatus( PORT0, 1 );

if ( regVal )

{

p0_1_counter++;

GPIOIntClear( PORT0, 1 );

}

return;

}

/*****************************************************************************

** Function name: PIOINT1_IRQHandler

**

** Descriptions: Use one GPIO pin(port1 pin1) as interrupt source

**

** parameters: None

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top