DSP6713 CE1#不拉低

2019-07-15 19:43发布

在家,我用的是DSP6713,在CE1空间接了一个Flash:AM29LV160D,但不知道为什么不论擦除,还是读写,CE1#片选信号都不拉低,请问哪些原因会导致这个问题?
下面是我的程序:主程序:
  1. Flash_StartAdd = 0x90000000;

  2. flash_chip_erase();
  3. printf("Finish flash erase!! ");// Write flash memory.
  4. for(i=0;i<0x400;i++)
  5. {
  6. data = i;//fmod(i,0x10000);
  7. addr = (Flash_StartAdd+2*i);
  8. Write_Flash_Word(&data,&addr);
  9. }
  10. printf("Write flash ok. ");// Read flash memory.
  11. for(i=0;i<0x400;i++)
  12. {
  13. addr = Flash_StartAdd+2*i;
  14. Read_Flash_Word(&data,&addr);
  15. if(data != fmod(i,0x10000))
  16. {
  17. printf(" Testing is Failure! ");
  18. printf("Address 0x%x is error! Data is 0x%x ",i,data);
  19. exit(0);
  20. }
  21. }
  22. printf("Opereation is success. ");
  23. #define FLASH_ADR1 (0x90000000+0x555<<1)
  24. #define FLASH_ADR2 (0x90000000+0x2AA<<1)
  25. #define Sourceaddr 0x90000000
  26. #define Toggle_Bit 0x80 //0x40 /* d6 = 1 */
  27. #define Hangup_Bit 0x20 /* d5 = 1 */
  28. #define Pass_Flag 0
  29. #define Fail_Flag 1
  30. void flash_chip_erase()
  31. {
  32. *(volatile Uint16*)FLASH_ADR1=0x012a;//0xaa;
  33. *(volatile Uint16*)FLASH_ADR2=0x0095;//0x55;
  34. *(volatile Uint16*)FLASH_ADR1=0x0100;//0x80;
  35. *(volatile Uint16*)FLASH_ADR1=0x012a;//0xaa;
  36. *(volatile Uint16*)FLASH_ADR2=0x0095;//0x55;
  37. *(volatile Uint16*)FLASH_ADR1=0x0010;//0x10;
  38. }
  39. int Toggle_Bit_Check(Uint16 *addr)
  40. {
  41. Uint16 toggle_data,read_data;
  42. toggle_data = *addr&Toggle_Bit;
  43. do{
  44. if(((read_data = *addr) &Toggle_Bit) == toggle_data)
  45. break;
  46. toggle_data = read_data & Toggle_Bit;
  47. }while((read_data&Hangup_Bit) != Hangup_Bit);
  48. toggle_data = *addr & Toggle_Bit;
  49. if(((read_data = *addr)&Toggle_Bit) != toggle_data)
  50. return (Fail_Flag);
  51. return (Pass_Flag);
  52. }

  53. int Write_Flash_Word(Uint16 *data,Uint16 *address)
  54. {
  55. *(volatile Uint16 *)FLASH_ADR1=0x012a;//0xaa;
  56. *(volatile Uint16 *)FLASH_ADR2=0x0095;//0x55;
  57. *(volatile Uint16 *)FLASH_ADR1=0x0120;//0xa0;
  58. *address=*data;
  59. return(Toggle_Bit_Check(address));
  60. }
  61. int Read_Flash_Word(Uint16 *data,Uint16 *address)
  62. {
  63. *(volatile Uint16 *)FLASH_ADR1=0x012a;//0xaa;
  64. *(volatile Uint16 *)FLASH_ADR2=0x0095;//0x55;
  65. *(volatile Uint16 *)FLASH_ADR1=0x01b0;//0xf0;
  66. *data=*address;
  67. return(Toggle_Bit_Check(address));
  68. }
复制代码

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。