|
请教为什么合宙ari001的算法文件flash编程函数是i==30执行页编程:
int ProgramPage(unsigned long adr, unsigned long sz, unsigned char *buf)
{
sz = (sz + 127) & ~127; // Adjust size for 32 Words
FLASH->SR |= FLASH_SR_EOP; // Reset FLASH_EOP
while (sz)
{
FLASH->CR |= FLASH_CR_PG; // Programming Enabled
FLASH->CR |= FLASH_CR_EOPIE;
for (u8 i = 0; i < 32; i++)
{
M32(adr + i * 4) = *((u32 *)(buf + i * 4)); // Program the first word of the Double Word
if (i == 30)
{
FLASH->CR |= FLASH_CR_PGSTRT;
}
}
__asm("DSB");
while (FLASH->SR & FLASH_SR_BSY)
{
IWDG->KR = 0xAAAA; // Reload IWDG
}
FLASH->CR &= ~FLASH_CR_PG; // Programming Disabled
FLASH->CR &= ~FLASH_CR_EOPIE; // Reset FLASH_EOPIE
adr += 128; // Go to next Page
buf += 128;
sz -= 128;
}
return (0); // Done
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|