|
/********************1號(hào)*************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
USART_Configuration();
TIM4_Configuration();
SPI_Configuration();
NVIC_Configuration();
while(1)
{
if(flag==1) //標(biāo)志位有效
{
flag=0;
Dataflash_erase_block(0);
delay_us(10);
bufferPageWrite(present_count,12,1,FLASH_BUFFER1);
delay_us(10);
FlashPageWrite(2,present_count,12);
delay_us(10); //往存儲(chǔ)芯片中寫數(shù)據(jù)
AT45DB_ReadBytes(2,1,12,present_count2); //讀取存儲(chǔ)芯片中的數(shù)據(jù)
SendData(present_count2,12);
SendData(start,15);
}
}
}
/********************2號(hào)*************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
USART_Configuration();
TIM4_Configuration();
SPI_Configuration();
NVIC_Configuration();
AT45DB_ReadBytes(2,1,12,present_count2); //讀取存儲(chǔ)芯片中的數(shù)據(jù)
while(1)
{
if(flag==1)
{
flag=0;
Dataflash_erase_block(0);
delay_us(10);
bufferPageWrite(present_count,12,1,FLASH_BUFFER1);
delay_us(10);
FlashPageWrite(2,present_count,12);
delay_us(10);
SendData(present_count2,12);
SendData(start,15);
}
}
}
/*****************************************************************************/
為什么1號(hào)程序,讀取的數(shù)據(jù)正確,而2好程序讀取的數(shù)據(jù)是錯(cuò)誤的,求解釋,謝謝!
其實(shí)就是單片機(jī)剛上電后,讀取掉電前一刻的數(shù)據(jù),所以程序要按照2的那樣編程。。。。。。。。。
|
|