DSP6713 CE1#不拉低
时间:10-02
整理:3721RD
点击:
在家,我用的是DSP6713,在CE1空间接了一个Flash:AM29LV160D,但不知道为什么不论擦除,还是读写,CE1#片选信号都不拉低,请问哪些原因会导致这个问题?
下面是我的程序:
主程序:
- Flash_StartAdd = 0x90000000;
- flash_chip_erase();
- printf("Finish flash erase!\n");// 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.\n");// 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!\n");
- printf("Address 0x%x is error! Data is 0x%x\n",i,data);
- exit(0);
- }
- }
- printf("Opereation is success.\n");
- #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));
- }
这个是因为地址计算错误,没有写到0x90000000CE1空间去……