为什么我声明的static静态局部变量值会丢失?

2019-07-21 04:30发布

void read_usbdata(void)
{  
static u32 read_address=0;
volatile u32 readaddress1=0;
    FRESULT res;  
   f_mount(0, &fatfs);
   res = f_open(&file, "Cfont.FON" , FA_READ);
// if (!res)
//    {  
readaddress1=read_address;
f_lseek(&file, readaddress1);  
f_read(&file, Data_buffer, sizeof(Data_buffer), (void *)&num_ReadBytes); 
GPIO_SetBits(GPIOF, GPIO_Pin_7);
//if(read_address>9000)
//printf( "%d ", readaddress1);
//read_address+=4096;
read_address=readaddress1+4096;
// }
f_close(&file);
}
主函数中要调用该函数,本来我想保留read_address值,可是每次程序执行了f_read后read_address就变成0,readaddress1却不改变
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。