在家,我用的是DSP6713,在CE1空间接了一个Flash:AM29LV160D,但不知道为什么不论擦除,还是读写,CE1#片选信号都不拉低,请问哪些原因会导致这个问题?
下面是我的程序:主程序:- Flash_StartAdd = 0x90000000;
- flash_chip_erase();
- printf("Finish flash erase!!
");// Write flash memory.
- for(i=0;i<0x400;i++)
- {
- data = i;//fmod(i,0x10000);
- addr = (Flash_StartAdd+2*i);
- Write_Flash_Word(&data,&addr);
- }
- printf("Write flash ok.
");// Read flash memory.
- for(i=0;i<0x400;i++)
- {
- addr = Flash_StartAdd+2*i;
- Read_Flash_Word(&data,&addr);
- if(data != fmod(i,0x10000))
- {
- printf(" Testing is Failure!
");
- printf("Address 0x%x is error! Data is 0x%x
",i,data);
- exit(0);
- }
- }
- printf("Opereation is success.
");
- #define FLASH_ADR1 (0x90000000+0x555<<1)
- #define FLASH_ADR2 (0x90000000+0x2AA<<1)
- #define Sourceaddr 0x90000000
- #define Toggle_Bit 0x80 //0x40 /* d6 = 1 */
- #define Hangup_Bit 0x20 /* d5 = 1 */
- #define Pass_Flag 0
- #define Fail_Flag 1
- void flash_chip_erase()
- {
- *(volatile Uint16*)FLASH_ADR1=0x012a;//0xaa;
- *(volatile Uint16*)FLASH_ADR2=0x0095;//0x55;
- *(volatile Uint16*)FLASH_ADR1=0x0100;//0x80;
- *(volatile Uint16*)FLASH_ADR1=0x012a;//0xaa;
- *(volatile Uint16*)FLASH_ADR2=0x0095;//0x55;
- *(volatile Uint16*)FLASH_ADR1=0x0010;//0x10;
- }
- int Toggle_Bit_Check(Uint16 *addr)
- {
- Uint16 toggle_data,read_data;
- toggle_data = *addr&Toggle_Bit;
- do{
- if(((read_data = *addr) &Toggle_Bit) == toggle_data)
- break;
- toggle_data = read_data & Toggle_Bit;
- }while((read_data&Hangup_Bit) != Hangup_Bit);
- toggle_data = *addr & Toggle_Bit;
- if(((read_data = *addr)&Toggle_Bit) != toggle_data)
- return (Fail_Flag);
- return (Pass_Flag);
- }
- int Write_Flash_Word(Uint16 *data,Uint16 *address)
- {
- *(volatile Uint16 *)FLASH_ADR1=0x012a;//0xaa;
- *(volatile Uint16 *)FLASH_ADR2=0x0095;//0x55;
- *(volatile Uint16 *)FLASH_ADR1=0x0120;//0xa0;
- *address=*data;
- return(Toggle_Bit_Check(address));
- }
- int Read_Flash_Word(Uint16 *data,Uint16 *address)
- {
- *(volatile Uint16 *)FLASH_ADR1=0x012a;//0xaa;
- *(volatile Uint16 *)FLASH_ADR2=0x0095;//0x55;
- *(volatile Uint16 *)FLASH_ADR1=0x01b0;//0xf0;
- *data=*address;
- return(Toggle_Bit_Check(address));
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>