共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 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 基于MCP23S17的输入输出功能模块控制被打赏¥20元 | |
| 【S32K3XX】SPD 软件包使用Link文件修改被打赏¥22元 | |
| Switch-Case局部变量定义问题被打赏¥23元 | |
| 基于米尔TIAM62L开发板的串口通信及应用被打赏¥20元 | |
| PCF8574功能模块及其使用被打赏¥20元 | |
| 传感器LSM6DSO及LIS3MDL的功能检测被打赏¥18元 | |
| LPS25HB气压传感器及其检测被打赏¥18元 | |
| HTS221温湿度传感器及其检测被打赏¥18元 | |
| 【S32K3XX】HSE FW 版本更新被打赏¥21元 | |
| 基于ArduinoUNO开发板的AT24C02读写测试被打赏¥16元 | |
我要赚赏金
