初中生
最后登录1970-1-1
在线时间 小时
注册时间2015-7-10
|
楼主 |
发表于 2015-7-29 15:06:48
|
显示全部楼层
void USART1_IRQHandler(void)
{
uint8_t ch[200];
int i;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
ch = USART_ReceiveData(USART1);
i++;
}
FLASH_WriteByte (WRIT_START_ADDR ,ch,20) ;//写入FLASH
}
void FLASH_WriteByte (uint32_t addr ,uint8_t *p,u16 Byte_Num)
{
uint32_t HalfWord;
Byte_Num = Byte_Num/2;
FLASH_Unlock();
NbrOfPage=(WRIT_END_ADDR-WRIT_START_ADDR)/FLASH_PAGE_SIZE;
FLASH_ClearFlag(FLASH_FLAG_BSY|FLASH_FLAG_EOP|FLASH_FLAG_PGERR|FLASH_FLAG_WRPRTERR);
for( EraseCounter=0;( EraseCounter<NbrOfPage)&&(FLASHStatus==FLASH_COMPLETE);EraseCounter++)
{
FLASHStatus=FLASH_ErasePage(WRIT_START_ADDR+(FLASH_PAGE_SIZE*EraseCounter));
}
Address = WRIT_START_ADDR;
if (FLASHStatus == FLASH_COMPLETE)
{
while(Byte_Num --)
{
HalfWord=*(p++);
HalfWord|=*(p++)<<8;
FLASH_ProgramHalfWord(addr, HalfWord);
addr += 2;
}
}
FLASH_Lock();//??
}
这样写是不是可以把接收的字符串按一个字节一个字节的存入Flash中?
|
|