找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5298|回復(fù): 5
打印 上一主題 下一主題
收起左側(cè)

stm32數(shù)據(jù)存儲

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:58348 發(fā)表于 2014-9-30 13:14 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式
/********************1號*************************************/
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);   //往存儲芯片中寫數(shù)據(jù)
                                        
                        AT45DB_ReadBytes(2,1,12,present_count2); //讀取存儲芯片中的數(shù)據(jù)
                        SendData(present_count2,12);
                        SendData(start,15);       
                       
                                                                  }

                                                                               }
                                                                               }

/********************2號*************************************/
int main(void)
     {

                 RCC_Configuration();
                 GPIO_Configuration();
                 USART_Configuration();                 
                 TIM4_Configuration();
                 SPI_Configuration();
                 NVIC_Configuration();
                AT45DB_ReadBytes(2,1,12,present_count2); //讀取存儲芯片中的數(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號程序,讀取的數(shù)據(jù)正確,而2好程序讀取的數(shù)據(jù)是錯誤的,求解釋,謝謝!
其實(shí)就是單片機(jī)剛上電后,讀取掉電前一刻的數(shù)據(jù),所以程序要按照2的那樣編程。。。。。。。。。

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:1 發(fā)表于 2014-9-30 13:21 | 只看該作者
存儲芯片是什么?
回復(fù)

使用道具 舉報(bào)

板凳
ID:58348 發(fā)表于 2014-9-30 13:23 | 只看該作者
AT45DB642D
回復(fù)

使用道具 舉報(bào)

地板
ID:58348 發(fā)表于 2014-9-30 13:26 | 只看該作者
admin 發(fā)表于 2014-9-30 13:21
存儲芯片是什么?

AT45DB642D
回復(fù)

使用道具 舉報(bào)

5#
ID:59827 發(fā)表于 2014-10-16 15:33 來自手機(jī) | 只看該作者
樓主倒是很暢快,上來就直接上代碼。
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表