[Kinetis] K10 的EEPROM 无法读写 不知道有解决过 这方面问题的吗

[复制链接]
1424|7
 楼主| cuiyul 发表于 2015-12-17 18:52 | 显示全部楼层 |阅读模式
一读写   程序就死掉了
 楼主| cuiyul 发表于 2015-12-17 20:17 | 显示全部楼层
  1. void flexint (void)
  2. {
  3.            SCB->SHCSR|=SCB_SHCSR_BUSFAULTENA_Msk|SCB_SHCSR_MEMFAULTENA_Msk|SCB_SHCSR_USGFAULTENA_Msk;
  4.            if ( partition_flash( EEPROM_1K_1K, 0X03))
  5.         {
  6.             /* Device has been partitioned for the first time, so this
  7.              * means the counters have not been initialized yet. We'll
  8.              * zero them out now.
  9.              */
  10.           *((uint32_t *)(LONGWORD_COUNTER_ADDR)) = 0x1;
  11.             while(!(FTFL->FCNFG & FTFL_FCNFG_EEERDY_MASK));
  12.         }
  13.                                 else
  14.                                 {
  15.                                         printf("\nlongword counter = 0x%08X", *(uint32_t *)(LONGWORD_COUNTER_ADDR));
  16.                                
  17.                                 }
  18.                     
  19. }
 楼主| cuiyul 发表于 2015-12-17 20:18 | 显示全部楼层

  1. int partition_flash(int eeprom_size, int dflash_size)
  2. {
  3. //                                unsigned char rrr;
  4.       /* Test to make sure the device is not already partitioned. If it
  5.        * is already partitioned, then return with no action performed.
  6.        */
  7.       if ((SIM->FCFG1 & SIM_FCFG1_DEPART(0xF))!= 0x00000F00)
  8.       {
  9.           printf("\nDevice is already partitioned.\n");
  10.           return 0;
  11.       }
  12.                              /* Write the FCCOB registers */
  13.       FTFL->FCCOB0 = FTFL_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
  14.       FTFL->FCCOB1 = 0x00;
  15.      FTFL->FCCOB2 = 0x00;
  16.       FTFL->FCCOB3 = 0x00;

  17.       /* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */
  18.       FTFL->FCCOB4 =eeprom_size;// eeprom_size;

  19.       /* FFCOB5 is written with the code for the Dflash size (dflash_size define) */
  20.        FTFL->FCCOB5 = dflash_size;//dflash_size;


  21.       /* All required FCCOBx registers are written, so launch the command */
  22.        ftfl_flex.FSTAT = FTFL_FSTAT_CCIF_MASK;
  23.       while(!(FTFL->FSTAT & FTFL_FSTAT_CCIF_MASK));
  24.                        
  25. //      FTFL->FCCOB0 = FTFL_FCCOB0_CCOBn(0x81); // Selects the PGMPART command,0X80±à3ìeeprom?üá?
  26. //      FTFL->FCCOB1 = 0x00;
  27. //      FTFL->FSTAT = FTFL_FSTAT_CCIF_MASK;//??CCIF±ê????D'1-?'??3yCCIF±ê??????'ó?????ˉ?üá?
  28. //      /* Wait for the command to complete */
  29. //      while(!(FTFL->FSTAT & FTFL_FSTAT_CCIF_MASK));//FTFE_FSTATμ?CCIF???ú?üá??'DD?ú??ê???±?3??a0???±μ??üá??'DDíê3é2?±??a1??μè'y?üá?'?ê?íê3é
  30.        return 1;
  31. }
李香兰 发表于 2015-12-17 20:32 | 显示全部楼层
I2C有没有调通,I2C里面有等待寄存器的时候
 楼主| cuiyul 发表于 2015-12-18 09:20 | 显示全部楼层
是内部的flexnvm   模拟出的eeprom    不是外部的
 楼主| cuiyul 发表于 2015-12-18 09:22 | 显示全部楼层
李香兰 发表于 2015-12-17 20:32
I2C有没有调通,I2C里面有等待寄存器的时候

是内部的flexnvm   模拟出的eeprom    不是外部的
NXP_TICS_Jeremy 发表于 2015-12-18 09:39 | 显示全部楼层
你的K10具体型号是多少?
 楼主| cuiyul 发表于 2015-12-18 11:59 | 显示全部楼层
NXP_TICS_Jeremy 发表于 2015-12-18 09:39
你的K10具体型号是多少?

k10dx256vlq10
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

20

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部