【LPC54102】LPC54102+初探IO口的使用
[复制链接]
LPC54102的板子已经申请到有一个月了,由于最近一直忙着赶论文,所以一直没有好好地玩她,实在抱歉!
万利的这款板子使用的是64引脚封装的LPC54102,可以使用串口下载,SWD下载,和jlink下载三种下载方式,使用方便。另外还将所有的引脚都印了出来,方便调试使用。
LPC54102的IO口可以做为上拉、下拉输入输出,也可设置为开漏输出,还可以设置为翻转功能,
利用万利官网给出的例程,更改参数的配置,对io口的输出进行配置,源程序为:
#define _MAIN_C_
#include "chip.h"
#include "stdint.h"
#include "main.h"
#include "chip.h"
#include "stdint.h"
#include "board_pinmuxing.h"
//#include "board_led.h"
#include "glcd.h"
#include "board_led.h"
#include "utility.h"
#define TICKRATE_HZ1 (1)/* 1 ticks per second */
#define TICKRATE_HZ2 (2)/* 2 ticks per second */
#define PRESCALE_HZ2 (0xFFFF) /* 16-bit prescale count */
volatile uint32_t SYS_ms = 0;
void SysTick_Handler ( void )
{
SYS_ms++;
}
void delay(int count)
{
int i=0;
int j=0;
for(i=0;i
for(j=0;j<20000;j++);
}
int32_t Board_LED_SetBitState ( uint32_t bitn, uint32_t sta )
{
int32_t retval = 1;
switch ( bitn ) {
case 0:
(sta > 0) ? Chip_GPIO_SetPinState(LPC_GPIO, 0, 30, true)
: Chip_GPIO_SetPinState(LPC_GPIO, 0, 30, false);
break;
case 1:
(sta > 0) ? Chip_GPIO_SetPinState(LPC_GPIO, 0, 29, true)
: Chip_GPIO_SetPinState(LPC_GPIO, 0, 29, false);
break;
case 2:
(sta > 0) ? Chip_GPIO_SetPinState(LPC_GPIO, 0, 8, true)
: Chip_GPIO_SetPinState(LPC_GPIO, 0, 8, false);
break;
case 3:
(sta > 0) ? Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, true)
: Chip_GPIO_SetPinState(LPC_GPIO, 0, 7, false);
break;
default:
retval = 0;
}
return retval;
}
int32_t main(void) {
uint32_t timerBaseClock;
// Setup SystemCoreClock and any needed board code
SystemCoreClockUpdate();
SysTick_Config(SystemCoreClock/1000);
Board_SetupMuxing();
Board_LED_Init ();
while (1)
{
delay(1000);
Board_LED_SetBitState ( 0, 1 );
delay(1000);
Board_LED_SetBitState ( 1, 1 );
//Board_LED_SetBitState ( 1, 0 );
delay(1000);
Board_LED_SetBitState ( 2, 1 );
delay(1000);
Board_LED_SetBitState ( 3, 1 );
// Board_LED_SetBitState ( 1, 1 );
// Board_LED_SetBitState ( 2, 1 );
delay(1000);
Board_LED_SetBitState ( 0, 0 );
delay(1000);
Board_LED_SetBitState ( 1, 0 );
//Board_LED_SetBitState ( 1, 0 );
delay(1000);
Board_LED_SetBitState ( 2, 0 );
delay(1000);
Board_LED_SetBitState ( 3, 0 );
// Board_LED_SetBitState ( 1, 1 );
// Board_LED_SetBitState ( 2, 0 );
}
}
其调试i效果为:
点亮一个LED:
流水灯:
以前没有接触过LPC的芯片,一切都是从头学习的,以后有学习心得和问题都会来这里分享和提问的…………………………
|