近日用IAR FOR STM8 1.3 +ST 做IAP,用到ST的固件库需要用到块烧写
下面是我的块烧写代码:
IN_RAM(void FLASH_Program(INT16U numblock,INT16U sumblock, INT8U *DataBuf))
{
INT8U count;
INT32U FlashAddr_Start = UPGRADEINLINE_APPSTART_ADDR
+ numblock * UPGRADEINLINE_DATAPCK_BYTESIZE;
INT32U FlashAddr_Last = UPGRADEINLINE_APPSTART_ADDR
+ (numblock + 1) * UPGRADEINLINE_DATAPCK_BYTESIZE;
FLASH->CR2 |= FLASH_CR2_PRG;//选择块编程
for(count = 0;count < 128;count++)
{
*(((PointerAttr INT8U *)(INT32U)FlashAddr_Start)+ count) = (INT8U)DataBuf[count]; (在这里死机了)
}
}
每当程序进入到函数循环时CPU就像死掉一样,仿真调试就停在这!我烧写的FLASH起始是址是0X9000;FLASH也解锁了,请各位大大或用过STM8块烧写的朋友指教啊,请问我在哪个地方操作不当或少操作了(注:用过字编程,成功了,只不过太慢了,60K的程序要两分钟左右,现在不得在改块编程)有好心的朋友能可以给我这方面的源码或例子吗,我邮箱:910377182@qq.com |