int型变量不能写入FLASH,FLASH是不是只可以写入数组。变量如何写入FLASH?
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "stmflash.h"
#include "key.h"
//ALIENTEK ì½Ë÷ÕßSTM32F407¿a·¢°å êμÑé34
//FLASHÄ£ÄaEEPROM êμÑé -¿aoˉêy°æ±¾
//¼¼êõÖ§3Ö£o
www.openedv.com
//ìÔ±|μêÆì£o
http://eboard.taobao.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
//×÷ÕߣoÕyμãÔ-×ó @ALIENTEK
//òaD′èëμ½STM32 FLASHμÄ×Ö·û′®êy×é
//const u8 TEXT_Buffer[]={"STM32 FLASH"};
//#define TEXT_LENTH sizeof(TEXT_Buffer)
//#define SIZE TEXT_LENTH/4+((TEXT_LENTH%4)?1:0)
#define FLASH_SAVE_ADDR 0X0800C004
.
int main(void)
{
u8 key=0;
u16 i=0;
//u8 datatemp[SIZE];
int m=1234;
int c;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delay_init(168);
uart_init(115200);
LED_Init();
LCD_Init();
KEY_Init();
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"FLASH EEPROM TEST");
LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,110,200,16,16,"2014/5/9");
LCD_ShowString(30,130,200,16,16,"KEY1:Write KEY0:Read");
//sprintf(asd,"%d",1234);
while(1)
{
key=KEY_Scan(0);
if(key==KEY1_PRES)
{
LCD_Fill(0,170,239,319,WHITE);//Çå3y°ëÆá
LCD_ShowString(30,170,200,16,16,"Start Write FLASH....");
STMFLASH_Write(FLASH_SAVE_ADDR,(u32*)m,10);
LCD_ShowString(30,170,200,16,16,"FLASH Write Finished!");
}
if(key==KEY0_PRES) //KEY0°′ÏÂ,¶áè¡×Ö·û′®2¢ÏÔê¾
{
LCD_ShowString(30,170,200,16,16,"Start Read FLASH.... ");
STMFLASH_Read(FLASH_SAVE_ADDR,(u32*)c,10);
LCD_ShowString(30,170,200,16,16,"The Data Readed Is: ");
//LCD_ShowString(30,190,200,16,16,datatemp);
LCD_ShowxNum(30,200,c,16,16,1);
}
i++;
delay_ms(10);
if(i==20)
{
LED0=!LED0;
i=0;
}
}
}
红 {MOD}的为自己改动部分,为什么每次读出来的数据都是 0;
谢谢,已经学会了。三克油
一周热门 更多>