下面是我的code
- unsigned char
- Flash_SectorErase(uint_32 *FlashPointer)
- {
- unsigned char Return = Flash_OK;
- uint_32 FlashPtr = (uint_32)FlashPointer;
- /* Allocate space on stack to run flash command out of SRAM */
- /* wait till CCIF is set*/
- while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK))
- {;}
-
- /* Write command to FCCOB registers */
- FTFL_FCCOB0 = FlashCmd_SectorErase;
- FTFL_FCCOB1 = (uint_8)(FlashPtr >> 16);
- FTFL_FCCOB2 = (uint_8)((FlashPtr >> 8) & 0xFF);
- FTFL_FCCOB3 = (uint_8)(FlashPtr & 0xFF);
- FTFL_FSTAT |= 0x80;
- /* wait for command completion */
- while (!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK)) {};
- }
复制代码每次运行到:FTFL_FSTAT |= 0x80;
不管我给的的参数是多少都没用,MCU肯定 复位,求高手指导!!
没有,因为我有个代码拷贝到RAM中的历程,
- flashCmdSize = 0x200;
- flashCmdFr = (UINT32)FlashCommandSequence - 1;
- flashCmdTo = (UINT32)__ram_for_command_sequence_func;
- for(i=0;i < flashCmdSize;i++)
- {
- value = READ8(flashCmdFr);
- flashCmdFr++;
- WRITE8(flashCmdTo, value);
- flashCmdTo++;
- }
- pFlashCommandSequence = (pFLASHCOMMANDSEQUENCE)((UINT8 *)__ram_for_command_sequence_func + 1);
复制代码这样的话,在For循环里面也会复位MCU,我不知道为什么。。。我想把2个Demo合并成一个,但他们的.ld文件里面的配置不一样,所以会有这种问题。。
一周热门 更多>