共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 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 【S32DS】S32K3 RTD7.0.1 HSE 组件配置报错问题解决被打赏¥27元 | |
| 【S32K3XX】MCME 启动 CORE1被打赏¥23元 | |
| AG32VH407下温度大气压传感器及其检测被打赏¥20元 | |
| AG32VH407下光照强度传感器BH1750及其检测被打赏¥22元 | |
| AT32VH407下使用温湿度传感器DHT22进行检测被打赏¥20元 | |
| DIY一个婴儿澡盆温度计被打赏¥34元 | |
| 【FreeRtos】FreeRtos+MPU region 配置规则被打赏¥23元 | |
| 【分享开发笔记,赚取电动螺丝刀】三分钟快速上手驱动墨水屏(ArduinoIDE)被打赏¥28元 | |
| 【S32K3XX】LIN 通讯模块使用被打赏¥31元 | |
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
我要赚赏金
