共2条
1/1 1 跳转至页
IAP 贴个程序,请教关于IAP的问题,现在无法写入。
问
__asm{ //关闭中断
MSR CPSR_c,0xdf
}
PLLCON=0; //关闭PLL
PLLFEED=0xaa;
PLLFEED=0x55;
MAMCR=0; //关闭MAM
select_sector(8,8);
erase_sector(8,8);
select_sector(8,8);
ram_to_flash(0x00010000,(uint32)text,1024);
PLLCON=1;
PLLFEED=0xaa;
PLLFEED=0x55;
while((PLLSTAT&(1<<10))==0);
PLLCON=3;
PLLFEED=0xaa;
PLLFEED=0x55; //打开PLL
MAMCR=2; //打开MAM
__asm{ //打开中断
MSR CPSR_c,0x5f
}
void select_sector(unsigned long start_sector,
unsigned long end_sector)
{
command[0]=IAP_SELSECTOR;
command[1]=start_sector;
command[2]=end_sector;
iap_entry(command,result);
}
void ram_to_flash(unsigned long flash_addr,
unsigned long ram_addr,
unsigned long count)
{
command[0]=IAP_RAMTOFLASH;
command[1]=flash_addr;
command[2]=ram_addr;
command[3]=count;
command[4]=IAP_FCCLK;
iap_entry(command,result);
}
/*************************************************
Function:erase_sector()
Description:擦除扇区
Input:start_sector,end_sector
Output:none
*************************************************/
void erase_sector(unsigned long start_sector,
unsigned long end_sector)
{
command[0]=IAP_ERASESECTOR;
command[1]=start_sector;
command[2]=end_sector;
command[3]=IAP_FCCLK;
iap_entry(command,result);
}
尝试了很多次都没有成功,重新开机后读出来的全是FF。已经在编译器里勾选了ARM/THUMB interworking (包括汇编器、ARM C编译器、THUMB C编译器)
请不吝赐教!
答 1: 有一些进展了,但是还有不明白的地方执行ram_to_flash()后返回错误代码SRC_ADDR_ERROR,即源地址text[]没有字对齐。text[]我定义成字节数组uint8 text[1024],改成uing32 text[1024]就可以IAP写入了。可是我不明白的是,调用函数的时候是(uint32)text,难道这样还不能字对齐吗?
MSR CPSR_c,0xdf
}
PLLCON=0; //关闭PLL
PLLFEED=0xaa;
PLLFEED=0x55;
MAMCR=0; //关闭MAM
select_sector(8,8);
erase_sector(8,8);
select_sector(8,8);
ram_to_flash(0x00010000,(uint32)text,1024);
PLLCON=1;
PLLFEED=0xaa;
PLLFEED=0x55;
while((PLLSTAT&(1<<10))==0);
PLLCON=3;
PLLFEED=0xaa;
PLLFEED=0x55; //打开PLL
MAMCR=2; //打开MAM
__asm{ //打开中断
MSR CPSR_c,0x5f
}
void select_sector(unsigned long start_sector,
unsigned long end_sector)
{
command[0]=IAP_SELSECTOR;
command[1]=start_sector;
command[2]=end_sector;
iap_entry(command,result);
}
void ram_to_flash(unsigned long flash_addr,
unsigned long ram_addr,
unsigned long count)
{
command[0]=IAP_RAMTOFLASH;
command[1]=flash_addr;
command[2]=ram_addr;
command[3]=count;
command[4]=IAP_FCCLK;
iap_entry(command,result);
}
/*************************************************
Function:erase_sector()
Description:擦除扇区
Input:start_sector,end_sector
Output:none
*************************************************/
void erase_sector(unsigned long start_sector,
unsigned long end_sector)
{
command[0]=IAP_ERASESECTOR;
command[1]=start_sector;
command[2]=end_sector;
command[3]=IAP_FCCLK;
iap_entry(command,result);
}
尝试了很多次都没有成功,重新开机后读出来的全是FF。已经在编译器里勾选了ARM/THUMB interworking (包括汇编器、ARM C编译器、THUMB C编译器)
请不吝赐教!
答 1: 有一些进展了,但是还有不明白的地方执行ram_to_flash()后返回错误代码SRC_ADDR_ERROR,即源地址text[]没有字对齐。text[]我定义成字节数组uint8 text[1024],改成uing32 text[1024]就可以IAP写入了。可是我不明白的是,调用函数的时候是(uint32)text,难道这样还不能字对齐吗?
共2条
1/1 1 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 在K230DBOX上实现多时段语音提示功能被打赏¥14元 | |
| 使K230DBOX实现相机持续拍照功能被打赏¥12元 | |
| 基于K230DBOX的文本管理器设计被打赏¥14元 | |
| 基于K230DBOX的彩色画板功能实现被打赏¥15元 | |
| 在K230DBOX上实现音乐播放器功能被打赏¥15元 | |
| NXP MCU系列开发板MCULink固件升级方法【VSCode】被打赏¥28元 | |
| 三分钟快速搭建NXP MCU开发环境(VSCode)被打赏¥22元 | |
| 为遥控小车巧添功能被打赏¥26元 | |
| 【S32K3XX】FlexCAN 模块配置使用被打赏¥30元 | |
| 【S32K3XX】FlexCAN RAM 资源分配整理被打赏¥25元 | |
我要赚赏金
