LPCXpresso-CN-1227这个板子使用的万利的MLINK仿真器,使用IAR编程环境,下载时出现问题,一直不能下载进Flash,弄了几天,无果,遂采用ISP的方式进行下载,但是这样就不能Debug,先只能这样用了。
/* Includes ------------------------------------------------------------------*/
#include "lpc12xx_libcfg.h"
/* Private define ------------------------------------------------------------*/
/* Number of user LEDs */
#define LED_NUM 4
const unsigned long led_mask[] = { 4, 5, 6,7};
/* Private variables ---------------------------------------------------------*/
/* SysTick Counter */
volatile unsigned long SysTickCnt;
/* Private functions ---------------------------------------------------------*/
void SysTick_Handler (void);
void Delay (unsigned long tick);
/**
* @brief SysTick handler sub-routine (1ms)
* @paramNone
* @return None
*/
void SysTick_Handler (void) {
SysTickCnt++;
}
/**
* @brief Delay function
* @paramtick - number milisecond of delay time
* @returnNone
*/
void Delay (unsigned long tick) {
unsigned long systickcnt;
systickcnt = SysTickCnt;
while ((SysTickCnt - systickcnt) < tick);
}
/**
* @brief Main program body
* @param None
* @return int
*/
int main (void)
{ /* Main Program */
int num = -1;
IOCON_PIO_CFG_Type PIO_mode;
SystemInit(); /* 系统时钟初始化 */
SysTick_Config(SystemCoreClock/1000 - 1); /* Generate interrupt each 1 ms */
SYS_ConfigAHBCLK(SYS_AHBCLKCTRL_GPIO0, ENABLE);
IOCON_StructInit(&PIO_mode);
PIO_mode.type = IOCON_PIO_0_4;
IOCON_SetFunc(&PIO_mode);
PIO_mode.type = IOCON_PIO_0_5;
IOCON_SetFunc(&PIO_mode);
PIO_mode.type = IOCON_PIO_0_6;
IOCON_SetFunc(&PIO_mode);
PIO_mode.type = IOCON_PIO_0_7;
IOCON_SetFunc(&PIO_mode);
GPIO_SetDir(LPC_GPIO0, 4, 1);
GPIO_SetDir(LPC_GPIO0, 5, 1);
GPIO_SetDir(LPC_GPIO0, 6, 1);
GPIO_SetDir(LPC_GPIO0, 7, 1);
GPIO_SetLowLevel(LPC_GPIO0, 4, 1);
GPIO_SetLowLevel(LPC_GPIO0, 5, 1);
GPIO_SetLowLevel(LPC_GPIO0, 6, 1);
GPIO_SetLowLevel(LPC_GPIO0, 7, 1);
for (;;)
{ /* Loop forever */
num += 1;
if (num == LED_NUM)
{
num =0;
}
GPIO_SetHighLevel(LPC_GPIO0, led_mask[num],1);
Delay(500); /* Delay 500ms */
GPIO_SetLowLevel(LPC_GPIO0, led_mask[num],1);
Delay(500); /* Delay 500ms */
}
}