共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 跳转至页
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
电流检测模块MAX4080S被打赏10分 | |
【我踩过的那些坑】calloc和malloc错误使用导致跑飞问题排查被打赏50分 | |
多组DCTODC电源方案被打赏50分 | |
【我踩过的那些坑】STM32cubeMX软件的使用过程中的“坑”被打赏50分 | |
新手必看!C语言精华知识:表驱动法被打赏50分 | |
【我踩过的那些坑】杜绑线问题被打赏50分 | |
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 |