#define flash_start_address 0x8070000
void write_data(u16 number)
{u16 temp,appoint_address;
if(number<12)
{FLASH_Unlock();
FLASH_ErasePage(flash_start_address+number*0x800);
for(temp=0;temp<1024;temp++)
{appoint_address=flash_start_address+number*0x800+temp*2;
FLASH_ProgramHalfWord(appoint_address,prog_write_buffer[temp]);
}
FLASH_Lock();
}
}
void read_data(u16 number)
{u16 temp,appoint_address;
if(number<12)
{for(temp=0;temp<1024;temp++)
{appoint_address=number*0x800+temp*2;
prog_write_buffer[temp]=p_x[appoint_address]+(p_x[appoint_address+1]*0x100);
}
}
}
写地址flash_start_address+number*0x800+temp*2
读地址number*0x800+temp*2
程序开始地址是0x8040000 每次下载程序都不会擦除之前写入的数据,
说明数据是保存在了0x8000000 ~ 0x8040000,
但是写入的地址又是0x8070000+number*0x800+temp*2
|