IAP LPC 8000
来源:互联网 发布:01年总决赛艾弗森数据 编辑:程序博客网 时间:2024/04/29 23:42
Cannot access Memory
*** error 122: AGDI: memory read failed (0xFFFFFFFE)
Cannot access Memory
Cannot access Memory
Cannot access Memory
Cannot access Memory
WS 1, `adr
1.设置
2. IAP flash地址 请参考 LPC812的Datasheet,我们用的芯片的 Flash是 16M的
注意Datasheet规定: 最小擦写单位是 one page, 1page分为64Byte, 按page擦除 所以 最小擦除擦写的起始地址必须是sector 或者page的起始地址(我用的sector起始地址,但是一定要注意,这片地址内没有你写的程序,否则会把自己download到flash中的程序给擦除了,一定要不能和自己的程序代码空间重合)
原文:The size of a sector is 1KB and the size of a page is 64Byte. One Sector contains 16 pages.
//uint32_t IAP_FLASH_ADDRESS_3rd_SECTOR 0x0c00 //Flash 3th Sector, 48th page, address 0x0c00 ,只要是sector或者页起始地址就行
//uint32_t IAP_FLASH_ADDRESS = 0x1c00; //Flash 7th Sector, 112th page, address 0x1c00
uint32_t IAP_FLASH_ADDRESS = 0x3C00; //Flash 15th Sector,240th page, address 0x3c00
3. 函数
主函数的部分配置
SystemCoreClockUpdate();
// remap to show all of Flash
LPC_SYSCON->SYSMEMREMAP = 2;
CLKOUT_Setup( CLKOUTCLK_SRC_MAIN_CLK );
api函数:
/*
* Program Data in Flash Memory
* Parameter: adr: Destination Start Address
* sz: Data Size
* buf: Source Data
* Return Value: 0 - OK, 1 - Failed
*/
int Program (uint32_t adr, uint32_t sz, uint8_t *buf)
{
uint32_t n;
#if SET_VALID_CODE != 0 // Set valid User Code Signature
if (adr == 0) { // Check for Vector Table
n = *((uint32_t *)(buf + 0x00)) +
*((uint32_t *)(buf + 0x04)) +
*((uint32_t *)(buf + 0x08)) +
*((uint32_t *)(buf + 0x0C)) +
*((uint32_t *)(buf + 0x10)) +
*((uint32_t *)(buf + 0x14)) +
*((uint32_t *)(buf + 0x18));
*((uint32_t *)(buf + 0x1C)) = 0 - n; // Signature at Reserved Vector
}
#endif
n = GetSecNum(adr); // Get Sector Number
IAP.cmd = IAP_PREPARE; // Prepare Sector for Write
IAP.par[0] = n; // Start Sector
IAP.par[1] = n; // End Sector
IAP_Call (&IAP.cmd, &IAP.stat); // Call IAP Command
if (IAP.stat) return (IAP.stat); // Command Failed
IAP.cmd = IAP_COPY_RAM2FLASH; // Copy RAM to Flash
IAP.par[0] = adr; // Destination Flash Address
IAP.par[1] = (uint32_t)buf; // Source RAM Address
IAP.par[2] = sz; // Number of bytes
IAP.par[3] = SystemCoreClock / 1000; // CCLK in kHz
IAP_Call (&IAP.cmd, &IAP.stat); // Call IAP Command
if (IAP.stat) return (IAP.stat); // Command Failed
return (0); // Finished without Errors
}
int EraseAllPage(void)
{
IAP.cmd = IAP_PREPARE; // Prepare Sector for Erase
IAP.par[0] = 0; // Start Sector
IAP.par[1] = 15; // End Sector
IAP_Call (&IAP.cmd, &IAP.stat); // Call IAP Command
if (IAP.stat) return (IAP.stat); // Command Failed
IAP.cmd = IAP_ERASE_PAGE; // Erase Page
IAP.par[0] = 0; // Start page
IAP.par[1] = 255; // End page
IAP.par[2] = SystemCoreClock / 1000; // CCLK in kHz
IAP_Call (&IAP.cmd, &IAP.stat); // Call IAP Command
if (IAP.stat) return (IAP.stat); // Command Failed
return (0); // Finished without Errors
}
- IAP LPC 8000
- LPC
- iap
- IAP
- IAP
- IAP
- IAP
- IAP
- LPC-10
- Windows LPC
- LPC入门教程
- LPC 函数
- LPC Communication
- LPC Function
- 详解LPC
- LPC排行榜
- LPC继承的例子
- lpc单片机使用指南-----序
- 查看oracle数据库字符集---修改
- Keil中将HEX文件转化为BIN文件
- Oracle语法温故(for循环、while循环、if else 、方法声明、调用,过程方法声明、调用)
- Oracle中用exp/imp命令快速导入导出数据
- 程序员——伤不起的三十岁
- IAP LPC 8000
- 标准库循环队列应用
- 2013年3月15日 工作总结
- io流 1
- 类成员函数的地址
- 头文件和.a(库文件不匹配)导致虚函数错位,进而导致的bug
- 2013年03月18日 工作总结
- 用Raspberry Pi和乐高打造廉价超级计算机
- 最近一周生日提醒