⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isp.c

📁 ARM LPC2000系列 从程序直接进入ISP模式
💻 C
字号:
/****************************************Copyright (c)**************************************************
**                Arzhiy Technologies Co.,LTD.
**                   
**                 http://arzhiy.21ic.org
**
********************************************************************************************************/

#undef MEMMAP
#define MEMMAP (*((volatile unsigned int *) 0xE01FC040))
#undef IODIR0
#define IODIR0 (*((volatile unsigned int *) 0xE0028008))
#undef IOCLR0
#define IOCLR0 (*((volatile unsigned int *) 0xE002800C))
#undef PINSEL0
#define PINSEL0 (*((volatile unsigned int *) 0xE002C000))
#undef VPBDIV
#define VPBDIV (*((volatile unsigned int *) 0xE01FC100))
#undef PLLCON
#define PLLCON (*((volatile unsigned int *) 0xE01FC080))
#undef PLLFEED
#define PLLFEED (*((volatile unsigned int *) 0xE01FC08C))
#undef VICINTENCLR
#define VICINTENCLR (*((volatile unsigned int *) 0xfffff014))
#undef TIMER1_PR
#define TIMER1_PR (*((volatile unsigned int *) 0xE000800C))
#undef TIMER1_MCR
#define TIMER1_MCR (*((volatile unsigned int *) 0xE0008014))
#undef TIMER1_CCR
#define TIMER1_CCR (*((volatile unsigned int *) 0xE0008028))


void (*bootloader_entry)(void);
unsigned long ISPtemp;
void ISPbyCode_init(void)
{
ISPtemp = PINSEL0;
/* Connect RXD0 & TXD0 pins to GPIO */
PINSEL0 = ISPtemp & 0xFFFFFFF3;

/* Select P0.14 as an output and P0.1 as an input */
ISPtemp = IODIR0;
ISPtemp = ISPtemp | 0x4000;
ISPtemp = ISPtemp & 0xFFFFFFFD;
IODIR0 = ISPtemp;

/* Clear P0.14 */
IOCLR0 = 0x4000;
//DelayNS(5000);


/* Disable Interrupts in the VIC*/
//VICINTENCLR=0x0FFFFFFFF;

VICIntEnClr = (1<<16)|(1<<17)|(1<<9); // 禁止EINT2、EINT3中断 I2C中断
VICIntEnClr = 0x00000040;      // 禁止UART0中断

/*
Disconnect PLL if you want to do ISP at crystal frequency.
Otherwise you need to pass the PLL freq when bootloader goes in
ISP mode.
cclk = crystal when PLL is disconnected
cclk = PLL freq when PLL is connected.
Disconnecting the PLL is recommended. */
PLLCON = 0x0;
PLLFEED = 0xAA;
PLLFEED= 0x55;

/*
Set the VPB divider to 1/4 if your application changes the VPBDIV value.
The bootloader is hard-coded to use the reset value of VPBDIV register
VPBDIV = 0x0;
*/
VPBDIV = 0x0;

/* Restore reset state of Timer1 */
TIMER1_PR=0x0;
TIMER1_MCR=0x0;
TIMER1_CCR=0x0;

/* Map bootloader vectors */
MEMMAP = 0x0;

/* Point to bootloader entry point i.e. reset vector 0x0 */
bootloader_entry = (void (*)(void))(0x0);
}
void ISPbyCode(void)
{
ISPbyCode_init();
while(1)
bootloader_entry();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -