微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > DSP学习交流 > DSP6713 CE1#不拉低

DSP6713 CE1#不拉低

时间:10-02 整理:3721RD 点击:

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


下面是我的程序:

主程序:

  1. Flash_StartAdd = 0x90000000;

  2. flash_chip_erase();
  3. printf("Finish flash erase!\n");// 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.\n");// 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!\n");
  18. printf("Address 0x%x is error! Data is 0x%x\n",i,data);
  19. exit(0);
  20. }
  21. }
  22. printf("Opereation is success.\n");
  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. }

复制代码


这个是因为地址计算错误,没有写到0x90000000CE1空间去……

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top