DSP芯片用的是6713,flash用的是AM29LV400B,4M:256K*16bit。
擦除flash的时候要分别在下列地址写入如下值:
0x555:0xaa;
0x2aa:0x55;
0x555:0x80;
0x555:0xaa;
0x2aa:0x55;
0x555:0x10;
因为原理图上我们是DSP的A2与flash的EA0相连,DSP与16位flash相连时地址会自动左移1位,为了使DSP的最低地址位能输出在A2上,我们必须再手动移1位,即:
short * ctrl_addr1 = (short *) ((int)DSK6713_FLASH_BASE + (0x555<<1));
short * ctrl_addr2 = (short *) ((int)DSK6713_FLASH_BASE + (0x2aa<<1));
这个地方看下TI的资料比较容易理解,但是接下来我们往flash里写程序的时候,难道就不需要移位了吗?���理解的应该这样写才对:* (flash_ptr+(i<<1)) = * (source_ptr+i);可这样实际运行的结果却是错误的,通过CCS的memory窗口可以看到,这样写进去的数在CE1的地址0x90000000中并不连续,flash的空间会出现16bit间隔的空空间,而用* (flash_ptr+i) = * (source_ptr+i);写进flash的数据才是连续存储的,为什么会这样?求解?
#define DSK6713_FLASH_BASE 0x90000000
#define START_POINT 0x00000000
#define LENGTH 0x1700
1.擦除程序
void erase_flash()
{
short * ctrl_addr1 = (short *) ((int)DSK6713_FLASH_BASE + (0x555<<1));
short * ctrl_addr2 = (short *) ((int)DSK6713_FLASH_BASE + (0x2aa<<1));
* ctrl_addr1 = 0xaa;
* ctrl_addr2 = 0x55;
* ctrl_addr1 = 0x80;
* ctrl_addr1 = 0xaa;
* ctrl_addr2 = 0x55;
* ctrl_addr1 = 0x10;
}
2.flash写程序
void program_flash(unsigned short * source_ptr,unsigned short * flash_ptr,unsigned int length)
{
int i;
unsigned short data;
short * ctrl_addr1 = (short *) ((int)flash_ptr + (0x555 <<1));
short * ctrl_addr2 = (short *) ((int)flash_ptr + (0x2aa <<1));
for (i = 0; i < length; i++)
{
* ctrl_addr1 = 0xaa;
* ctrl_addr2 = 0x55;
* ctrl_addr1 = 0xa0;
* (flash_ptr+i) = data = * (source_ptr+i);
}
}
3.汇编启动一级BOOT程序:
mvkl BOOT_START,A4
mvkh BOOT_START,A4
mvkl FLASH_START,B4
mvkh FLASH_START,B4
mvkl BOOT_SIZE,B5
mvkh BOOT_SIZE,B5
zero A1
copy_loop1:
ldh *B4++, B0
nop 5
sth B0,*A4++
add A1,1,A1
cmplt A1,B5,B0
nop
[B0] b copy_loop1
nop 5
b copy_done
Thomas Yang1:
david
您好
你说的左移是系统自动完成的
不需要编程者考虑
你只需要在DSP/BIOS中设置对应的片选空间的寄存器就可以了